Search in sources :

Example 6 with SOAPFaultException

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

use of com.sun.identity.liberty.ws.soapbinding.SOAPFaultException 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 8 with SOAPFaultException

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

the class PPRequestHandler method getServiceInstanceUpdateHeader.

/**
     * Gets the service instance update header.
     * 
     * @exception SOAPFaultException.
     */
private ServiceInstanceUpdateHeader getServiceInstanceUpdateHeader() throws SOAPFaultException {
    ServiceInstanceUpdate siu = IDPPServiceManager.getInstance().getServiceInstanceUpdate();
    ServiceInstanceUpdateHeader siuHeader = siu.getServiceInstanceUpdateHeader();
    if (siu.isSOAPFaultNeeded()) {
        QName faultCodeServer = new QName(SOAPBindingConstants.NS_SOAP, "Server");
        SOAPFaultDetail detail = new SOAPFaultDetail(SOAPFaultDetail.ENDPOINT_MOVED, null, null);
        SOAPFault sf = new SOAPFault(faultCodeServer, IDPPUtils.bundle.getString("endPointMoved"), null, detail);
        Message sfmsg = new Message(sf);
        sfmsg.setServiceInstanceUpdateHeader(siuHeader);
        SOAPFaultException sfe = new SOAPFaultException(sfmsg);
        throw sfe;
    }
    return siuHeader;
}
Also used : Message(com.sun.identity.liberty.ws.soapbinding.Message) QName(javax.xml.namespace.QName) ServiceInstanceUpdateHeader(com.sun.identity.liberty.ws.soapbinding.ServiceInstanceUpdateHeader) SOAPFaultDetail(com.sun.identity.liberty.ws.soapbinding.SOAPFaultDetail) SOAPFault(com.sun.identity.liberty.ws.soapbinding.SOAPFault) SOAPFaultException(com.sun.identity.liberty.ws.soapbinding.SOAPFaultException) InteractionSOAPFaultException(com.sun.identity.liberty.ws.interaction.InteractionSOAPFaultException) ServiceInstanceUpdate(com.sun.identity.liberty.ws.interfaces.ServiceInstanceUpdate)

Example 9 with SOAPFaultException

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

the class PPRequestHandler method initInteraction.

/**
     * Initialize interaction for the queries that require interaction
     * @param isQuery true if this is a <code>PP</code> query request, 
     *                false if this is a <code>PP</code> modify request.
     * @param interactResourceMap map of resources that need an interaction
     *                            This map will have key as the resource
     *                            and the value as interaction type. 
     * @param msg SOAP request message
     * @exception SOAPFaultException for interaction redirection
     * @exception IDPPException for any other failure.
     */
private void initInteraction(boolean isQuery, Map interactResourceMap, Message msg) throws SOAPFaultException, IDPPException {
    IDPPUtils.debug.message("PPRequestHandler.initInteraction:Init");
    if (msg == null || interactResourceMap == null || interactResourceMap.isEmpty()) {
        IDPPUtils.debug.error("PPRequestHandler.initInteraction:Null" + "Input parameters");
        throw new IDPPException(IDPPUtils.bundle.getString("nullInputParams"));
    }
    try {
        //Create Interaction inquiry element
        InquiryElement inquiry = JAXBObjectFactory.getObjectFactory().createInquiryElement();
        inquiry.setTitle(IDPPUtils.bundle.getString(IDPPConstants.INTERACTION_TITLE));
        List selectElements = inquiry.getSelectOrConfirmOrText();
        Set inquirySelects = interactResourceMap.keySet();
        Iterator iter = inquirySelects.iterator();
        while (iter.hasNext()) {
            String resource = (String) iter.next();
            String interactionType = (String) interactResourceMap.get(resource);
            if (interactionType.equals(IDPPConstants.INTERACT_FOR_CONSENT)) {
                selectElements.add(getInteractConfirmElement(isQuery, resource, msg));
            } else if (interactionType.equals(IDPPConstants.INTERACT_FOR_VALUE)) {
                selectElements.addAll(getInteractTextElements(isQuery, resource, msg));
            }
        }
        String lang = getLanguage(msg);
        if (LogUtil.isLogEnabled()) {
            String[] data = { logMsg };
            LogUtil.access(Level.INFO, LogUtil.PP_INTERACTION_SUCCESS, data);
        }
        InteractionManager.getInstance().handleInteraction(msg, inquiry, lang);
    } catch (InteractionSOAPFaultException ise) {
        if (IDPPUtils.debug.messageEnabled()) {
            IDPPUtils.debug.message("PPRequestHandler.initInteraction:" + "Interact redirection happened");
        }
        throw ise.getSOAPFaultException();
    } catch (Exception ex) {
        IDPPUtils.debug.error("PPRequestHandler.initInteraction:Failed");
        throw new IDPPException(ex);
    }
}
Also used : Set(java.util.Set) InquiryElement(com.sun.identity.liberty.ws.interaction.jaxb.InquiryElement) Iterator(java.util.Iterator) InteractionSOAPFaultException(com.sun.identity.liberty.ws.interaction.InteractionSOAPFaultException) ArrayList(java.util.ArrayList) List(java.util.List) SOAPFaultException(com.sun.identity.liberty.ws.soapbinding.SOAPFaultException) SOAPBindingException(com.sun.identity.liberty.ws.soapbinding.SOAPBindingException) JAXBException(javax.xml.bind.JAXBException) DSTException(com.sun.identity.liberty.ws.dst.DSTException) InteractionSOAPFaultException(com.sun.identity.liberty.ws.interaction.InteractionSOAPFaultException)

Aggregations

SOAPFaultException (com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)9 Message (com.sun.identity.liberty.ws.soapbinding.Message)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 JAXBException (javax.xml.bind.JAXBException)4 SOAPBindingException (com.sun.identity.liberty.ws.soapbinding.SOAPBindingException)3 SOAPFault (com.sun.identity.liberty.ws.soapbinding.SOAPFault)3 SOAPFaultDetail (com.sun.identity.liberty.ws.soapbinding.SOAPFaultDetail)3 DSTException (com.sun.identity.liberty.ws.dst.DSTException)2 InteractionSOAPFaultException (com.sun.identity.liberty.ws.interaction.InteractionSOAPFaultException)2 InquiryElement (com.sun.identity.liberty.ws.interaction.jaxb.InquiryElement)2 RedirectRequestElement (com.sun.identity.liberty.ws.interaction.jaxb.RedirectRequestElement)2 StatusElement (com.sun.identity.liberty.ws.interaction.jaxb.StatusElement)2 UserInteractionElement (com.sun.identity.liberty.ws.interaction.jaxb.UserInteractionElement)2 Iterator (java.util.Iterator)2 Element (org.w3c.dom.Element)2 InteractionResponseElement (com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement)1 ServiceInstanceUpdate (com.sun.identity.liberty.ws.interfaces.ServiceInstanceUpdate)1 CorrelationHeader (com.sun.identity.liberty.ws.soapbinding.CorrelationHeader)1 ProviderHeader (com.sun.identity.liberty.ws.soapbinding.ProviderHeader)1