Changeset 6327 for branches/OKBJavaConnector/AdministrationService/src/com
- Timestamp:
- 05/28/11 10:03:00 (14 years ago)
- 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 4 4 */ 5 5 package com.heuristiclab.okb.service.administration; 6 7 6 8 7 import com.heuristiclab.services.administration.AdministrationService; … … 23 22 */ 24 23 public final class AdministrationServiceUtil { 25 24 25 /** 26 * workaround for getting the selfe signed certificates to work 27 **/ 26 28 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() { 32 31 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 } 36 35 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 } 41 39 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 }}; 53 44 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")); 61 66 IAdministrationService port = srv.getAdministrationService(); 62 67 return port; 63 64 } 65 catch(MalformedURLException mue) 66 { 68 69 } catch (MalformedURLException mue) { 67 70 throw new IllegalStateException(mue); 68 71 } 69 72 } 70 73 74 /* 75 * fetching a platform from the service 76 */ 77 public static Platform getPlattform(String platformName) { 78 Platform returnValue = null; 71 79 72 73 74 public static Platform getPlattform(String platformName)75 {76 Platform returnValue = null;77 78 80 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)) { 83 83 returnValue = new Platform(o); 84 84 } 85 85 } 86 if(returnValue == null) 87 { 86 if (returnValue == null) { 88 87 ObjectFactory of = new ObjectFactory(); 89 88 com.heuristiclab.services.administration.Platform p = of.createPlatform(); 90 89 p.setName(of.createString(platformName)); 91 90 92 91 p.setDescription(of.createString(platformName)); 93 92 long id = createAdministrationService().addPlatform(p); … … 95 94 96 95 } 97 96 98 97 return returnValue; 99 98 } 100 101 102 99 } -
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 5 2 package com.heuristiclab.okb.service.administration; 6 3 7 4 /** 8 * 5 * Value object for representing a platform 9 6 * @author fab 10 7 */
Note: See TracChangeset
for help on using the changeset viewer.