Search in sources :

Example 1 with SAMLResponderException

use of com.sun.identity.saml.common.SAMLResponderException in project OpenAM by OpenRock.

the class FSNameRegistrationRequest method signXML.

/**
     * Signs the <code>FSNameRegistrationRequest</code> object.
     *
     * @param certAlias the Certificate Alias.
     * @throws SAMLException if this object cannot be signed.
     */
public void signXML(String certAlias) throws SAMLException {
    FSUtils.debug.message("FSNameRegistrationRequest.signXML: Called");
    if (signed) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSNameRegistrationRequest.signXML: " + "the assertion is already signed.");
        }
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "alreadySigned", null);
    }
    if (certAlias == null || certAlias.length() == 0) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "cannotFindCertAlias", null);
    }
    try {
        XMLSignatureManager manager = XMLSignatureManager.getInstance();
        if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, null, IFSConstants.ID, this.id, false);
        } else if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, null, IFSConstants.REQUEST_ID, this.getRequestID(), false);
        } else {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("invalid minor version.");
            }
        }
        signature = XMLUtils.toDOMDocument(signatureString, FSUtils.debug).getDocumentElement();
        signed = true;
        xmlString = this.toXMLString(true, true);
    } catch (Exception e) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "signFailed", null);
    }
}
Also used : XMLSignatureManager(com.sun.identity.saml.xmlsig.XMLSignatureManager) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException) SAMLException(com.sun.identity.saml.common.SAMLException) ParseException(java.text.ParseException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException)

Example 2 with SAMLResponderException

use of com.sun.identity.saml.common.SAMLResponderException in project OpenAM by OpenRock.

the class FSRequest method parseQuery.

/**
     * Parses the Query or <code>SubjectQuery</code> represented by
     * a DOM tree Node. It then checks and sets data members if it is a
     * supported query, such as <code>AuthenticationQuery</code>,
     * <code>AttributeQeury</code>, or <code>AuthorizationDecisionQuery</code>.
     *
     * @param child a <code>DOM</code> Node.
     * @throws <code>SAMLException</code> if the <code>Query</code> is invalid.
     */
private void parseQuery(Node child) throws SAMLException {
    NamedNodeMap nm = child.getAttributes();
    int len = nm.getLength();
    String attrName;
    String attrValue;
    Attr attr;
    boolean found = false;
    for (int j = 0; j < len; j++) {
        attr = (Attr) nm.item(j);
        attrName = attr.getLocalName();
        if ((attrName != null) && (attrName.equals("type"))) {
            attrValue = attr.getNodeValue();
            if (attrValue.equals("AuthenticationQueryType")) {
                if (contentType != NOT_SUPPORTED) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Request(Element): should" + " contain only one AuthenticationQuery.");
                    }
                    throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
                }
                contentType = AUTHENTICATION_QUERY;
                query = new AuthenticationQuery((Element) child);
            } else if (attrValue.equals("AuthorizationDecisionQueryType")) {
                if (contentType != NOT_SUPPORTED) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Request(Element): should " + "contain one " + "AuthorizationDecisionQuery.");
                    }
                    throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
                }
                contentType = AUTHORIZATION_DECISION_QUERY;
                query = new AuthorizationDecisionQuery((Element) child);
            } else if (attrValue.equals("AttributeQueryType")) {
                if (contentType != NOT_SUPPORTED) {
                    if (FSUtils.debug.messageEnabled()) {
                        FSUtils.debug.message("Request(Element): should " + "contain one AttributeQuery.");
                    }
                    throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
                }
                contentType = ATTRIBUTE_QUERY;
                query = new AttributeQuery((Element) child);
            } else {
                if (FSUtils.debug.messageEnabled()) {
                    FSUtils.debug.message("Request(Element): This type of" + " " + attrName + " is not supported.");
                }
                throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "queryNotSupported", null);
            }
            // check typevalue
            found = true;
            break;
        }
    // if found type attribute
    }
    // if not found type
    if (!found) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("Request(Element): missing" + " xsi:type definition in " + child.getLocalName());
        }
        throw new SAMLRequesterException(FSUtils.BUNDLE_NAME, "wrongInput", null);
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) AttributeQuery(com.sun.identity.saml.protocol.AttributeQuery) Element(org.w3c.dom.Element) SAMLRequesterException(com.sun.identity.saml.common.SAMLRequesterException) AuthenticationQuery(com.sun.identity.saml.protocol.AuthenticationQuery) AuthorizationDecisionQuery(com.sun.identity.saml.protocol.AuthorizationDecisionQuery) Attr(org.w3c.dom.Attr) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException)

Example 3 with SAMLResponderException

use of com.sun.identity.saml.common.SAMLResponderException in project OpenAM by OpenRock.

the class FSResponse method signXML.

/**
     * Signs the Response.
     *
     * @param certAlias the Certificate Alias.
     * @throws XMLSignatureException if <code>FSAuthnRequest</code>
     *         cannot be signed.
     */
public void signXML(String certAlias) throws SAMLException {
    FSUtils.debug.message("FSResponse.signXML: Called");
    if (signed) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSResponse.signXML: the assertion is " + "already signed.");
        }
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "alreadySigned", null);
    }
    if (certAlias == null || certAlias.length() == 0) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "cannotFindCertAlias", null);
    }
    try {
        XMLSignatureManager manager = XMLSignatureManager.getInstance();
        if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, IFSConstants.DEF_SIG_ALGO, IFSConstants.ID, this.id, false);
        } else if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, IFSConstants.DEF_SIG_ALGO, IFSConstants.RESPONSE_ID, this.getResponseID(), false);
        } else {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("invalid minor version.");
            }
        }
        signature = XMLUtils.toDOMDocument(signatureString, FSUtils.debug).getDocumentElement();
        signed = true;
        xmlString = this.toXMLString(true, true);
    } catch (Exception e) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "signFailed", null);
    }
}
Also used : XMLSignatureManager(com.sun.identity.saml.xmlsig.XMLSignatureManager) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException) IOException(java.io.IOException) SAMLVersionMismatchException(com.sun.identity.saml.common.SAMLVersionMismatchException) SAMLException(com.sun.identity.saml.common.SAMLException) ParseException(java.text.ParseException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException)

Example 4 with SAMLResponderException

use of com.sun.identity.saml.common.SAMLResponderException in project OpenAM by OpenRock.

the class FSFederationTerminationNotification method signXML.

/**
     * Signs the <code>FSFederationTerminationNotification</code>.
     * object
     *
     * @param certAlias the Certificate Alias
     * @throws SAMLException if
     *         <code>FSFederationTerminationNotification</code>
     *         cannot be signed.
     */
public void signXML(String certAlias) throws SAMLException {
    FSUtils.debug.message("FSFederationTerminationNotification.signXML: Called");
    if (signed) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSFederationTerminationNotification.signXML: " + "the assertion is already signed.");
        }
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "alreadySigned", null);
    }
    if (certAlias == null || certAlias.length() == 0) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "cannotFindCertAlias", null);
    }
    try {
        XMLSignatureManager manager = XMLSignatureManager.getInstance();
        if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, (String) null, IFSConstants.ID, this.id, false);
        } else if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, (String) null, IFSConstants.REQUEST_ID, this.getRequestID(), false);
        } else {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("invalid minor version.");
            }
        }
        signature = XMLUtils.toDOMDocument(signatureString, FSUtils.debug).getDocumentElement();
        signed = true;
        xmlString = this.toXMLString(true, true);
    } catch (Exception e) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "signFailed", null);
    }
}
Also used : XMLSignatureManager(com.sun.identity.saml.xmlsig.XMLSignatureManager) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException) SAMLException(com.sun.identity.saml.common.SAMLException) ParseException(java.text.ParseException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException)

Example 5 with SAMLResponderException

use of com.sun.identity.saml.common.SAMLResponderException in project OpenAM by OpenRock.

the class FSLogoutResponse method signXML.

/**
     * Signs the <code>LogoutResponse</code>.
     *
     * @param certAlias the Certificate Alias.
     * @throws XMLSignatureException if this object cannot be signed.
     */
public void signXML(String certAlias) throws SAMLException {
    FSUtils.debug.message("FSLogoutResponse.signXML: Called");
    if (signed) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSLogoutResponse.signXML: " + "the assertion is already signed.");
        }
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "alreadySigned", null);
    }
    if (certAlias == null || certAlias.length() == 0) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "cannotFindCertAlias", null);
    }
    try {
        XMLSignatureManager manager = XMLSignatureManager.getInstance();
        if (minorVersion == IFSConstants.FF_11_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, IFSConstants.DEF_SIG_ALGO, IFSConstants.ID, this.id, false);
        } else if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
            signatureString = manager.signXML(this.toXMLString(true, true), certAlias, IFSConstants.DEF_SIG_ALGO, IFSConstants.RESPONSE_ID, this.getResponseID(), false);
        } else {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("invalid minor version.");
            }
        }
        signature = XMLUtils.toDOMDocument(signatureString, FSUtils.debug).getDocumentElement();
        signed = true;
        xmlString = this.toXMLString(true, true);
    } catch (Exception e) {
        throw new SAMLResponderException(FSUtils.BUNDLE_NAME, "signFailed", null);
    }
}
Also used : XMLSignatureManager(com.sun.identity.saml.xmlsig.XMLSignatureManager) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException) IOException(java.io.IOException) SAMLVersionMismatchException(com.sun.identity.saml.common.SAMLVersionMismatchException) SAMLException(com.sun.identity.saml.common.SAMLException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) ParseException(java.text.ParseException) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException)

Aggregations

SAMLResponderException (com.sun.identity.saml.common.SAMLResponderException)34 SAMLException (com.sun.identity.saml.common.SAMLException)22 XMLSignatureManager (com.sun.identity.saml.xmlsig.XMLSignatureManager)21 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)15 IOException (java.io.IOException)9 X509Certificate (java.security.cert.X509Certificate)9 ParseException (java.text.ParseException)9 Document (org.w3c.dom.Document)8 SessionException (com.sun.identity.plugin.session.SessionException)7 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)6 SAMLVersionMismatchException (com.sun.identity.saml.common.SAMLVersionMismatchException)5 Element (org.w3c.dom.Element)5 FSAccountMgmtException (com.sun.identity.federation.accountmgmt.FSAccountMgmtException)4 FSLogoutResponse (com.sun.identity.federation.message.FSLogoutResponse)4 HashMap (java.util.HashMap)4 ProviderDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.ProviderDescriptorType)3 FSException (com.sun.identity.federation.common.FSException)2 FSSOAPService (com.sun.identity.federation.services.FSSOAPService)2 SAMLRequesterException (com.sun.identity.saml.common.SAMLRequesterException)2 List (java.util.List)2