Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/28/11 10:03:00 (14 years ago)
Author:
bfarka
Message:

added dokumentation for the service #1441

Location:
branches/OKBJavaConnector/AdministrationService/src/com/heuristiclab/okb/service/administration
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/OKBJavaConnector/AdministrationService/src/com/heuristiclab/okb/service/administration/AdministrationServiceUtil.java

    r6157 r6327  
    44 */
    55package com.heuristiclab.okb.service.administration;
    6 
    76
    87import com.heuristiclab.services.administration.AdministrationService;
     
    2322 */
    2423public final class AdministrationServiceUtil {
    25    
     24
     25    /**
     26     * workaround for getting the selfe signed certificates to work
     27     **/
    2628    static {
    27     // Create a trust manager that does not validate certificate chains
    28     TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
    29       public java.security.cert.X509Certificate[] getAcceptedIssuers() {
    30         return new java.security.cert.X509Certificate[] {};
    31       }
     29        // Create a trust manager that does not validate certificate chains
     30        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
    3231
    33       public void checkClientTrusted(
    34           java.security.cert.X509Certificate[] certs, String authType) {
    35       }
     32        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
     33            return new java.security.cert.X509Certificate[]{};
     34        }
    3635
    37       public void checkServerTrusted(
    38           java.security.cert.X509Certificate[] certs, String authType) {
    39       }
    40     } };
     36        public void checkClientTrusted(
     37                java.security.cert.X509Certificate[] certs, String authType) {
     38        }
    4139
    42     SSLContext sc;
    43     try {
    44       sc = SSLContext.getInstance("SSL");
    45       sc.init(null, trustAllCerts, new java.security.SecureRandom());
    46       HttpsURLConnection
    47           .setDefaultSSLSocketFactory(sc.getSocketFactory());
    48     } catch (NoSuchAlgorithmException e) {
    49       throw new RuntimeException(e);
    50     } catch (KeyManagementException e) {
    51       throw new RuntimeException(e);
    52     }
     40        public void checkServerTrusted(
     41                java.security.cert.X509Certificate[] certs, String authType) {
     42        }
     43    }};
    5344
    54   }
    55    
    56     public static IAdministrationService createAdministrationService()
    57     {
    58         try
    59         {
    60      AdministrationService srv = new AdministrationService(new URL("https://services.heuristiclab.com/OKB.SPR.Java-3.3/AdministrationService.svc"));
     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
     59    /**
     60     * getting an instance of the service
     61     * @return
     62     */
     63    protected static IAdministrationService createAdministrationService() {
     64        try {
     65            AdministrationService srv = new AdministrationService(new URL("https://services.heuristiclab.com/OKB.SPR.Java-3.3/AdministrationService.svc"));
    6166            IAdministrationService port = srv.getAdministrationService();
    6267            return port;
    63            
    64         }
    65         catch(MalformedURLException mue)
    66         {
     68
     69        } catch (MalformedURLException mue) {
    6770            throw new IllegalStateException(mue);
    6871        }
    6972    }
    7073
     74    /*
     75     * fetching a platform from the service
     76     */
     77    public static Platform getPlattform(String platformName) {
     78        Platform returnValue = null;
    7179
    72  
    73 
    74     public static Platform getPlattform(String platformName)
    75     {
    76         Platform returnValue = null;
    77        
    7880        IAdministrationService service = AdministrationServiceUtil.createAdministrationService();
    79         for(com.heuristiclab.services.administration.Platform o : service.getPlatforms().getPlatform())
    80         {
    81             if(o.getName().getValue().equals(platformName))
    82             {
     81        for (com.heuristiclab.services.administration.Platform o : service.getPlatforms().getPlatform()) {
     82            if (o.getName().getValue().equals(platformName)) {
    8383                returnValue = new Platform(o);
    8484            }
    8585        }
    86         if(returnValue == null)
    87         {
     86        if (returnValue == null) {
    8887            ObjectFactory of = new ObjectFactory();
    8988            com.heuristiclab.services.administration.Platform p = of.createPlatform();
    9089            p.setName(of.createString(platformName));
    91            
     90
    9291            p.setDescription(of.createString(platformName));
    9392            long id = createAdministrationService().addPlatform(p);
     
    9594
    9695        }
    97        
     96
    9897        return returnValue;
    9998    }
    100 
    101 
    10299}
  • branches/OKBJavaConnector/AdministrationService/src/com/heuristiclab/okb/service/administration/Platform.java

    r6157 r6327  
    1 /*
    2  * To change this template, choose Tools | Templates
    3  * and open the template in the editor.
    4  */
     1
    52package com.heuristiclab.okb.service.administration;
    63
    74/**
    8  *
     5 * Value object for representing a platform
    96 * @author fab
    107 */
Note: See TracChangeset for help on using the changeset viewer.