Search in sources :

Example 16 with StatusCode

use of com.sun.identity.saml.protocol.StatusCode in project OpenAM by OpenRock.

the class FSLogoutResponse method parseURLEncodedRequest.

/**
         * Returns <code>FSLogoutResponse</code> object. The
         * object is creating by parsing the <code>HttpServletRequest</code>
         * object.
         *
         * @param request the <code>HttpServletRequest</code> object.
         * @throws FSMsgException if there is an error creating this object.
         * @throws SAMLException if there is an error.
         */
public static FSLogoutResponse parseURLEncodedRequest(HttpServletRequest request) throws FSMsgException, SAMLException {
    FSLogoutResponse retLogoutResponse = new FSLogoutResponse();
    try {
        FSUtils.debug.message("checking minor version");
        retLogoutResponse.majorVersion = Integer.parseInt(request.getParameter(IFSConstants.MAJOR_VERSION));
        retLogoutResponse.minorVersion = Integer.parseInt(request.getParameter(IFSConstants.MINOR_VERSION));
    } catch (NumberFormatException ex) {
        throw new FSMsgException("invalidNumber", null);
    }
    String requestID = request.getParameter(IFSConstants.RESPONSE_ID);
    if (requestID != null) {
        retLogoutResponse.responseID = requestID;
    } else {
        String[] args = { IFSConstants.RESPONSE_ID };
        throw new FSMsgException("missingAttribute", args);
    }
    retLogoutResponse.inResponseTo = request.getParameter(IFSConstants.IN_RESPONSE_TO);
    String instantString = request.getParameter(IFSConstants.ISSUE_INSTANT);
    if (instantString == null || instantString.length() == 0) {
        String[] args = { IFSConstants.ISSUE_INSTANT };
        throw new FSMsgException("missingAttribute", args);
    }
    try {
        retLogoutResponse.issueInstant = DateUtils.stringToDate(instantString);
    } catch (ParseException e) {
        throw new FSMsgException("parseError", null);
    }
    FSUtils.debug.message(" get provider Id");
    String providerID = request.getParameter(IFSConstants.PROVIDER_ID);
    if (providerID != null) {
        retLogoutResponse.providerId = providerID;
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("ProviderID : " + retLogoutResponse.providerId);
        }
    } else {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("ProviderID : " + retLogoutResponse.providerId);
        }
        throw new FSMsgException("missingElement", null);
    }
    String relayState = request.getParameter(IFSConstants.RELAY_STATE);
    if (relayState != null) {
        retLogoutResponse.relayState = relayState;
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("RelayState:" + retLogoutResponse.relayState);
        }
    }
    String value = request.getParameter(IFSConstants.VALUE);
    if (value != null) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("Status : " + value);
        }
        StatusCode statusCode = new StatusCode(value);
        retLogoutResponse.status = new Status(statusCode);
    } else {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("Status : " + value);
        }
        throw new FSMsgException("missingElement", null);
    }
    FSUtils.debug.message("Returning Logout response Object");
    return retLogoutResponse;
}
Also used : Status(com.sun.identity.saml.protocol.Status) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) ParseException(java.text.ParseException) StatusCode(com.sun.identity.saml.protocol.StatusCode)

Aggregations

Status (com.sun.identity.saml.protocol.Status)16 StatusCode (com.sun.identity.saml.protocol.StatusCode)16 SAMLException (com.sun.identity.saml.common.SAMLException)13 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)7 SessionException (com.sun.identity.plugin.session.SessionException)7 IOException (java.io.IOException)7 FSException (com.sun.identity.federation.common.FSException)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)4 SessionProvider (com.sun.identity.plugin.session.SessionProvider)4 ParseException (java.text.ParseException)4 ServletException (javax.servlet.ServletException)4 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)3 FSRedirectException (com.sun.identity.federation.common.FSRedirectException)3 FSAuthnResponse (com.sun.identity.federation.message.FSAuthnResponse)3 Assertion (com.sun.identity.saml.assertion.Assertion)3 SAMLResponderException (com.sun.identity.saml.common.SAMLResponderException)3 Response (com.sun.identity.saml.protocol.Response)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3