MessageProcessor.java revision 4a2f0f0be43dfd4c1b490cbf3cc48b6ba6084b1c
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 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: MessageProcessor.java,v 1.2 2008/06/25 05:50:11 qcheng Exp $
*
*/
/* iPlanet-PUBLIC-CLASS */
/**
* The class <code>MessageProcessor</code> is used to process the
* <code>SOAPMessage</code> for the JSR 196 providers. This API will
* be used by both the client and server providers for securing
* applications.
*/
public class MessageProcessor {
// Private constructor, should not be called.
private MessageProcessor() {}
/**
* Constructor
* @param config the provider configuration of WSC or WSP.
*/
}
/**
* This method is used to validate the SOAP Message Request by the
* processing rules of Liberty SOAPBinding specifications.
* @param soapMessage SOAPMessage that needs to be validated.
* @param subject Subject that may be used to populate the authenticated
* @param sharedData that may be used to store any data needed between
* the request and response.
* @param httpRequest HttpServletRequest associated with this SOAP
* Message request.
* @return Object Credential object after successful validation.
* @exception SOAPBindingException for any error occured during validation.
*/
public Object validateRequest (
)
throws SOAPBindingException {
try {
"Verification failed.");
throw new SOAPBindingException(
}
throw new SOAPBindingException(
}
} else {
throw new SOAPBindingException(
}
} catch (SecurityException se) {
"Validation has failed.", se);
"Exception.", sfe);
}
}
/**
* Secures the SOAP Message response by adding necessary headers to the
* given SOAP Message and also signs the message if it is required.
* @param soapMessage SOAP Message that needs to be secured.
* @param sharedData Any shared data that may be needed between the request
* and response.
* @return SOAPMessage Secured SOAP Message by adding liberty headers
* and also signs the message if configured.
* @exception SOAPBindingException for any failure.
*/
public SOAPMessage secureResponse (
)
throws SOAPBindingException {
try {
if(_config.isResponseSignEnabled()) {
}
}
return soapMessage;
"Failed in securing the response", ex);
throw new SOAPBindingException(
}
}
/**
* Secures the request by getting the credential from the discovery
* service.
* @param offering Resource Offering of the discovery service.
* @param credentials List of credentials that are required to access
* the discovery service.
* @param serviceType Service Type that the discovery service should
* need to look for.
* @param soapMessage SOAPMessage that needs to be secured.
* @param sharedData Any shared data that may be used between the request
* and the response.
* @return SOAPMessage Secured SOAP Message.
* @exception SOAPBindingException for any failure.
*/
public SOAPMessage secureRequest(
)
throws SOAPBindingException {
try {
}
"offerings are null.");
throw new SOAPBindingException(
}
// If the security profile is of SAML or Bearer insert a
// security token for this profile.
}
}
}
}
return soapMessage;
"Securing the request.", ex);
throw new SOAPBindingException(
}
}
/**
* Validates the SOAP Response from the service and verifies the signature
* if needed.
* @param soapMessage SOAPMessage that needs to be validated.
* @param sharedData Any shared data that may be required between the
* request and the response.
* @return SOAPMessage Validated SOAP Response.
* @exception SOAPBindingException for any failure.
*/
public SOAPMessage validateResponse(
)
throws SOAPBindingException {
try {
if(_config.isResponseSignEnabled() &&
throw new SOAPBindingException(
}
return soapMessage;
" Response validation failed.", ex);
throw new SOAPBindingException(
}
}
/**
* Signs the message.
* @param soapMessage SOAPMessage that needs to be signed.
* @param profile Security profile that needs to be used for signing.
* @param assertion Security Assertion
* @return SOAPMessage signed SOAPMessage.
*/
private SOAPMessage signMessage(
)
throws SOAPBindingException {
try {
if(soapHeader == null) {
}
throw new SOAPBindingException(
}
if(correlationId != null) {
}
}
"SigElement is null");
throw new SOAPBindingException(
}
importNode(sigElem, true));
"Signing failed.", ex);
throw new SOAPBindingException(
}
}
/**
* Adds the correlation header.
* @param msg SOAP Message that needs to be added with Correlation header.
* @param req Message Request, if present adds the correlation header
* reference.
* @return SOAPHeader SOAP Header with Correlation header.
*/
private SOAPHeader addCorrelationHeader(
)
throws SOAPBindingException {
try {
}
}
return header;
"Could not add correlation header", ex);
throw new SOAPBindingException(
}
}
/**
* Adds binary token to the security header.
*/
private BinarySecurityToken addBinaryToken(
) throws SOAPBindingException {
try {
}
new SecurityTokenManager(getAdminToken());
return binaryToken;
"Could not add binary security token", ex);
throw new SOAPBindingException(
}
}
/**
* Returns web service offering by making a discovery query
*/
private QueryResponse getWebserviceOffering(
)
throws SOAPBindingException {
try {
"Failed in discovery query.", ex);
throw new SOAPBindingException(
}
}
/**
* Returns security profile after parsing the resource offering.
*/
private String processResourceOffering(
)
throws SOAPBindingException {
try {
+ "descriptions are null.");
throw new SOAPBindingException(
}
"MessageProcessor.processResourceOffering:"
+ " security Mechs are empty");
throw new SOAPBindingException(
}
}
//It should not come over here.
throw new SOAPBindingException(
"Failed in processing the resource offering.", ex);
throw new SOAPBindingException(
}
}
/**
* Returns the admin single sign-on token.
*/
private static SSOToken getAdminToken() {
}
/**
* Returns the security header element.
*/
throws SOAPBindingException {
try {
if((headerChildNodes == null) ||
throw new SOAPBindingException(
}
continue;
}
currentNode.getLocalName())) &&
currentNode.getNamespaceURI()))) {
return (Element)currentNode;
}
}
return null;
} catch (SOAPException se) {
"SOAPException", se);
throw new SOAPBindingException(
}
}
}