Search in sources :

Example 1 with Extension

use of com.sun.identity.federation.message.common.Extension in project OpenAM by OpenRock.

the class FSSSOAndFedService method handleAuthnRequest.

private void handleAuthnRequest(HttpServletRequest request, HttpServletResponse response, FSAuthnRequest authnRequest, boolean bPostAuthn, boolean bLECP, String realm, String hostEntityId, String metaAlias, IDPDescriptorType hostedDesc, BaseConfigType hostedConfig) {
    FSUtils.debug.message("FSSSOAndFedService.handleAuthnRequest: Called");
    Object session = null;
    try {
        SessionProvider provider = SessionManager.getProvider();
        session = provider.getSession(request);
        if ((session != null) && (provider.isValid(session))) {
            MultiProtocolUtils.addFederationProtocol(session, SingleLogoutManager.IDFF);
        }
    } catch (SessionException e) {
        FSUtils.debug.warning("FSSSOFedService.handleAuthnRequest: hub", e);
    }
    try {
        if (!bPostAuthn && !authnRequest.getIsPassive()) {
            FSSessionManager sessionService = FSSessionManager.getInstance(metaAlias);
            sessionService.setAuthnRequest(authnRequest.getRequestID(), authnRequest);
        } else {
            // remove it from authn request map
            FSSessionManager sessionService = FSSessionManager.getInstance(metaAlias);
            sessionService.removeAuthnRequest(authnRequest.getRequestID());
        }
        // handle sso
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSSSOAndFedService.handleAuthnRequest: " + "Trying to handle AuthnRequest message: " + authnRequest.toXMLString());
            List extensions = authnRequest.getExtensions();
            if ((extensions != null) && (!extensions.isEmpty())) {
                FSUtils.debug.message("FSSSOAndFedService.handleAuthnRequest: " + "AuthnRequest extensions: " + ((Extension) extensions.get(0)).getAttributeMap());
                ;
            }
        }
        FSServiceManager sm = FSServiceManager.getInstance();
        FSSSOAndFedHandler handler = null;
        if (!bLECP) {
            handler = sm.getSSOAndFedHandler(request, response, authnRequest, realm);
        } else {
            handler = sm.getLECPProfileHandler(request, response, authnRequest, realm);
        }
        if (handler == null) {
            FSUtils.debug.error("FSSSOAndFedService.handleAuthnRequest: " + "could not create SSOAndFedHandler");
            String[] data = { FSUtils.bundle.getString("requestProcessingFailed") };
            LogUtil.error(Level.INFO, LogUtil.AUTHN_REQUEST_PROCESSING_FAILED, data, session);
            response.sendError(response.SC_INTERNAL_SERVER_ERROR, FSUtils.bundle.getString("requestProcessingFailed"));
            return;
        }
        if ((agent != null) && agent.isRunning() && (idffSvc != null)) {
            idffSvc.incIdAuthnRqt();
        }
        handler.setHostedEntityId(hostEntityId);
        handler.setMetaAlias(metaAlias);
        handler.setHostedDescriptor(hostedDesc);
        handler.setHostedDescriptorConfig(hostedConfig);
        handler.setRealm(realm);
        handler.processAuthnRequest(authnRequest, bPostAuthn);
        return;
    } catch (Exception se) {
        FSUtils.debug.error("FSSSOAndFedService: Exception occured:", se);
        try {
            response.sendError(response.SC_INTERNAL_SERVER_ERROR, se.getMessage());
        } catch (IOException ex) {
            FSUtils.debug.error("FSSSOAndFedService: Exception occured " + ex.getMessage());
        }
        return;
    }
}
Also used : Extension(com.sun.identity.federation.message.common.Extension) FSServiceManager(com.sun.identity.federation.services.FSServiceManager) SessionException(com.sun.identity.plugin.session.SessionException) List(java.util.List) IOException(java.io.IOException) FSSessionManager(com.sun.identity.federation.services.FSSessionManager) ServletException(javax.servlet.ServletException) SOAPException(javax.xml.soap.SOAPException) SessionException(com.sun.identity.plugin.session.SessionException) FSException(com.sun.identity.federation.common.FSException) IOException(java.io.IOException) FSAccountMgmtException(com.sun.identity.federation.accountmgmt.FSAccountMgmtException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 2 with Extension

use of com.sun.identity.federation.message.common.Extension in project OpenAM by OpenRock.

the class FSAuthnRequest method parseURLEncodedRequest.

/**
     * Returns <code>FSAuthnRequest</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 <code>FSAuthnRequest</code> object.
     */
public static FSAuthnRequest parseURLEncodedRequest(HttpServletRequest request) throws FSMsgException {
    FSAuthnRequest retAuthnRequest = new FSAuthnRequest();
    String authReqID = request.getParameter(IFSConstants.AUTH_REQUEST_ID);
    if (authReqID == null || authReqID.length() == 0) {
        throw new FSMsgException("nullAuthnRequestID", null);
    }
    retAuthnRequest.requestID = authReqID;
    String instantString = request.getParameter(IFSConstants.ISSUE_INSTANT);
    if (instantString == null || instantString.length() == 0) {
        String[] args = { IFSConstants.ISSUE_INSTANT };
        throw new FSMsgException("missingAttribute", args);
    }
    try {
        retAuthnRequest.issueInstant = DateUtils.stringToDate(instantString);
    } catch (ParseException e) {
        throw new FSMsgException("parseError", null);
    }
    retAuthnRequest.majorVersion = checkMajorVersion(request.getParameter(IFSConstants.MAJOR_VERSION));
    retAuthnRequest.minorVersion = checkMinorVersion(request.getParameter(IFSConstants.MINOR_VERSION));
    String providerId = request.getParameter(IFSConstants.PROVIDER_ID);
    if (providerId == null || providerId.length() == 0) {
        throw new FSMsgException("nullProviderIdInRequest", null);
    } else {
        FSUtils.debug.message("ProviderID of the sender: " + providerId);
        retAuthnRequest.providerId = providerId;
    }
    retAuthnRequest.affiliationID = request.getParameter(IFSConstants.AFFILIATIONID);
    String forceAuthn = request.getParameter(IFSConstants.FORCE_AUTHN_ELEM);
    if (forceAuthn != null && forceAuthn.length() != 0 && (forceAuthn.equals(IFSConstants.TRUE) || forceAuthn.equals(IFSConstants.ONE))) {
        retAuthnRequest.forceAuthn = true;
    } else {
        retAuthnRequest.forceAuthn = false;
    }
    String isPassive = request.getParameter(IFSConstants.IS_PASSIVE_ELEM);
    if (isPassive != null && isPassive.length() != 0 && (isPassive.equals(IFSConstants.TRUE) || isPassive.equals(IFSConstants.ONE))) {
        retAuthnRequest.isPassive = true;
    } else {
        retAuthnRequest.isPassive = false;
    }
    if (retAuthnRequest.minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
        String nameIDPolicy = request.getParameter(IFSConstants.NAMEID_POLICY_ELEMENT);
        if (nameIDPolicy != null && (nameIDPolicy.equals(IFSConstants.NAME_ID_POLICY_FEDERATED) || nameIDPolicy.equals(IFSConstants.NAME_ID_POLICY_ONETIME))) {
            retAuthnRequest.federate = true;
        }
        retAuthnRequest.nameIDPolicy = nameIDPolicy;
    } else {
        String federate = request.getParameter(IFSConstants.FEDERATE);
        if (federate != null && federate.length() != 0 && (federate.equals(IFSConstants.TRUE) || federate.equals(IFSConstants.ONE))) {
            retAuthnRequest.federate = true;
        } else {
            retAuthnRequest.federate = false;
        }
    }
    String protocolProfile = request.getParameter(IFSConstants.PROTOCOL_PROFILE);
    if (protocolProfile != null && protocolProfile.length() != 0) {
        retAuthnRequest.protocolProfile = protocolProfile;
    }
    String relayState = request.getParameter(IFSConstants.RELAY_STATE);
    if (relayState != null && relayState.length() != 0) {
        retAuthnRequest.setRelayState(relayState);
    }
    String authnContextComparison = request.getParameter(IFSConstants.AUTHN_CONTEXT_COMPARISON);
    if (authnContextComparison != null && authnContextComparison.length() != 0) {
        retAuthnRequest.setAuthContextCompType(authnContextComparison);
        String authType = retAuthnRequest.getAuthContextCompType();
        if (!(authType.equals(IFSConstants.MINIMUM) || authType.equals(IFSConstants.EXACT) || authType.equals(IFSConstants.MAXIMUM) || authType.equals(IFSConstants.BETTER))) {
            throw new FSMsgException("wrongInput", null);
        }
    }
    retAuthnRequest.authnContext = RequestAuthnContext.parseURLEncodedRequest(request, retAuthnRequest.getMinorVersion());
    retAuthnRequest.scoping = FSScoping.parseURLEncodedRequest(request);
    Extension extension = Extension.parseURLEncodedRequest(request, QUERY_STRING_EXTENSION_PREFIX, retAuthnRequest.getMinorVersion());
    if (extension != null) {
        retAuthnRequest.extensions = new ArrayList();
        retAuthnRequest.extensions.add(extension);
    }
    return retAuthnRequest;
}
Also used : Extension(com.sun.identity.federation.message.common.Extension) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException)

Example 3 with Extension

use of com.sun.identity.federation.message.common.Extension in project OpenAM by OpenRock.

the class FSAuthnRequest method toURLEncodedQueryString.

/**
     * Returns an URL Encoded Query String.
     *
     * @return a url encoded query string.
     * @throws FSMsgException if there is an error.
     */
public String toURLEncodedQueryString() throws FSMsgException {
    if ((providerId == null) || (providerId.length() == 0)) {
        FSUtils.debug.error("FSAuthnRequest.toURLEncodedQueryString: " + "providerId is null in the request with requestId:" + requestID);
        String[] args = { requestID };
        throw new FSMsgException("nullProviderIdWRequestId", args);
    }
    if ((requestID == null) || (requestID.length() == 0)) {
        requestID = SAMLUtils.generateID();
        if (requestID == null) {
            FSUtils.debug.error("FSAuthnRequest.toURLEncodedQueryString: " + "couldn't generate RequestID.");
            throw new FSMsgException("errorGenerateID", null);
        }
    }
    StringBuffer urlEncodedAuthnReq = new StringBuffer(300);
    urlEncodedAuthnReq.append(IFSConstants.AUTH_REQUEST_ID).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(requestID)).append(IFSConstants.AMPERSAND).append(IFSConstants.MAJOR_VERSION).append(IFSConstants.EQUAL_TO).append(majorVersion).append(IFSConstants.AMPERSAND).append(IFSConstants.MINOR_VERSION).append(IFSConstants.EQUAL_TO).append(minorVersion).append(IFSConstants.AMPERSAND);
    if ((extensions != null) && (!extensions.isEmpty())) {
        Extension extension = (Extension) extensions.get(0);
        urlEncodedAuthnReq.append(extension.toURLEncodedQueryString(QUERY_STRING_EXTENSION_PREFIX)).append(IFSConstants.AMPERSAND);
        if (extensions.size() > 1) {
            if (FSUtils.debug.warningEnabled()) {
                FSUtils.debug.warning("FSAuthnRequest.toURLEncodedQueryString: " + "only one Extension element is allowed and extras " + " will be removed");
            }
        }
    }
    urlEncodedAuthnReq.append(IFSConstants.PROVIDER_ID).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(providerId)).append(IFSConstants.AMPERSAND);
    if (consentURI != null) {
        urlEncodedAuthnReq.append(IFSConstants.CONSENT).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(consentURI)).append(IFSConstants.AMPERSAND);
    }
    if (affiliationID != null) {
        urlEncodedAuthnReq.append(IFSConstants.AFFILIATIONID).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(affiliationID)).append(IFSConstants.AMPERSAND);
    }
    if (issueInstant != null) {
        urlEncodedAuthnReq.append(IFSConstants.ISSUE_INSTANT).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(DateUtils.toUTCDateFormat(issueInstant))).append(IFSConstants.AMPERSAND);
    } else {
        FSUtils.debug.error("FSAuthnRequest.toURLEncodedQueryString: " + "issueInstant missing");
        String[] args = { IFSConstants.ISSUE_INSTANT };
        throw new FSMsgException("missingAttribute", args);
    }
    String strForceAuthn = IFSConstants.FALSE;
    if (forceAuthn) {
        strForceAuthn = IFSConstants.TRUE;
    }
    urlEncodedAuthnReq.append(IFSConstants.FORCE_AUTHN_ELEM).append(IFSConstants.EQUAL_TO).append(strForceAuthn).append(IFSConstants.AMPERSAND);
    String strIsPassive = IFSConstants.FALSE;
    if (isPassive) {
        strIsPassive = IFSConstants.TRUE;
    }
    urlEncodedAuthnReq.append(IFSConstants.IS_PASSIVE_ELEM).append(IFSConstants.EQUAL_TO).append(strIsPassive).append(IFSConstants.AMPERSAND);
    if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
        String strFederate = IFSConstants.NAME_ID_POLICY_NONE;
        if (federate) {
            strFederate = IFSConstants.NAME_ID_POLICY_FEDERATED;
            if (nameIDPolicy != null && nameIDPolicy.length() > 0) {
                strFederate = nameIDPolicy;
            }
        }
        urlEncodedAuthnReq.append(IFSConstants.NAMEID_POLICY_ELEMENT).append(IFSConstants.EQUAL_TO).append(strFederate).append(IFSConstants.AMPERSAND);
    } else {
        String strFederate = IFSConstants.FALSE;
        if (federate) {
            strFederate = IFSConstants.TRUE;
        }
        urlEncodedAuthnReq.append(IFSConstants.FEDERATE).append(IFSConstants.EQUAL_TO).append(strFederate).append(IFSConstants.AMPERSAND);
    }
    if (protocolProfile != null && protocolProfile.length() != 0) {
        urlEncodedAuthnReq.append(IFSConstants.PROTOCOL_PROFILE).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(protocolProfile)).append(IFSConstants.AMPERSAND);
    }
    if (authnContext != null) {
        authnContext.setMinorVersion(minorVersion);
        urlEncodedAuthnReq.append(authnContext.toURLEncodedQueryString());
    }
    if (relayState != null && relayState.length() != 0) {
        urlEncodedAuthnReq.append(IFSConstants.RELAY_STATE).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(relayState)).append(IFSConstants.AMPERSAND);
    }
    if (scoping != null) {
        urlEncodedAuthnReq.append(scoping.toURLEncodedQueryString());
    }
    if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
        if (authContextCompType != null && authContextCompType.length() != 0) {
            urlEncodedAuthnReq.append(IFSConstants.AUTHN_CONTEXT_COMPARISON).append(IFSConstants.EQUAL_TO).append(URLEncDec.encode(authContextCompType)).append(IFSConstants.AMPERSAND);
        }
    }
    int len = urlEncodedAuthnReq.length() - 1;
    if (urlEncodedAuthnReq.charAt(len) == '&') {
        urlEncodedAuthnReq = urlEncodedAuthnReq.deleteCharAt(len);
    }
    return urlEncodedAuthnReq.toString();
}
Also used : Extension(com.sun.identity.federation.message.common.Extension) FSMsgException(com.sun.identity.federation.message.common.FSMsgException)

Example 4 with Extension

use of com.sun.identity.federation.message.common.Extension in project OpenAM by OpenRock.

the class FSAuthnRequest method toXMLString.

/**
     * Creates a String representation of the &lt;lib:AuthnRequest&gt; element.
     *
     * @param includeNS  Determines whether or not the namespace qualifier
     *          is prepended to the Element when converted
     * @param declareNS Determines whether or not the namespace is declared
     *          within the Element.
     * @param includeHeader Determines whether the output include the xml
     *        declaration header.
     * @return A string containing the valid XML for this element.
     * @throws FSMsgException if there is an error.
     */
public String toXMLString(boolean includeNS, boolean declareNS, boolean includeHeader) throws FSMsgException {
    if (xmlString != null) {
        return xmlString;
    }
    if ((providerId == null) || (providerId.length() == 0)) {
        FSUtils.debug.error("FSAuthnRequest.toXMLString: " + "providerId is null in the request with requestId:" + requestID);
        String[] args = { requestID };
        throw new FSMsgException("nullProviderIdWRequestId", args);
    }
    if ((requestID == null) || (requestID.length() == 0)) {
        requestID = SAMLUtils.generateID();
        if (requestID == null) {
            FSUtils.debug.error("FSAuthnRequest.toXMLString: " + "couldn't generate RequestID.");
            throw new FSMsgException("errorGenerateID", null);
        }
    }
    StringBuffer xml = new StringBuffer(300);
    if (includeHeader) {
        xml.append("<?xml version=\"1.0\" encoding=\"").append(IFSConstants.DEFAULT_ENCODING).append("\" ?>");
    }
    String prefix = "";
    String samlpPrefix = "";
    String uri = "";
    String samlpUri = "";
    if (includeNS) {
        prefix = IFSConstants.LIB_PREFIX;
        samlpPrefix = IFSConstants.PROTOCOL_PREFIX;
    }
    if (declareNS) {
        if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
            uri = IFSConstants.LIB_12_NAMESPACE_STRING;
        } else {
            uri = IFSConstants.LIB_NAMESPACE_STRING;
        }
        samlpUri = IFSConstants.PROTOCOL_NAMESPACE_STRING;
    }
    String instantString = DateUtils.toUTCDateFormat(issueInstant);
    if (requestID != null) {
        xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.AUTHN_REQUEST).append(uri).append(IFSConstants.SPACE).append(samlpUri);
        if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION && id != null && !(id.length() == 0)) {
            xml.append(IFSConstants.SPACE).append(IFSConstants.ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(id).append(IFSConstants.QUOTE);
        }
        xml.append(IFSConstants.SPACE).append(IFSConstants.REQUEST_ID).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(requestID).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.MAJOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(majorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.MINOR_VERSION).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(minorVersion).append(IFSConstants.QUOTE).append(IFSConstants.SPACE).append(IFSConstants.ISSUE_INSTANT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(instantString).append(IFSConstants.QUOTE);
        if (consentURI != null) {
            xml.append(IFSConstants.SPACE).append(IFSConstants.CONSENT).append(IFSConstants.EQUAL_TO).append(IFSConstants.QUOTE).append(consentURI).append(IFSConstants.QUOTE);
        }
        xml.append(IFSConstants.RIGHT_ANGLE);
        if ((respondWiths != null) && (respondWiths != Collections.EMPTY_LIST)) {
            Iterator i = respondWiths.iterator();
            while (i.hasNext()) {
                xml.append(IFSConstants.LEFT_ANGLE).append(samlpPrefix).append(IFSConstants.RESPONDWITH).append(IFSConstants.RIGHT_ANGLE).append((String) i.next()).append(IFSConstants.START_END_ELEMENT).append(samlpPrefix).append(IFSConstants.RESPONDWITH).append(IFSConstants.RIGHT_ANGLE);
            }
        }
        if (signed) {
            if (signatureString != null) {
                xml.append(signatureString);
            } else if (signature != null) {
                signatureString = XMLUtils.print(signature);
                xml.append(signatureString);
            }
        }
        if ((extensions != null) && (!extensions.isEmpty())) {
            for (Iterator iter = extensions.iterator(); iter.hasNext(); ) {
                Extension extension = (Extension) iter.next();
                extension.setMinorVersion(minorVersion);
                xml.append(extension.toXMLString());
            }
        }
        xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.PROVIDER_ID).append(IFSConstants.RIGHT_ANGLE).append(providerId).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.PROVIDER_ID).append(IFSConstants.RIGHT_ANGLE);
        if (affiliationID != null) {
            xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.AFFILIATIONID).append(IFSConstants.RIGHT_ANGLE).append(affiliationID).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.AFFILIATIONID).append(IFSConstants.RIGHT_ANGLE);
        }
        if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
            String strFederate = IFSConstants.NAME_ID_POLICY_NONE;
            if (federate) {
                strFederate = IFSConstants.NAME_ID_POLICY_FEDERATED;
                if (nameIDPolicy != null && nameIDPolicy.length() > 0) {
                    strFederate = nameIDPolicy;
                }
            }
            xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.NAMEID_POLICY_ELEMENT).append(IFSConstants.RIGHT_ANGLE).append(strFederate).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.NAMEID_POLICY_ELEMENT).append(IFSConstants.RIGHT_ANGLE);
        } else {
            String strFederate = IFSConstants.FALSE;
            if (federate) {
                strFederate = IFSConstants.TRUE;
            }
            xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.FEDERATE).append(IFSConstants.RIGHT_ANGLE).append(strFederate).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.FEDERATE).append(IFSConstants.RIGHT_ANGLE);
        }
        String strForceAuthn = IFSConstants.FALSE;
        if (forceAuthn) {
            strForceAuthn = IFSConstants.TRUE;
        }
        xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.FORCE_AUTHN_ELEM).append(IFSConstants.RIGHT_ANGLE).append(strForceAuthn).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.FORCE_AUTHN_ELEM).append(IFSConstants.RIGHT_ANGLE);
        String strIsPassive = IFSConstants.FALSE;
        if (isPassive) {
            strIsPassive = IFSConstants.TRUE;
        }
        xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.IS_PASSIVE_ELEM).append(IFSConstants.RIGHT_ANGLE).append(strIsPassive).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.IS_PASSIVE_ELEM).append(IFSConstants.RIGHT_ANGLE);
        if (protocolProfile != null && protocolProfile.length() != 0) {
            xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.PROTOCOL_PROFILE).append(IFSConstants.RIGHT_ANGLE).append(protocolProfile).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.PROTOCOL_PROFILE).append(IFSConstants.RIGHT_ANGLE);
        }
        if (assertionConsumerServiceID != null) {
            xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.ASSERTION_CONSUMER_SVC_ID).append(IFSConstants.RIGHT_ANGLE).append(assertionConsumerServiceID).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.ASSERTION_CONSUMER_SVC_ID).append(IFSConstants.RIGHT_ANGLE);
        }
        if (authnContext != null) {
            authnContext.setMinorVersion(minorVersion);
            xml.append(authnContext.toXMLString());
        }
        if (relayState != null && relayState.length() != 0) {
            xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.RELAY_STATE).append(IFSConstants.RIGHT_ANGLE).append(XMLUtils.escapeSpecialCharacters(relayState)).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.RELAY_STATE).append(IFSConstants.RIGHT_ANGLE);
        }
        if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
            if (scoping != null) {
                xml.append(scoping.toXMLString(true, false));
            }
        }
        if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
            if (authContextCompType != null && authContextCompType.length() != 0) {
                xml.append(IFSConstants.LEFT_ANGLE).append(prefix).append(IFSConstants.AUTHN_CONTEXT_COMPARISON).append(IFSConstants.RIGHT_ANGLE).append(authContextCompType).append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.AUTHN_CONTEXT_COMPARISON).append(IFSConstants.RIGHT_ANGLE);
            }
        }
        xml.append(IFSConstants.START_END_ELEMENT).append(prefix).append(IFSConstants.AUTHN_REQUEST).append(IFSConstants.RIGHT_ANGLE);
    } else {
        FSUtils.debug.error("FSAuthnRequest.toString: requestID is null ");
        throw new FSMsgException("nullAuthnRequestID", null);
    }
    return xml.toString();
}
Also used : Extension(com.sun.identity.federation.message.common.Extension) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) Iterator(java.util.Iterator)

Aggregations

Extension (com.sun.identity.federation.message.common.Extension)4 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)3 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)1 FSException (com.sun.identity.federation.common.FSException)1 FSServiceManager (com.sun.identity.federation.services.FSServiceManager)1 FSSessionManager (com.sun.identity.federation.services.FSSessionManager)1 SessionException (com.sun.identity.plugin.session.SessionException)1 SessionProvider (com.sun.identity.plugin.session.SessionProvider)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 ServletException (javax.servlet.ServletException)1 SOAPException (javax.xml.soap.SOAPException)1