Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/AdministrationService/src/administrationservice/Main.java @ 6062

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

added Administrationservice as Netbeansproject #1441

File size: 3.5 KB
Line 
1/*
2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
4 */
5
6package administrationservice;
7
8import com.heuristiclab.services.administration.AdministrationService;
9import com.heuristiclab.services.administration.Algorithm;
10import com.heuristiclab.services.administration.ArrayOfAlgorithm;
11import com.heuristiclab.services.administration.ArrayOfPlatform;
12import com.heuristiclab.services.administration.IAdministrationService;
13import com.heuristiclab.services.administration.Platform;
14import java.net.MalformedURLException;
15import java.net.URL;
16import java.security.KeyManagementException;
17import java.security.NoSuchAlgorithmException;
18import java.util.logging.Level;
19import java.util.logging.Logger;
20import javax.net.ssl.HttpsURLConnection;
21import javax.net.ssl.SSLContext;
22import javax.net.ssl.TrustManager;
23import javax.net.ssl.X509TrustManager;
24
25/**
26 *
27 * @author MartinH
28 */
29public class Main {
30
31
32      static {
33    // Create a trust manager that does not validate certificate chains
34    TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
35      public java.security.cert.X509Certificate[] getAcceptedIssuers() {
36        return new java.security.cert.X509Certificate[] {};
37      }
38
39      public void checkClientTrusted(
40          java.security.cert.X509Certificate[] certs, String authType) {
41      }
42
43      public void checkServerTrusted(
44          java.security.cert.X509Certificate[] certs, String authType) {
45      }
46    } };
47
48    SSLContext sc;
49    try {
50      sc = SSLContext.getInstance("SSL");
51      sc.init(null, trustAllCerts, new java.security.SecureRandom());
52      HttpsURLConnection
53          .setDefaultSSLSocketFactory(sc.getSocketFactory());
54    } catch (NoSuchAlgorithmException e) {
55      throw new RuntimeException(e);
56    } catch (KeyManagementException e) {
57      throw new RuntimeException(e);
58    }
59
60  }
61
62  public void GetAlgorithmsTest(IAdministrationService port) {
63
64    ArrayOfAlgorithm algos = port.getAlgorithms();
65
66
67    for (Algorithm algo : algos.getAlgorithm()) {
68      System.out.println("algo ClassId:=" + algo.getAlgorithmClassId());
69      System.out.println("algo Id:=" + algo.getId());
70      System.out.println("algo PlattformId:=" + algo.getPlatformId());
71      System.out.println("algo Class:=" + algo.getClass());
72      System.out.println("algo Description:="
73          + algo.getDescription().getValue());
74      System.out.println("algo Name:=" + algo.getName().getValue());
75    }
76    //assertTrue("No Algorithms found!", algos.getAlgorithm().size() > 0);
77  }
78
79  public void GetPlatformsTest(IAdministrationService port) {
80
81    ArrayOfPlatform algos = port.getPlatforms();
82
83
84    for (Platform platform : algos.getPlatform()) {
85      System.out.println("platform Id:=" + platform.getId());
86      System.out.println("platform Class:=" + platform.getClass());
87      System.out.println("platform Description:="
88          + platform.getDescription().getValue());
89      System.out.println("platform Name:=" + platform.getName().getValue());
90    }
91    //assertTrue("No Platforms found!", algos.getPlatform().size() > 0);
92  }
93
94
95    /**
96     * @param args the command line arguments
97     */
98    public static void main(String[] args) {
99        try {
100            Main test = new Main();
101            AdministrationService srv = new AdministrationService(new URL("https://services.heuristiclab.com/OKB.SPR.Java-3.3/AdministrationService.svc?wsdl"));
102            IAdministrationService port = srv.getAdministrationService();
103            test.GetAlgorithmsTest(port);
104            test.GetPlatformsTest(port);
105        } catch (MalformedURLException ex) {
106            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
107        }
108    }
109
110}
Note: See TracBrowser for help on using the repository browser.