Client.java revision 195685d773ad5f35ed22b75908856f7aa7066355
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: Client.java,v 1.6 2008/10/10 00:15:09 hengming Exp $
*
* Portions Copyrighted 2014 ForgeRock AS
*/
/**
* The <code>Client</code> class provides web service clients with a method to
* send requests using SOAP connection to web service servers.
*
* @supported.all.api
*/
public class Client {
private final static String SOAP_KEYSTORE_FILE_PROP =
"com.sun.identity.liberty.ws.soap.truststore";
private final static String SOAP_KEYSTORE_PASS_FILE_PROP =
"com.sun.identity.liberty.ws.soap.storepass";
private final static String SOAP_KEYSTORE_TYPE_PROP =
"com.sun.identity.liberty.ws.soap.storetype";
private final static String SOAP_PRIVATE_KEY_PASS_FILE_PROP =
"com.sun.identity.liberty.ws.soap.keypass";
private final static String SOAP_TRUST_MNGR_PROP =
"com.sun.identity.liberty.ws.soap.trustmanager";
private final static String SOAP_TRUST_SECMNGR_ALGO_PROP =
"com.sun.identity.liberty.ws.soap.securitymanager.algorithm";
static {
"com.sun.identity.liberty.ws.soap.certalias");
}
private Client() {}
/**
* Sends a request to a SOAP endpoint and returns the response. The server
* only contains one servlet for different web services. So the SOAP
* endpoint URL has format 'servlet_URL/key'
*
* @param req the request
* @param connectTo the SOAP endpoint URL
* @return a response from the SOAP endpoint
* @throws SOAPBindingException if an error occurs while sending the
* message
* @throws SOAPFaultException if the response is a SOAP Fault
*/
throws SOAPBindingException, SOAPFaultException {
}
/**
* Sends a request to a SOAP endpoint and returns the response. The server
* only contains one servlet for different web services. So the SOAP
* endpoint URL has format 'servlet_URL/key'.
*
* @param req the request message.
* @param connectTo the SOAP endpoint URL
* @param certAlias the cert alias of a client certificate being used in
* SSL
* @return a response from the SOAP endpoint
* @throws SOAPBindingException if an error occurs while sending the
* message
* @throws SOAPFaultException if the response is a SOAP Fault
*/
}
/**
* Sends a request to a SOAP endpoint and returns the response. The server
* only contains one servlet for different web services. So the SOAP
* endpoint URL has format 'servlet_URL/key'.
*
* @param req the request message.
* @param connectTo the SOAP endpoint URL
* @param certAlias the cert alias of a client certificate
* @param soapAction the SOAPAction header
* @return a response from the SOAP endpoint
* @throws SOAPFaultException if a SOAP Fault occurs
* @throws SOAPBindingException if a error occurs while processing,
* sending or receiving Message
*/
throws SOAPBindingException, SOAPFaultException {
try {
} catch (Exception e) {
throw new SOAPBindingException(e.getMessage());
}
soapAction = "";
}
} else {
throw new SOAPBindingException(msg);
}
}
}
try {
new StreamResult(os));
} catch (Exception e) {
throw new SOAPBindingException(e.getMessage());
} finally {
try {
} catch (Exception e) {
}
}
}
try {
throw new SOAPFaultException(resp);
}
} catch (IOException e) {
throw new SOAPBindingException(e.getMessage());
} finally {
try {
} catch (Exception e) {
}
}
}
throw new SOAPBindingException(msg);
}
return resp;
}
/**
* Gets URLConnection associated with the endpoint. If it is a SSL
* connection, the certAlias will be used to get the client certificate.
*
* @param endpoint the url of the SOAP receiver
* @param certAlias the cert alias of a client certificate
* @return a URLConnection object
* @throws Exception if an error occurs while connecting to server
*/
throws Exception {
}
if (con instanceof HttpsURLConnection) {
}
} else {
}
} else {
"HttpsURLConnection, client cert not selected.");
}
}
con.setDoInput(true);
con.setDoOutput(true);
return con;
}
/**
* Initializes JSSE enviroment.
*
* @throws Exception if an error occurs while initializing JSSE
*/
private static void initializeJSSE() throws Exception {
// put SunJSSE at fisrt place, so that JSSE will work
}
algorithm = "SunX509";
}
}
/**
* Define a Trust manager
*
* @param trustStore the keystore used to store certificates
* @param algorithm the algorithm to user
* @throws Exception if an error occurs while instantiating the custom
* class or using the keystore
*/
throws SOAPBindingException{
boolean error = false ;
try{
if(trustManagerDefinition != null
}
} else {
}
}catch(ClassNotFoundException cnfe){
"Client.defineTrustManager class not found: " ,cnfe);
error = true ;
}catch(InstantiationException ie){
"Client.defineTrustManager cannot instantiate: " , ie);
error = true ;
}catch(NoSuchAlgorithmException nsae){
"Client.defineTrustManager no algorithm: " , nsae);
error = true ;
}catch(IllegalAccessException iae){
"Client.defineTrustManager illegal access: " , iae);
error = true ;
}catch(KeyStoreException kse){
"Client.defineTrustManager keystore: " , kse);
error = true ;
}
if(error ){
throw new SOAPBindingException(msg);
}
}
/**
* Checks if Trust Keystore properties are defined
* @return true if a specific trust store is to be used
**/
private static boolean useSpecificTrustStore(){
return(
}
/**
* Create a JKSKeyProvider using either default properties or specific properties
* @return the JKSKeyProvider
**/
private static JKSKeyProvider createKeyProvider() {
if (useSpecificTrustStore()) {
jksKp = new JKSKeyProvider(
} else {
jksKp = new JKSKeyProvider();
}
return jksKp ;
}
}