Search in sources :

Example 6 with Message

use of com.sun.identity.liberty.ws.soapbinding.Message in project OpenAM by OpenRock.

the class InteractionManager method getRequestMessage.

private Message getRequestMessage(String messageID) {
    Message requestMessage = null;
    CacheEntry cacheEntry = cache.getCacheEntry(messageID);
    if (cacheEntry != null) {
        requestMessage = cacheEntry.getRequestMessage();
    }
    if (debug.messageEnabled()) {
        debug.message("InteractionManager.getRequestMessage():" + " looking up request message for messageID=" + messageID + ":requestMessage=" + (requestMessage == null));
    }
    return requestMessage;
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message)

Example 7 with Message

use of com.sun.identity.liberty.ws.soapbinding.Message in project OpenAM by OpenRock.

the class InteractionManager method newRedirectFaultError.

private SOAPFaultException newRedirectFaultError(QName errorCode) {
    StatusElement se = null;
    try {
        se = objectFactory.createStatusElement();
    } catch (JAXBException je) {
        debug.error("InteractionManager.newRedirectFaultError():" + " can not create StatusElement", je);
    }
    se.setCode(errorCode);
    List details = new ArrayList();
    try {
        details.add(Utils.convertJAXBToElement(se));
    } catch (JAXBException je) {
        debug.error("InteractionManager.newRedirectFaultError():" + "can not create new RedirectFaultError:" + "can not convert JAXBObject to Element", je);
    }
    SOAPFault sf = new SOAPFault(QNAME_SERVER, SERVER_ERROR, FAULT_ACTOR, new SOAPFaultDetail(details));
    SOAPFaultException sfe = new SOAPFaultException(new Message(sf));
    return sfe;
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message) JAXBException(javax.xml.bind.JAXBException) StatusElement(com.sun.identity.liberty.ws.interaction.jaxb.StatusElement) ArrayList(java.util.ArrayList) SOAPFaultDetail(com.sun.identity.liberty.ws.soapbinding.SOAPFaultDetail) ArrayList(java.util.ArrayList) List(java.util.List) SOAPFault(com.sun.identity.liberty.ws.soapbinding.SOAPFault) SOAPFaultException(com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)

Example 8 with Message

use of com.sun.identity.liberty.ws.soapbinding.Message in project OpenAM by OpenRock.

the class DSTRequestHandler method processRequest.

/**
     * Processes the request for the given personal profile service request.
     * @param msg SOAP Request message
     * @return Message SOAP Response Message.
     * @exception SOAPFaultException if the service requires an interaction.
     * @exception Exception for any generic failure.
     */
public Message processRequest(Message msg) throws SOAPFaultException, Exception {
    if (DSTUtils.debug.messageEnabled()) {
        DSTUtils.debug.message("DSTRequestHandler:processRequest:" + "Request received: " + msg.toString());
    }
    List requestBodies = msg.getBodies();
    requestBodies = Utils.convertElementToJAXB(requestBodies);
    if (requestBodies == null || requestBodies.size() == 0) {
        DSTUtils.debug.error("DSTRequestHandler:processRequest:" + "SOAPBodies are null");
        throw new Exception(DSTUtils.bundle.getString("nullInputParams"));
    }
    Message response = null;
    int securityProfile = msg.getSecurityProfileType();
    if ((securityProfile == Message.X509_TOKEN) || (securityProfile == Message.SAML_TOKEN) || (securityProfile == Message.BEARER_TOKEN)) {
        response = new Message(null, generateBinarySecurityToken(msg));
    } else {
        response = new Message();
    }
    response.setCorrelationHeader(msg.getCorrelationHeader());
    response.setWSFVersion(msg.getWSFVersion());
    List responseBodies = processSOAPBodies(requestBodies, msg, response);
    responseBodies = Utils.convertJAXBToElement(responseBodies);
    response.setSOAPBodies(responseBodies);
    if (DSTUtils.debug.messageEnabled()) {
        DSTUtils.debug.message("DSTRequestHandler:processRequest:" + "returned response: " + response.toString());
    }
    return response;
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message) ArrayList(java.util.ArrayList) List(java.util.List) SOAPFaultException(com.sun.identity.liberty.ws.soapbinding.SOAPFaultException) DSTException(com.sun.identity.liberty.ws.dst.DSTException)

Example 9 with Message

use of com.sun.identity.liberty.ws.soapbinding.Message in project OpenAM by OpenRock.

the class DSTClient method sendMessage.

/**
     * Sends the SOAP Message to the data service.
     * @param List of Request Objects.
     * @return List of Response Objects.
     * @exception DSTException for failure.
     */
private List sendMessage(List requestObjects) throws DSTException, InteractionRedirectException {
    DSTUtils.debug.message("DSTClient:sendMessage:Init");
    if (requestObjects == null || requestObjects.size() == 0) {
        DSTUtils.debug.message("DSTClient:sendMessage: requestobj are null");
        throw new DSTException(DSTUtils.bundle.getString("nullInputParams"));
    }
    try {
        Message msg = null;
        ProviderHeader provH = null;
        if (providerID != null) {
            provH = new ProviderHeader(providerID);
        }
        if (securityProfile == Message.X509_TOKEN) {
            if (token == null) {
                throw new DSTException(DSTUtils.bundle.getString("nullToken"));
            }
            DSTUtils.debug.message("DSTClient:sendMessage:using x509");
            msg = new Message(provH, token);
        } else if (securityProfile == Message.SAML_TOKEN) {
            DSTUtils.debug.message("DSTClient:sendMessage:using SAML");
            msg = new Message(provH, assertion);
        } else if (securityProfile == Message.BEARER_TOKEN) {
            DSTUtils.debug.message("DSTClient:sendMessage:using Bearer");
            msg = new Message(provH, assertion);
        } else if (securityProfile == Message.ANONYMOUS) {
            DSTUtils.debug.message("DSTClient:sendMessage:using Anonymous");
            msg = new Message(provH);
        } else {
            throw new DSTException(DSTUtils.bundle.getString("invalidSecurityProfile"));
        }
        msg.setSOAPBodies(requestObjects);
        msg.setWSFVersion(wsfVersion);
        if (clientAuthEnabled) {
            msg.setClientAuthentication(clientAuthEnabled);
        }
        if (DSTUtils.debug.messageEnabled()) {
            DSTUtils.debug.message("DSTClient:sendMessage: request:" + msg.toString());
        }
        Message response = null;
        if (httpRequest != null) {
            response = handleInteraction(msg);
        } else {
            response = Client.sendRequest(msg, soapURI, certAlias, soapAction);
        }
        if (DSTUtils.debug.messageEnabled()) {
            DSTUtils.debug.message("DSTClient:sendMessage:response = " + response.toString());
        }
        serviceInstanceUpdateHeader = response.getServiceInstanceUpdateHeader();
        return response.getBodies();
    } catch (SOAPBindingException sbe) {
        DSTUtils.debug.error("DSTClient:sendMessage:soapbindexception", sbe);
        throw new DSTException(sbe);
    } catch (SOAPFaultException sfe) {
        DSTUtils.debug.error("DSTClient:sendMessage:soapfault", sfe);
        serviceInstanceUpdateHeader = sfe.getSOAPFaultMessage().getServiceInstanceUpdateHeader();
        throw new DSTException(sfe);
    }
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message) ProviderHeader(com.sun.identity.liberty.ws.soapbinding.ProviderHeader) SOAPBindingException(com.sun.identity.liberty.ws.soapbinding.SOAPBindingException) SOAPFaultException(com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)

Example 10 with Message

use of com.sun.identity.liberty.ws.soapbinding.Message in project OpenAM by OpenRock.

the class DSTClient method handleInteraction.

/**
     * Handles interaction request processing.
     * When the interaction is required, it throws and InteractRedirect
     * Exception, and redirect to the caller application(servlet). 
     */
private Message handleInteraction(Message requestMsg) throws DSTException, SOAPFaultException, SOAPBindingException, InteractionRedirectException {
    if (requestMsg == null || httpRequest == null || httpResponse == null || soapURI == null) {
        DSTUtils.debug.error("DSTClient:handeInteraction:null values");
        throw new DSTException(DSTUtils.bundle.getString("nullInputParams"));
    }
    DSTUtils.debug.message("DSTClient:handleInteraction:init");
    String resend = httpRequest.getParameter(InteractionManager.RESEND_MESSAGE);
    String returnURL = httpRequest.getRequestURL().toString();
    Message response;
    try {
        InteractionManager manager = InteractionManager.getInstance();
        if (resend == null) {
            //If the interaction is not required, this will send a
            // original response.
            response = manager.sendRequest(requestMsg, soapURI, certAlias, soapAction, returnURL, httpRequest, httpResponse);
        } else {
            response = manager.resendRequest(returnURL, httpRequest, httpResponse);
        }
        return response;
    } catch (InteractionRedirectException ire) {
        DSTUtils.debug.message("DSTClient:handleInteraction: Interaction" + "Redirection happened.");
        throw ire;
    } catch (InteractionException ie) {
        DSTUtils.debug.error("DSTClient:handleInteraction: Interaction" + " Error occured.", ie);
        throw new DSTException(ie);
    }
}
Also used : InteractionManager(com.sun.identity.liberty.ws.interaction.InteractionManager) InteractionException(com.sun.identity.liberty.ws.interaction.InteractionException) Message(com.sun.identity.liberty.ws.soapbinding.Message) InteractionRedirectException(com.sun.identity.liberty.ws.interaction.InteractionRedirectException)

Aggregations

Message (com.sun.identity.liberty.ws.soapbinding.Message)16 List (java.util.List)8 SOAPFaultException (com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)7 ArrayList (java.util.ArrayList)6 SOAPBindingException (com.sun.identity.liberty.ws.soapbinding.SOAPBindingException)4 SOAPFault (com.sun.identity.liberty.ws.soapbinding.SOAPFault)3 SOAPFaultDetail (com.sun.identity.liberty.ws.soapbinding.SOAPFaultDetail)3 JAXBException (javax.xml.bind.JAXBException)3 SASLResponse (com.sun.identity.liberty.ws.authnsvc.protocol.SASLResponse)2 RedirectRequestElement (com.sun.identity.liberty.ws.interaction.jaxb.RedirectRequestElement)2 StatusElement (com.sun.identity.liberty.ws.interaction.jaxb.StatusElement)2 CorrelationHeader (com.sun.identity.liberty.ws.soapbinding.CorrelationHeader)2 ProviderHeader (com.sun.identity.liberty.ws.soapbinding.ProviderHeader)2 Element (org.w3c.dom.Element)2 SASLRequest (com.sun.identity.liberty.ws.authnsvc.protocol.SASLRequest)1 DSTException (com.sun.identity.liberty.ws.dst.DSTException)1 InteractionException (com.sun.identity.liberty.ws.interaction.InteractionException)1 InteractionManager (com.sun.identity.liberty.ws.interaction.InteractionManager)1 InteractionRedirectException (com.sun.identity.liberty.ws.interaction.InteractionRedirectException)1 InteractionSOAPFaultException (com.sun.identity.liberty.ws.interaction.InteractionSOAPFaultException)1