1 | /* |
---|
2 | * To change this template, choose Tools | Templates |
---|
3 | * and open the template in the editor. |
---|
4 | */ |
---|
5 | package authservice; |
---|
6 | |
---|
7 | import com.heuristiclab.services.authentication.AuthenticationService; |
---|
8 | import com.heuristiclab.services.authentication.ArrayOfUser; |
---|
9 | import com.heuristiclab.services.authentication.User; |
---|
10 | import com.heuristiclab.services.authentication.IAuthenticationService; |
---|
11 | import java.net.MalformedURLException; |
---|
12 | import java.net.URL; |
---|
13 | import java.security.KeyManagementException; |
---|
14 | import java.security.NoSuchAlgorithmException; |
---|
15 | import java.util.logging.Level; |
---|
16 | import java.util.logging.Logger; |
---|
17 | import javax.net.ssl.HttpsURLConnection; |
---|
18 | import javax.net.ssl.SSLContext; |
---|
19 | import javax.net.ssl.TrustManager; |
---|
20 | import javax.net.ssl.X509TrustManager; |
---|
21 | |
---|
22 | /** |
---|
23 | * |
---|
24 | * @author MartinH |
---|
25 | */ |
---|
26 | public class Main { |
---|
27 | |
---|
28 | static { |
---|
29 | // Create a trust manager that does not validate certificate chains |
---|
30 | TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { |
---|
31 | |
---|
32 | public java.security.cert.X509Certificate[] getAcceptedIssuers() { |
---|
33 | return new java.security.cert.X509Certificate[]{}; |
---|
34 | } |
---|
35 | |
---|
36 | public void checkClientTrusted( |
---|
37 | java.security.cert.X509Certificate[] certs, String authType) { |
---|
38 | } |
---|
39 | |
---|
40 | public void checkServerTrusted( |
---|
41 | java.security.cert.X509Certificate[] certs, String authType) { |
---|
42 | } |
---|
43 | }}; |
---|
44 | |
---|
45 | SSLContext sc; |
---|
46 | try { |
---|
47 | sc = SSLContext.getInstance("SSL"); |
---|
48 | sc.init(null, trustAllCerts, new java.security.SecureRandom()); |
---|
49 | HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); |
---|
50 | } catch (NoSuchAlgorithmException e) { |
---|
51 | throw new RuntimeException(e); |
---|
52 | } catch (KeyManagementException e) { |
---|
53 | throw new RuntimeException(e); |
---|
54 | } |
---|
55 | |
---|
56 | } |
---|
57 | |
---|
58 | public void GetUsersTest() { |
---|
59 | // try { |
---|
60 | //AuthenticationService srv = new AuthenticationService(new URL("https://services.heuristiclab.com/OKB.SPR.Java-3.3/AuthenticationService.svc?wsdl")); |
---|
61 | AuthenticationService srv = new AuthenticationService(); |
---|
62 | IAuthenticationService port = srv.getAuthenticationService(); |
---|
63 | |
---|
64 | ArrayOfUser users = port.getUsers(); |
---|
65 | for (User user : users.getUser()) { |
---|
66 | System.out.println("user Name:=" + user.getName().getValue()); |
---|
67 | System.out.println("user Class:=" + user.getClass().getName()); |
---|
68 | } |
---|
69 | //} catch (MalformedURLException ex) { |
---|
70 | // Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
---|
71 | //} |
---|
72 | } |
---|
73 | |
---|
74 | /** |
---|
75 | * @param args the command line arguments |
---|
76 | */ |
---|
77 | public static void main(String[] args) { |
---|
78 | Main test = new Main(); |
---|
79 | test.GetUsersTest(); |
---|
80 | } |
---|
81 | } |
---|