Search in sources :

Example 31 with FSMsgException

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

the class FSLogoutNotification method parseXML.

/**
     * Constructor create <code>FSLogoutNotification</code> from a
     * <code>XML</code> string.
     *
     * @param xml the <code>XML</code> string.
     * @throws FSMsgException if there is an error creating
     *         this object.
     */
public static FSLogoutNotification parseXML(String xml) throws FSMsgException {
    Document doc = XMLUtils.toDOMDocument(xml, FSUtils.debug);
    if (doc == null) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSLogoutNotification.parseXML:Error " + "while parsing input xml string");
        }
        throw new FSMsgException("parseError", null);
    }
    Element root = doc.getDocumentElement();
    return new FSLogoutNotification(root);
}
Also used : FSMsgException(com.sun.identity.federation.message.common.FSMsgException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 32 with FSMsgException

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

the class FSAuthnResponse method parseAuthnResponseXML.

/**
    * Creates <code>FSAuthnResponse</code> object from XML Schema.
    *
    * @param xml the XML Schema for this object.
    * @throws <code>SAMLException</code> on error.
    * @throws FSMsgException on error.
    */
public static FSAuthnResponse parseAuthnResponseXML(String xml) throws SAMLException, FSMsgException {
    // parse the xml string
    FSUtils.debug.message("FSAuthnResponse.parseAuthnResponseXML: Called");
    Element root;
    Document doc = XMLUtils.toDOMDocument(xml, FSUtils.debug);
    if (doc == null) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAuthnResponse.parseXML:Error " + "while parsing input xml string");
        }
        throw new FSMsgException("parseError", null);
    }
    root = doc.getDocumentElement();
    return new FSAuthnResponse(root);
}
Also used : FSMsgException(com.sun.identity.federation.message.common.FSMsgException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Example 33 with FSMsgException

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

the class FSAuthnResponseEnvelope method parseXML.

/**
    * Returns the <code>FSAuthnResponseEnvelope</code> object.
    *
    * @param xml the XML string to create this object from
    * @return <code>FSAuthnResponseEnvelope</code> object.
    * @throws FSMsgException if there is error creating the object.
    */
public static FSAuthnResponseEnvelope parseXML(String xml) throws FSMsgException {
    try {
        Document doc = XMLUtils.toDOMDocument(xml, FSUtils.debug);
        Element root = doc.getDocumentElement();
        return new FSAuthnResponseEnvelope(root);
    } catch (SAMLException ex) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAuthnResponseEnvelope.parseXML: " + "Error while parsing input xml string");
        }
        throw new FSMsgException("parseError", null);
    }
}
Also used : FSMsgException(com.sun.identity.federation.message.common.FSMsgException) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) SAMLException(com.sun.identity.saml.common.SAMLException)

Example 34 with FSMsgException

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

the class FSFederationTerminationNotification method parseURLEncodedRequest.

/**
     * Returns <code>FSFederationTerminationNotification</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>FSFederationTerminationNotification</code> object.
     */
public static FSFederationTerminationNotification parseURLEncodedRequest(HttpServletRequest request) throws FSMsgException, SAMLException {
    FSFederationTerminationNotification retFederationTerminationNotification = new FSFederationTerminationNotification();
    try {
        FSUtils.debug.message("checking minor version");
        retFederationTerminationNotification.majorVersion = Integer.parseInt(request.getParameter(IFSConstants.MAJOR_VERSION));
        retFederationTerminationNotification.minorVersion = Integer.parseInt(request.getParameter(IFSConstants.MINOR_VERSION));
    } catch (NumberFormatException ex) {
        throw new FSMsgException("invalidNumber", null);
    }
    String requestID = request.getParameter(IFSConstants.REQUEST_ID);
    if (request != null) {
        retFederationTerminationNotification.requestID = requestID;
    } else {
        String[] args = { IFSConstants.REQUEST_ID };
        throw new FSMsgException("missingAttribute", args);
    }
    String instantString = request.getParameter(IFSConstants.ISSUE_INSTANT);
    if (instantString == null || instantString.length() == 0) {
        String[] args = { IFSConstants.ISSUE_INSTANT };
        throw new FSMsgException("missingAttribute", args);
    }
    try {
        retFederationTerminationNotification.issueInstant = DateUtils.stringToDate(instantString);
    } catch (ParseException e) {
        throw new FSMsgException("parseError", null);
    }
    String providerID = request.getParameter(IFSConstants.PROVIDER_ID);
    if (providerID != null) {
        retFederationTerminationNotification.providerId = providerID;
    } else {
        throw new FSMsgException("missingElement", null);
    }
    String nameFormat = request.getParameter(IFSConstants.NAME_FORMAT);
    String nameQualifier = request.getParameter(IFSConstants.NAME_QUALIFIER);
    String name = request.getParameter("Name");
    if (name == null) {
        throw new FSMsgException("missingNameIdentifier", null);
    }
    String relayState = request.getParameter(IFSConstants.RELAY_STATE);
    if (relayState != null) {
        retFederationTerminationNotification.relayState = relayState;
    }
    retFederationTerminationNotification.nameIdentifier = new NameIdentifier(name, nameQualifier, nameFormat);
    FSUtils.debug.message("Returning Termination Object");
    return retFederationTerminationNotification;
}
Also used : FSMsgException(com.sun.identity.federation.message.common.FSMsgException) NameIdentifier(com.sun.identity.saml.assertion.NameIdentifier) ParseException(java.text.ParseException)

Example 35 with FSMsgException

use of com.sun.identity.federation.message.common.FSMsgException 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

FSMsgException (com.sun.identity.federation.message.common.FSMsgException)46 SAMLException (com.sun.identity.saml.common.SAMLException)17 Document (org.w3c.dom.Document)15 Element (org.w3c.dom.Element)15 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)10 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)10 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)8 Status (com.sun.identity.saml.protocol.Status)8 IOException (java.io.IOException)8 Iterator (java.util.Iterator)8 FSException (com.sun.identity.federation.common.FSException)7 ParseException (java.text.ParseException)7 SessionException (com.sun.identity.plugin.session.SessionException)6 FSNameRegistrationResponse (com.sun.identity.federation.message.FSNameRegistrationResponse)5 StatusCode (com.sun.identity.saml.protocol.StatusCode)5 FSLogoutNotification (com.sun.identity.federation.message.FSLogoutNotification)4 NameIdentifier (com.sun.identity.saml.assertion.NameIdentifier)4 List (java.util.List)4 SOAPMessage (javax.xml.soap.SOAPMessage)4 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)3