Search in sources :

Example 11 with Message

use of com.sun.identity.liberty.ws.soapbinding.Message 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)

Example 12 with Message

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

the class InteractionManager method sendRequest.

/**
     * Sends SOAP request to <code>WSP</code>.  
     * This would be invoked at <code>WSC</code> side.
     *
     * @param requestMessage request message.
     * @param connectTo SOAP URL to which to send the SOAP request
     * @param certAlias SOAP Client Certificate Alias
     * @param soapAction SOAP Action Attribute
     * @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
     * @return response SOAP response 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 binding errors
     * @throws SOAPFaultException if the response message has SOAP fault
     *
     * @supported.api
     */
public Message sendRequest(Message requestMessage, String connectTo, String certAlias, String soapAction, String returnToURL, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws InteractionException, InteractionRedirectException, SOAPBindingException, SOAPFaultException {
    if (debug.messageEnabled()) {
        debug.message("InteractionManager.sendRequest():" + " entering with messageID=" + requestMessage.getCorrelationHeader().getMessageID() + ":refToMessageID=" + requestMessage.getCorrelationHeader().getRefToMessageID() + ":requestMessage=" + requestMessage);
    }
    // construct and set UserInteraction element in requestMessage
    if (interactionConfig.wscIncludesUserInteractionHeader()) {
        Enumeration locales = httpRequest.getLocales();
        List acceptLanguages = new ArrayList();
        while (locales.hasMoreElements()) {
            acceptLanguages.add(locales.nextElement().toString());
        }
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.sendRequest():" + "Accept-Language specified by httpRequest=" + acceptLanguages);
        }
        UserInteractionElement ue = createUserInteractionElement(acceptLanguages);
        String id = SAMLUtils.generateID();
        ue.setId(id);
        if (ue != null) {
            try {
                Element element = Utils.convertJAXBToElement(ue);
                requestMessage.setOtherSOAPHeader(element, id);
            } catch (JAXBException je) {
                debug.error("InteractionManager.sendRequest():" + "not setting userInteractionHeader:" + "can not convert JAXBObject to Element", je);
            }
        }
    }
    Message responseMessage = null;
    try {
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.sendRequest():" + "invoking soap Client.sendRequest():" + ":requestMessage=" + requestMessage + ":connecTo=" + connectTo);
        }
        if (LogUtil.isLogEnabled()) {
            String[] objs = new String[1];
            objs[0] = requestMessage.getCorrelationHeader().getMessageID();
            LogUtil.access(Level.INFO, LogUtil.IS_SENDING_MESSAGE, objs);
        }
        responseMessage = Client.sendRequest(requestMessage, connectTo, certAlias, soapAction);
    } catch (SOAPFaultException sfe) {
        if (debug.messageEnabled()) {
            debug.message("InteractionManager.sendRequest():" + " catching SOAPFaultException=" + sfe);
        }
        String redirectURL = getRedirectURL(sfe);
        if (redirectURL == null) {
            throw sfe;
        }
        String responseID = getResponseID(sfe);
        responseMessage = handleRedirectRequest(requestMessage, redirectURL, responseID, connectTo, certAlias, soapAction, returnToURL, httpRequest, httpResponse);
    }
    if (debug.messageEnabled()) {
        debug.message("InteractionManager.sendRequest():" + " returning response message=" + responseMessage);
    }
    if (LogUtil.isLogEnabled()) {
        String[] objs = new String[2];
        objs[0] = responseMessage.getCorrelationHeader().getMessageID();
        objs[1] = requestMessage.getCorrelationHeader().getMessageID();
        LogUtil.access(Level.INFO, LogUtil.IS_RETURNING_RESPONSE_MESSAGE, objs);
    }
    return responseMessage;
}
Also used : Enumeration(java.util.Enumeration) Message(com.sun.identity.liberty.ws.soapbinding.Message) InquiryElement(com.sun.identity.liberty.ws.interaction.jaxb.InquiryElement) StatusElement(com.sun.identity.liberty.ws.interaction.jaxb.StatusElement) RedirectRequestElement(com.sun.identity.liberty.ws.interaction.jaxb.RedirectRequestElement) UserInteractionElement(com.sun.identity.liberty.ws.interaction.jaxb.UserInteractionElement) Element(org.w3c.dom.Element) InteractionResponseElement(com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) UserInteractionElement(com.sun.identity.liberty.ws.interaction.jaxb.UserInteractionElement) ArrayList(java.util.ArrayList) List(java.util.List) SOAPFaultException(com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)

Example 13 with Message

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

the class DiscoveryClient method createRequest.

private Message createRequest() throws DiscoveryException {
    if (!processed) {
        processResourceOffering();
        processed = true;
    }
    // create new Message according to different secuMechID
    Message req = null;
    ProviderHeader provH = null;
    if (providerID != null) {
        try {
            provH = new ProviderHeader(providerID);
        } catch (SOAPBindingException sbe) {
            throw new DiscoveryException(sbe.getMessage());
        }
    }
    if (clientMech == Message.X509_TOKEN) {
        DiscoSDKUtils.debug.message("DiscoveryClient.createRequest: mech=x509");
        try {
            req = new Message(provH, token);
        } catch (SOAPBindingException sbe) {
            throw new DiscoveryException(sbe.getMessage());
        }
    } else if ((clientMech == Message.SAML_TOKEN) || (clientMech == Message.BEARER_TOKEN)) {
        if (DiscoSDKUtils.debug.messageEnabled()) {
            DiscoSDKUtils.debug.message("DiscoveryClient.createRequest: " + "mech=saml or bearer");
        }
        try {
            req = new Message(provH, assertion);
        } catch (SOAPBindingException sbe) {
            throw new DiscoveryException(sbe.getMessage());
        }
    } else {
        if (DiscoSDKUtils.debug.messageEnabled()) {
            DiscoSDKUtils.debug.message("DiscoveryClient.createRequest: " + "mech=anon");
        }
        try {
            req = new Message(provH);
        } catch (SOAPBindingException sbe) {
            throw new DiscoveryException(sbe.getMessage());
        }
    }
    if (clientAuth) {
        req.setClientAuthentication(clientAuth);
    }
    req.setWSFVersion(wsfVersion);
    return req;
}
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)

Example 14 with Message

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

the class DiscoveryClient method getResourceOffering.

/**
     * Queries discovery service for resource offering.
     * @param query discovery query object 
     * @return Query response Element corresponding to the query
     * @exception DiscoveryException if error occurs
     */
public QueryResponse getResourceOffering(Query query) throws DiscoveryException {
    Message req = createRequest();
    req.setSOAPBody(DiscoSDKUtils.parseXML(query.toString()));
    return new QueryResponse(getResponse(req));
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message)

Example 15 with Message

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

the class DiscoveryClient method modify.

/**
     * Modifies discovery resource offering.
     * @param modify List of Modify object
     * @return List of <code>ModifyResponse</code> object
     * @exception DiscoveryException if error occurs
     */
public ModifyResponse modify(Modify modify) throws DiscoveryException {
    Message req = createRequest();
    req.setSOAPBody(DiscoSDKUtils.parseXML(modify.toString()));
    return new ModifyResponse(getResponse(req));
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message)

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