Search in sources :

Example 61 with SAMLException

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

the class QueryResponse method parseCreds.

private void parseCreds(Element elem) throws DiscoveryException {
    NodeList contentnl = elem.getChildNodes();
    Node child;
    String nodeName;
    SecurityAssertion assertion;
    for (int i = 0, length = contentnl.getLength(); i < length; i++) {
        child = contentnl.item(i);
        if ((nodeName = child.getLocalName()) != null) {
            try {
                assertion = new SecurityAssertion((Element) child);
            } catch (SAMLException se) {
                if (DiscoUtils.debug.messageEnabled()) {
                    DiscoUtils.debug.message("QueryResponse(Element): " + "Exception thrown when parsing Credentials:", se);
                }
                throw new DiscoveryException(DiscoUtils.bundle.getString("wrongCredential"));
            }
            if (creds == null) {
                creds = new ArrayList();
            }
            creds.add(assertion);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SecurityAssertion(com.sun.identity.liberty.ws.security.SecurityAssertion) SAMLException(com.sun.identity.saml.common.SAMLException)

Example 62 with SAMLException

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

the class Attribute method addAttributeValue.

/**
     * Adds <code>AttributeValue</code> to the Attribute.
     *
     * @param value A String representing <code>AttributeValue</code>. 
     * @exception SAMLException 
     */
public void addAttributeValue(String value) throws SAMLException {
    if (value == null || value.length() == 0) {
        if (SAMLUtilsCommon.debug.messageEnabled()) {
            SAMLUtilsCommon.debug.message("addAttributeValue: Input is null");
        }
        throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("nullInput"));
    }
    StringBuffer sb = new StringBuffer(300);
    sb.append("<").append(SAMLConstants.ASSERTION_PREFIX).append("AttributeValue").append(SAMLConstants.assertionDeclareStr).append(">").append(value).append("</").append(SAMLConstants.ASSERTION_PREFIX).append("AttributeValue>");
    try {
        Element ele = XMLUtils.toDOMDocument(sb.toString().trim(), SAMLUtilsCommon.debug).getDocumentElement();
        if (_attributeValue == null) {
            _attributeValue = new ArrayList();
        }
        if (!(_attributeValue.add(ele))) {
            if (SAMLUtilsCommon.debug.messageEnabled()) {
                SAMLUtilsCommon.debug.message("Attribute: failed to " + "add to the attribute value list.");
            }
            throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("addListError"));
        }
    } catch (Exception e) {
        SAMLUtilsCommon.debug.error("addAttributeValue error", e);
        throw new SAMLRequesterException("Exception in addAttributeValue" + e.getMessage());
    }
}
Also used : SAMLRequesterException(com.sun.identity.saml.common.SAMLRequesterException) SAMLException(com.sun.identity.saml.common.SAMLException) SAMLRequesterException(com.sun.identity.saml.common.SAMLRequesterException)

Example 63 with SAMLException

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

the class AssertionManagerClient method getAssertion.

/**
     * Returns assertion associated with the <code>AssertionArtifact</code>.
     * @param artifact An <code>AssertionArtifact</code>.
     * @param destID The destination site requesting the assertion using
     *          the artifact. This String is compared with the
     *          <code>destID</code> that the artifact is created for originally.
     * @return The Assertion referenced to by artifact.
     * @throws SAMLException If an error occurred during the process, or no
     *          assertion maps to the input artifact.
     */
protected Assertion getAssertion(AssertionArtifact artifact, String destID) throws SAMLException {
    if (useLocal) {
        return (assertionManager.getAssertion(artifact, destID));
    }
    String assertion = null;
    try {
        Object[] args = { artifact.getAssertionArtifact(), Base64.encode(SAMLUtils.stringToByteArray(destID)) };
        assertion = (String) stub.send("getAssertion2", args, null, null);
        return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
    } catch (Exception re) {
        if (SAMLUtils.debug.warningEnabled()) {
            SAMLUtils.debug.warning("AMC:getAssertion: " + artifact, re);
        }
        throw (new SAMLException(re.getMessage()));
    }
}
Also used : Assertion(com.sun.identity.saml.assertion.Assertion) SAMLException(com.sun.identity.saml.common.SAMLException) SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException)

Example 64 with SAMLException

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

the class AssertionManagerClient method createAssertionArtifact.

/**
     * Returns an <code>AssertionArtifact</code> for the given <code>
     * Assertion</code>.
     * @param assertion The Assertion for which an Artifact needs to be
     *       created. 
     * @param target The <code>sourceID</code> of the site for which the
     *        <code>AssertionArtifact</code> is created. It is in raw String
     *        format (not Base64 encoded, for example.) This String can be
     *        obtained from converting the 20 bytes sequence to char Array,
     *        then from the char Array to String.
     * @return <code>AssertionArtifact</code>
     * @throws SAMLException if the <code>AssertionArtifact</code> cannot be
     *         created.
     */
public AssertionArtifact createAssertionArtifact(Assertion assertion, String target) throws SAMLException {
    if (useLocal) {
        return (assertionManager.createAssertionArtifact(assertion, target));
    }
    String aa = null;
    try {
        Object[] args = { assertion.toString(true, true), Base64.encode(SAMLUtils.stringToByteArray(target)) };
        aa = (String) stub.send("createAssertionArtifact", args, null, null);
        return (new AssertionArtifact(aa));
    } catch (Exception re) {
        if (SAMLUtils.debug.warningEnabled()) {
            SAMLUtils.debug.warning("AMC:createAssertionArtifact:", re);
        }
        throw (new SAMLException(re.getMessage()));
    }
}
Also used : SAMLException(com.sun.identity.saml.common.SAMLException) AssertionArtifact(com.sun.identity.saml.protocol.AssertionArtifact) SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException)

Example 65 with SAMLException

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

the class AssertionManagerClient method getAssertion.

/**
     * Returns assertion associated with the <code>AssertionArtifact</code>.
     * @param artifact An <code>AssertionArtifact</code>.
     * @param destID  A Set of String that represents the destination id. 
     *          The destination site requesting the assertion using the
     *          artifact. This String is compared with the <code>destID</code>
     *          that the artifact is created for originally. This field must not
     *          be null or empty set.
     * @return The Assertion referenced to by artifact.
     * @throws SAMLException If an error occurred during the process, or no
     *          assertion maps to the input artifact.
     */
public Assertion getAssertion(AssertionArtifact artifact, Set destID) throws SAMLException {
    if (useLocal) {
        return (assertionManager.getAssertion(artifact, destID));
    }
    String assertion = null;
    try {
        if (destID == null || destID.isEmpty()) {
            SAMLUtils.debug.error("AssertionManagerClient:getAssertion(" + "AssertionArtifact, Set): destID set is null");
            throw new SAMLException("nullInput");
        }
        Set destSet = new HashSet();
        Iterator it = destID.iterator();
        while (it.hasNext()) {
            destSet.add(Base64.encode(SAMLUtils.stringToByteArray((String) it.next())));
        }
        Object[] args = { artifact.getAssertionArtifact(), destSet };
        assertion = (String) stub.send("getAssertion", args, null, null);
        return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
    } catch (Exception re) {
        if (SAMLUtils.debug.warningEnabled()) {
            SAMLUtils.debug.warning("AMC:getAssertion: " + artifact, re);
        }
        throw (new SAMLException(re.getMessage()));
    }
}
Also used : Assertion(com.sun.identity.saml.assertion.Assertion) SAMLException(com.sun.identity.saml.common.SAMLException) SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException)

Aggregations

SAMLException (com.sun.identity.saml.common.SAMLException)86 SessionException (com.sun.identity.plugin.session.SessionException)30 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)26 List (java.util.List)23 SAMLResponderException (com.sun.identity.saml.common.SAMLResponderException)19 ArrayList (java.util.ArrayList)19 FSException (com.sun.identity.federation.common.FSException)17 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)17 Iterator (java.util.Iterator)17 XMLSignatureManager (com.sun.identity.saml.xmlsig.XMLSignatureManager)16 SessionProvider (com.sun.identity.plugin.session.SessionProvider)15 Assertion (com.sun.identity.saml.assertion.Assertion)15 Set (java.util.Set)15 Attribute (com.sun.identity.saml.assertion.Attribute)13 Element (org.w3c.dom.Element)13 ParseException (java.text.ParseException)12 Map (java.util.Map)12 Status (com.sun.identity.saml.protocol.Status)11 Document (org.w3c.dom.Document)11 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)10