Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/AuthenticationService/src/authservice/Main.java @ 11049

Last change on this file since 11049 was 6147, checked in by mholper, 13 years ago

added UserNameHandler for all serviceProject, central in ECJClient #1441

File size: 2.7 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5package authservice;
6
7import com.heuristiclab.services.authentication.AuthenticationService;
8import com.heuristiclab.services.authentication.ArrayOfUser;
9import com.heuristiclab.services.authentication.User;
10import com.heuristiclab.services.authentication.IAuthenticationService;
11import java.net.MalformedURLException;
12import java.net.URL;
13import java.security.KeyManagementException;
14import java.security.NoSuchAlgorithmException;
15import java.util.logging.Level;
16import java.util.logging.Logger;
17import javax.net.ssl.HttpsURLConnection;
18import javax.net.ssl.SSLContext;
19import javax.net.ssl.TrustManager;
20import javax.net.ssl.X509TrustManager;
21
22/**
23 *
24 * @author MartinH
25 */
26public 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}
Note: See TracBrowser for help on using the repository browser.