1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* JLasso -- Java bindings for Lasso library
*
* Copyright (C) 2004 Entr'ouvert
* http://lasso.labs.libre-entreprise.org
*
* Authors: Benjamin Poussin <poussin@codelutin.com>
* Emmanuel Raviart <eraviart@entrouvert.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// To run it:
// $ export LD_LIBRARY_PATH=../target/
// $ javac -classpath /usr/share/java/junit.jar:../target/lasso.jar:.:/ LoginTest.java
// $ java -classpath /usr/share/java/junit.jar:../target/lasso.jar:.:/ LoginTest
import junit.framework.TestCase;
import junit.framework.Test;
import junit.framework.TestSuite;
import com.entrouvert.lasso.Lasso;
import com.entrouvert.lasso.LassoServer;
public class LoginTest extends TestCase {
public String generateIdentityProviderContextDump() {
LassoServer serverContext = new LassoServer(
"../../examples/data/idp-metadata.xml",
"../../examples/idp-public-key.pem",
"../../examples/idp-private-key.pem",
"../../examples/idp-crt.pem",
1); // FIXME: Replace with lasso.signatureMethodRsaSha1
serverContext.addProvider(
"../../examples/data/sp-metadata.xml",
"../../examples/sp-public-key.pem",
"../../examples/ca-crt.pem");
String serverContextDump = serverContext.dump();
return serverContextDump;
}
public String generateServiceProviderContextDump() {
LassoServer serverContext = new LassoServer(
"../../examples/data/sp-metadata.xml",
"../../examples/sp-public-key.pem",
"../../examples/sp-private-key.pem",
"../../examples/sp-crt.pem",
1); // FIXME: Replace with lasso.signatureMethodRsaSha1
serverContext.addProvider(
"../../examples/data/idp-metadata.xml",
"../../examples/idp-public-key.pem",
"../../examples/ca-crt.pem");
String serverContextDump = serverContext.dump();
return serverContextDump;
}
public void testSimpleAdd() {
String identityProviderContextDump = generateIdentityProviderContextDump();
assertNotNull(identityProviderContextDump);
String serviceProviderContextDump = generateServiceProviderContextDump();
assertNotNull(serviceProviderContextDump);
}
public static Test suite() {
return new TestSuite(LoginTest.class);
}
public static void main(String args[]) {
Lasso.init();
junit.textui.TestRunner.run(suite());
Lasso.shutdown();
}
}
|