Search in sources :

Example 1 with ParameterType

use of com.sun.identity.liberty.ws.interaction.jaxb.ParameterType 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)

Example 2 with ParameterType

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

the class InteractionUtils method getParameters.

/**
     * Returns user friendly <code>Map</code> representation of parameters
     * in interaction response element
     *
     * @param interactionResponseElement obtained from
     *                        <code>InteractionManager</code>
     * @return a Map of parameters. Keys of the map are parameter 
     *          name String objects.  Values in the map are parameter value
     *          String objects
     */
public static Map getParameters(InteractionResponseElement interactionResponseElement) {
    List parameters = interactionResponseElement.getParameter();
    Map pm = new HashMap();
    Iterator iter = parameters.iterator();
    while (iter.hasNext()) {
        ParameterType pt = (ParameterType) iter.next();
        pm.put(pt.getName(), pt.getValue());
    }
    return pm;
}
Also used : ParameterType(com.sun.identity.liberty.ws.interaction.jaxb.ParameterType) HashMap(java.util.HashMap) Iterator(java.util.Iterator) List(java.util.List) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

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