Search in sources :

Example 1 with CorrelationHeader

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

the class InteractionManager method getResponseID.

String getResponseID(SOAPFaultException sfe) throws SOAPFaultException {
    String responseID = null;
    CorrelationHeader ch = sfe.getSOAPFaultMessage().getCorrelationHeader();
    if (ch == null) {
        debug.error("InteractionManager.getResponseID():" + "null CorrelationHeader in SOAPFaultException");
        throw sfe;
    }
    responseID = ch.getMessageID();
    if (responseID == null) {
        debug.error("InteractionManager.getResponseID():" + "null messageID in SOAPFaultException");
        throw sfe;
    }
    return responseID;
}
Also used : CorrelationHeader(com.sun.identity.liberty.ws.soapbinding.CorrelationHeader)

Example 2 with CorrelationHeader

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

the class InteractionManager method resendRequest.

/**
     * Resends a SOAP request message to <code>WSP</code>.
     * This would be invoked at <code>WSC</code> side.
     *
     * @param returnToURL URL to which to redirect user agent after
     *                    <code>WSP</code> - resource owner interactions
     * @param httpRequest HTTP request object of current user agent request
     * @param httpResponse HTTP response object of current user agent request
     * @param requestMessage SOAP message to be resent.
     * @return response SOAP message sent by <code>WSP</code>.
     *
     * @throws InteractionException for generic interaction error
     * @throws InteractionRedirectException if user agent is redirected to 
     *                     <code>WSP</code> for resource owner interactions
     * @throws SOAPBindingException  for generic SOAP errors
     * @throws SOAPFaultException if the response message has SOAP fault
     *
     * @supported.api
     */
public Message resendRequest(String returnToURL, HttpServletRequest httpRequest, HttpServletResponse httpResponse, Message requestMessage) throws InteractionRedirectException, InteractionException, SOAPBindingException, SOAPFaultException {
    if (debug.messageEnabled()) {
        debug.message("InteractionManager.resendRequest():entering ");
    }
    //check for RESEND_MESSAGE parameter
    String messageID = httpRequest.getParameter(RESEND_MESSAGE);
    if (messageID == null) {
        debug.error("InteractionManager.resend():" + " request without " + RESEND_MESSAGE + " in requestURL=" + httpRequest.getRequestURL().toString());
        String[] objs = { RESEND_MESSAGE };
        throw new InteractionException(INTERACTION_RB_NAME, "missing_query_parameter", objs);
    }
    //check whether WSP advised not to resend
    if ((messageID == "0") || (messageID.equals("false"))) {
        debug.error("InteractionManager.resend():" + " resend not allowed in requestURL=" + httpRequest.getRequestURL().toString());
        throw new InteractionException(INTERACTION_RB_NAME, "wsp_advised_not_to_resend", null);
    }
    //check for original REQUEST_ID
    messageID = httpRequest.getParameter(REQUEST_ID);
    if (messageID == null) {
        debug.error("InteractionManager.resend():" + " request without " + REQUEST_ID + " in requestURL=" + httpRequest.getRequestURL().toString());
        String[] objs = { REQUEST_ID };
        throw new InteractionException(INTERACTION_RB_NAME, "request_missing_query_parameter", objs);
    }
    String connectTo = getConnectTo(messageID);
    if (connectTo == null) {
        debug.error("InteractionManager.resend():" + " old connectTo not  found for messageID=" + messageID);
        throw new InteractionException(INTERACTION_RB_NAME, "old_connectTo_not_found", null);
    }
    if (requestMessage == null) {
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.resendRequest():" + "invoking with null requestMessage:" + "old cached message would be used");
        }
        Message oldMessage = getRequestMessage(messageID);
        if (oldMessage == null) {
            debug.error("InteractionManager.resend():" + " old message not  found for messageID=" + messageID);
            throw new InteractionException(INTERACTION_RB_NAME, "old_message_not_found", null);
        }
        requestMessage = oldMessage;
    } else {
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.resendRequest():" + "invoking with non null requestMessage");
        }
    }
    CorrelationHeader ch = new CorrelationHeader();
    ch.setRefToMessageID(InteractionManager.getInstance().getRequestMessageID(messageID));
    requestMessage.setCorrelationHeader(ch);
    if (debug.messageEnabled()) {
        debug.message("InteractionManager.resendRequest():" + "invoking InteractionManager.sendRequest():" + "with requestMessage=" + requestMessage + ":returnToURL=" + returnToURL);
    }
    if (LogUtil.isLogEnabled()) {
        String[] objs = new String[2];
        objs[0] = messageID;
        objs[1] = ch.getMessageID();
        LogUtil.access(Level.INFO, LogUtil.IS_RESENDING_MESSAGE, objs);
    }
    Message responseMessage = sendRequest(requestMessage, connectTo, getClientCert(messageID), getSoapAction(messageID), returnToURL, httpRequest, httpResponse);
    if (debug.messageEnabled()) {
        debug.message("InteractionManager.resendRequest():" + " returning responseMessage=" + responseMessage);
    }
    return responseMessage;
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message) CorrelationHeader(com.sun.identity.liberty.ws.soapbinding.CorrelationHeader)

Example 3 with CorrelationHeader

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

the class InteractionManager method getInteractionResponseElement.

/**
     * Gets interaction response that was gathered from resource owner
     * by <code>InteractionManager</code>
     *
     * @param requestMessage request message.
     *
     * @return interaction response that was gathered by
     *         <code>InteractionManager</code>.
     *
     * @throws InteractionException for interaction error
     *
     * @supported.api
     */
public InteractionResponseElement getInteractionResponseElement(Message requestMessage) throws InteractionException {
    InteractionResponseElement interactionResponseElement = null;
    CorrelationHeader ch = requestMessage.getCorrelationHeader();
    String messageID = ch.getRefToMessageID();
    CacheEntry cacheEntry = null;
    if (messageID != null) {
        cacheEntry = cache.getCacheEntry(messageID);
        if (cacheEntry != null) {
            interactionResponseElement = cacheEntry.getInteractionResponseElement();
        }
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.getInteractionResponseElement():" + "for messageID=" + messageID + ":" + "responseElement=" + (interactionResponseElement != null));
        }
    }
    if (LogUtil.isLogEnabled()) {
        String[] objs = new String[3];
        objs[0] = ch.getMessageID();
        objs[1] = ch.getRefToMessageID();
        objs[2] = (cacheEntry == null) ? "NULL" : "NOT NULL";
        LogUtil.access(Level.INFO, LogUtil.IS_RETURNING_RESPONSE_ELEMENT, objs);
    }
    return interactionResponseElement;
}
Also used : InteractionResponseElement(com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement) CorrelationHeader(com.sun.identity.liberty.ws.soapbinding.CorrelationHeader)

Example 4 with CorrelationHeader

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

the class InteractionManager method newRedirectFault.

private SOAPFaultException newRedirectFault(String messageID) {
    RedirectRequestElement re = null;
    try {
        re = objectFactory.createRedirectRequestElement();
    } catch (JAXBException je) {
        debug.error("InteractionManager.newRedirectFault():" + " can not create RedirectRequestElement", je);
    }
    CorrelationHeader ch = new CorrelationHeader();
    String responseID = ch.getMessageID();
    ch.setRefToMessageID(messageID);
    String redirectUrl = null;
    String lbRedirectUrl = interactionConfig.getLbWSPRedirectHandler();
    String wspRedirectUrl = interactionConfig.getWSPRedirectHandler();
    if (debug.messageEnabled()) {
        debug.message("InteractionManager.newRedirectURLFault():" + "wspRedirectURL:" + wspRedirectUrl + ", lbRedirectUrl:" + lbRedirectUrl);
    }
    if (lbRedirectUrl == null) {
        redirectUrl = wspRedirectUrl + "?" + TRANS_ID + "=" + responseID;
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.newRedirectURLFault():" + "lbRedirectURL is null, rediectUrl:" + redirectUrl);
        }
    } else {
        //lbRedirectUrl defined
        redirectUrl = lbRedirectUrl + "?" + TRANS_ID + "=" + responseID + "&" + InteractionConfig.HANDLER_HOST_ID + "=" + InteractionConfig.getInstance().getLocalServerId();
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.newRedirectURLFault():" + "lbRedirectURL is not null, rediectUrl:" + redirectUrl);
        }
    }
    re.setRedirectURL(redirectUrl);
    List details = new ArrayList();
    try {
        details.add(Utils.convertJAXBToElement(re));
    } catch (JAXBException je) {
        debug.error("InteractionManager.newRedirectFault():" + " can not create newRedirectFault:" + " can not convert JAXBObject to Element", je);
    }
    SOAPFault sf = new SOAPFault(QNAME_SERVER, SERVER_ERROR, FAULT_ACTOR, new SOAPFaultDetail(details));
    Message sfmsg = new Message(sf);
    sfmsg.setCorrelationHeader(ch);
    SOAPFaultException sfe = new SOAPFaultException(sfmsg);
    return sfe;
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message) CorrelationHeader(com.sun.identity.liberty.ws.soapbinding.CorrelationHeader) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) RedirectRequestElement(com.sun.identity.liberty.ws.interaction.jaxb.RedirectRequestElement) 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)

Aggregations

CorrelationHeader (com.sun.identity.liberty.ws.soapbinding.CorrelationHeader)4 Message (com.sun.identity.liberty.ws.soapbinding.Message)2 InteractionResponseElement (com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement)1 RedirectRequestElement (com.sun.identity.liberty.ws.interaction.jaxb.RedirectRequestElement)1 SOAPFault (com.sun.identity.liberty.ws.soapbinding.SOAPFault)1 SOAPFaultDetail (com.sun.identity.liberty.ws.soapbinding.SOAPFaultDetail)1 SOAPFaultException (com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 JAXBException (javax.xml.bind.JAXBException)1