Search in sources :

Example 1 with InteractionResponseElement

use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement 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 2 with InteractionResponseElement

use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement in project OpenAM by OpenRock.

the class PPRequestHandler method processInteractionConsentResponse.

/**
     * Process the interaction response
     * @param isQuery true if this is a <code>PP</code> query request,
     *                  false if this is a <code>PP</code> modify request.
     * @param msg SOAP Request Message
     * @param resource interaction resource
     * @return true if the consent is allowed.
     */
private boolean processInteractionConsentResponse(boolean isQuery, Message msg, String resource) {
    if (IDPPUtils.debug.messageEnabled()) {
        IDPPUtils.debug.message("PPRequestHandler.processInteraction" + "Response:Init");
    }
    if (msg == null || resource == null) {
        IDPPUtils.debug.error("PPRequestHandler:processInteraction" + "Response:null input params");
        return false;
    }
    resource = IDPPUtils.getExpressionContext(resource);
    if (IDPPUtils.debug.messageEnabled()) {
        IDPPUtils.debug.message("PPRequestHandler:processInteraction" + "PP Element that was trying to access:" + resource);
    }
    try {
        InteractionResponseElement ire = InteractionManager.getInstance().getInteractionResponseElement(msg);
        if (ire == null) {
            return false;
        }
        Map responses = InteractionUtils.getParameters(ire);
        if (responses == null || responses.isEmpty()) {
            return false;
        }
        String value = (String) responses.get(resource);
        if (value == null || value.equals("false")) {
            if (IDPPUtils.debug.messageEnabled()) {
                IDPPUtils.debug.message("PPRequestHandler.process" + "Interaction: response is deny");
            }
            return false;
        } else {
            return true;
        }
    } catch (Exception e) {
        IDPPUtils.debug.error("PPRequestHandler.processInteraction" + "Response: Exception occured.", e);
        return false;
    }
}
Also used : InteractionResponseElement(com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement) HashMap(java.util.HashMap) Map(java.util.Map) 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)

Example 3 with InteractionResponseElement

use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement in project OpenAM by OpenRock.

the class PPRequestHandler method processInteractionValueResponse.

/**
     * Process the interaction response for values.
     * @param isQuery true if this is a <code>PP</code> query request,
     *                false if this is a <code>PP</code> modify request.
     * @param msg SOAP Request Message
     * @param resource interaction resource
     * @return Map map of interacted data. 
     */
private Map processInteractionValueResponse(boolean isQuery, Message msg, String resource) {
    if (IDPPUtils.debug.messageEnabled()) {
        IDPPUtils.debug.message("PPRequestHandler.processInteraction" + "Response:Init");
    }
    if (msg == null || resource == null) {
        IDPPUtils.debug.error("PPRequestHandler:processInteraction" + "Response:null input params");
        return null;
    }
    //Get the actual element
    resource = IDPPUtils.getExpressionContext(resource);
    if (IDPPUtils.debug.messageEnabled()) {
        IDPPUtils.debug.message("PPRequestHandler:processInteraction" + "PP Element that was trying to access:" + resource);
    }
    try {
        Map interactedData = new HashMap();
        InteractionResponseElement ire = InteractionManager.getInstance().getInteractionResponseElement(msg);
        if (ire == null) {
            return null;
        }
        Map responses = InteractionUtils.getParameters(ire);
        if (responses == null || responses.isEmpty()) {
            return null;
        }
        String lang = getLanguage(msg);
        PPInteractionHelper interactionHelper = new PPInteractionHelper(lang);
        Map queries = interactionHelper.getInteractForValueQuestions(isQuery, resource);
        Iterator iter = queries.keySet().iterator();
        while (iter.hasNext()) {
            String query = (String) iter.next();
            String value = (String) responses.get(query);
            if (value == null || value.length() == 0) {
                continue;
            }
            interactedData.put(interactionHelper.getPPAttribute(query), value);
        }
        return interactedData;
    } catch (Exception e) {
        IDPPUtils.debug.error("PPRequestHandler.processInteraction" + "Response: Exception occured.", e);
        return null;
    }
}
Also used : InteractionResponseElement(com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement) HashMap(java.util.HashMap) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) 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)

Example 4 with InteractionResponseElement

use of com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement in project OpenAM by OpenRock.

the class WSPRedirectHandlerServlet method sendInteractionResponsePage.

private void sendInteractionResponsePage(String messageID, HttpServletRequest httpRequest, HttpServletResponse httpResponse, String returnToURL) throws IOException {
    if (debug.messageEnabled()) {
        debug.message("WSPRedirectHandlerServlet.sendInteractionResponsePage():" + "entering");
    }
    try {
        //read and save query parameters;
        InteractionResponseElement interactionResponseElement = JAXBObjectFactory.getObjectFactory().createInteractionResponseElement();
        List list = interactionResponseElement.getParameter();
        Enumeration parameterNames = httpRequest.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            String parameterName = (String) parameterNames.nextElement();
            /*
                ParameterType parameterType  
                        = JAXBObjectFactory.getObjectFactory()
                        .createParameterType();
                */
            String parameterValue = httpRequest.getParameter(parameterName);
            if (debug.messageEnabled()) {
                debug.message("WSPRedirectHandlerServlet" + ".sendInteractionResponsePage():" + "parameterName=" + parameterName + ", parameterValue=" + parameterValue);
            }
            int index = parameterName.indexOf(PARAMETER_PREFIX);
            if (index != -1) {
                ParameterType parameterType = JAXBObjectFactory.getObjectFactory().createParameterType();
                parameterName = parameterName.substring(index + PARAMETER_PREFIX.length());
                parameterType.setName(parameterName);
                parameterType.setValue(parameterValue);
                list.add(parameterType);
            }
        }
        if (LogUtil.isLogEnabled()) {
            String[] objs = new String[1];
            objs[0] = messageID;
            LogUtil.access(Level.INFO, LogUtil.IS_COLLECTED_RESPONSE_FROM_USER_AGENT, objs);
        }
        //store InteractionResponse in interaction manager;
        InteractionManager.getInstance().setInteractionResponseElement(messageID, interactionResponseElement);
        if (returnToURL.indexOf("?") != -1) {
            returnToURL = returnToURL + "&" + InteractionManager.RESEND_MESSAGE + "=" + InteractionManager.getInstance().getRequestMessageID(messageID);
        } else {
            returnToURL = returnToURL + "?" + InteractionManager.RESEND_MESSAGE + "=" + messageID;
        }
        if (debug.messageEnabled()) {
            debug.message("WSPRedirectHandlerServlet." + " sendInteractionResponsePage():" + "redirecting user agent to returnToURL=" + returnToURL);
        }
        httpResponse.sendRedirect(returnToURL);
        if (LogUtil.isLogEnabled()) {
            String[] objs = new String[1];
            objs[0] = messageID;
            LogUtil.access(Level.INFO, LogUtil.IS_REDIRECTED_USER_AGENT_BACK, objs);
        }
    } catch (JAXBException je) {
        debug.error("WSPRedirectHandlerServlet.sendInteractionResponsePage():" + "catching JAXBException =", je);
        showErrorPage(httpRequest, httpResponse, "Error createing JAXBObject:" + je.getMessage());
    } catch (Exception e) {
        debug.error("WSPRedirectHandlerServlet.sendInteractionResponsePage():" + "catching Exception =", e);
    }
}
Also used : InteractionResponseElement(com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement) ParameterType(com.sun.identity.liberty.ws.interaction.jaxb.ParameterType) Enumeration(java.util.Enumeration) JAXBException(javax.xml.bind.JAXBException) List(java.util.List) TransformerException(javax.xml.transform.TransformerException) ServletException(javax.servlet.ServletException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Aggregations

InteractionResponseElement (com.sun.identity.liberty.ws.interaction.jaxb.InteractionResponseElement)4 JAXBException (javax.xml.bind.JAXBException)3 DSTException (com.sun.identity.liberty.ws.dst.DSTException)2 InteractionSOAPFaultException (com.sun.identity.liberty.ws.interaction.InteractionSOAPFaultException)2 SOAPBindingException (com.sun.identity.liberty.ws.soapbinding.SOAPBindingException)2 SOAPFaultException (com.sun.identity.liberty.ws.soapbinding.SOAPFaultException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ParameterType (com.sun.identity.liberty.ws.interaction.jaxb.ParameterType)1 CorrelationHeader (com.sun.identity.liberty.ws.soapbinding.CorrelationHeader)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Enumeration (java.util.Enumeration)1 Iterator (java.util.Iterator)1 List (java.util.List)1 ServletException (javax.servlet.ServletException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 SAXException (org.xml.sax.SAXException)1