Search in sources :

Example 1 with QueryResponse

use of com.sun.identity.liberty.ws.disco.QueryResponse in project OpenAM by OpenRock.

the class MessageProcessor method secureRequest.

/**
     * 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.
     * @throws SOAPBindingException for any failure.
     */
public SOAPMessage secureRequest(ResourceOffering offering, List credentials, String serviceType, SOAPMessage soapMessage, Map sharedData) throws SOAPBindingException {
    Utils.debug.message("MessageProcessor.secureRequest:Init");
    try {
        SOAPHeader header = addCorrelationHeader(soapMessage, null);
        QueryResponse discoResponse = getWebserviceOffering(offering, credentials, serviceType);
        if (Utils.debug.messageEnabled()) {
            Utils.debug.message("MessageProcessor.secureRequest: " + "Discovery Response: " + discoResponse.toString());
        }
        ResourceOffering serviceOffering = (ResourceOffering) discoResponse.getResourceOffering().get(0);
        List creds = discoResponse.getCredentials();
        String securityProfile = processResourceOffering(serviceOffering);
        SecurityAssertion securityAssertion = null;
        // security token for this profile.
        if (securityProfile.equals(Message.NULL_SAML) || securityProfile.equals(Message.TLS_SAML) || securityProfile.equals(Message.CLIENT_TLS_SAML) || securityProfile.equals(Message.NULL_BEARER) || securityProfile.equals(Message.TLS_BEARER) || securityProfile.equals(Message.CLIENT_TLS_BEARER) || securityProfile.equals(Message.NULL_SAML_WSF11) || securityProfile.equals(Message.TLS_SAML_WSF11) || securityProfile.equals(Message.CLIENT_TLS_SAML_WSF11) || securityProfile.equals(Message.NULL_BEARER_WSF11) || securityProfile.equals(Message.TLS_BEARER_WSF11) || securityProfile.equals(Message.CLIENT_TLS_BEARER_WSF11)) {
            if (creds != null && creds.size() != 0) {
                securityAssertion = (SecurityAssertion) creds.get(0);
                securityAssertion.addToParent(header);
            }
        }
        if (securityProfile.equals(Message.NULL_SAML) || securityProfile.equals(Message.TLS_SAML) || securityProfile.equals(Message.CLIENT_TLS_SAML) || securityProfile.equals(Message.NULL_X509) || securityProfile.equals(Message.TLS_X509) || securityProfile.equals(Message.CLIENT_TLS_X509) || securityProfile.equals(Message.NULL_SAML_WSF11) || securityProfile.equals(Message.TLS_SAML_WSF11) || securityProfile.equals(Message.CLIENT_TLS_SAML_WSF11) || securityProfile.equals(Message.NULL_X509_WSF11) || securityProfile.equals(Message.TLS_X509_WSF11) || securityProfile.equals(Message.CLIENT_TLS_X509_WSF11)) {
            soapMessage = signMessage(soapMessage, securityProfile, securityAssertion);
        }
        if (Utils.debug.messageEnabled()) {
            Utils.debug.message("MessageProcessor.secureRequest: " + XMLUtils.print(soapMessage.getSOAPPart().getEnvelope()));
        }
        return soapMessage;
    } catch (Exception ex) {
        Utils.debug.error("MessageProcessor.secureRequest: Failure in " + "Securing the request.", ex);
        throw new SOAPBindingException(Utils.bundle.getString("secureRequestFailed"));
    }
}
Also used : ResourceOffering(com.sun.identity.liberty.ws.disco.ResourceOffering) QueryResponse(com.sun.identity.liberty.ws.disco.QueryResponse) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) SecurityAssertion(com.sun.identity.liberty.ws.security.SecurityAssertion) SOAPHeader(javax.xml.soap.SOAPHeader) SOAPException(javax.xml.soap.SOAPException)

Aggregations

QueryResponse (com.sun.identity.liberty.ws.disco.QueryResponse)1 ResourceOffering (com.sun.identity.liberty.ws.disco.ResourceOffering)1 SecurityAssertion (com.sun.identity.liberty.ws.security.SecurityAssertion)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SOAPException (javax.xml.soap.SOAPException)1 SOAPHeader (javax.xml.soap.SOAPHeader)1 NodeList (org.w3c.dom.NodeList)1