Announcement Announcement Module
Collapse
No announcement yet.
saaj client via ssl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • saaj client via ssl

    Hello all,

    i need to access a web service via ssl with saaj api.

    all i found to do this is setting system properties:
    Code:
    System.setProperty("javax.net.ssl.keyStore", "...");
    ...
    System.setProperty("javax.net.ssl.trustStore", "...");
    ...
    i can not do this. the clients are web applications that run on websphere, and every one need their own keystore and truststore configuration.

    when i have access a url via ssl with java.net api, to solve this, each client set up a SSLContext with his keystore and truststore and set to HttpsURLConnection:
    Code:
    String keyManagerFactoryAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
    KeyManagerFactory kmFactory = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
    KeyStore ks = KeyStore.getInstance(keyStoreType);
    InputStream inKeyStore = keyStore.openStream();
    ks.load(inKeyStore, keyStorePassword.toCharArray());
    inKeyStore.close();
    kmFactory.init(ks, keyStorePassword.toCharArray());
    KeyManager[] kms = kmFactory.getKeyManagers();
    
    String trustManagerFactoryAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
    TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(trustManagerFactoryAlgorithm);
    KeyStore ts = KeyStore.getInstance(trustStoreType);
    InputStream inTrustStore = trustStore.openStream();
    ts.load(inTrustStore, trustStorePassword.toCharArray());
    inTrustStore.close();
    tmFactory.init(ts);
    TrustManager[] tms = tmFactory.getTrustManagers();
    
    context = SSLContext.getInstance("SSL");
    context.init(kms, tms, null);
    
    SSLSocketFactory sslSocketFactory = context.getSocketFactory();
    HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
    con.setSSLSocketFactory(sslSocketFactory);
    can i do something similar with saaj api??? i found with axis api, but not with saaj.

    thanks in advance,
    CÚsar.
Working...
X