Search in sources :

Example 66 with SAMLException

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

the class AssertionManagerClient method getAssertion.

/**
     * Returns the <code>Assertion</code> based on the
     * <code>AssertionIDReference</code>.
     *
     * @param idRef The <code>AssertionIDReference</code> which references to an
     *        Assertion.
     * @param destID A set of String that representing the destination site id.
     *        The destination site id requesting the assertion using
     *        the assertion id reference. This String is compared with the
     *        <code>destID</code> that the assertion is created for originally.
     *        This field is not used (could be null) if the assertion was
     *        created without a <code>destID</code> originally. This String can
     *        be obtained from converting the 20 byte site id sequence to char
     *        array, then a new String from the char array.
     * @return the Assertion referenced by the
     *         <code>AssertionIDReference</code>.
     * @throws SAMLException if an error occurred during the process; or
     *          the assertion could not be found.
     */
public Assertion getAssertion(AssertionIDReference idRef, Set destID) throws SAMLException {
    if (useLocal)
        return (assertionManager.getAssertion(idRef, destID));
    String assertion = null;
    try {
        Set destSet = new HashSet();
        if (destID != null && !destID.isEmpty()) {
            Iterator it = destID.iterator();
            while (it.hasNext()) {
                destSet.add(Base64.encode(SAMLUtils.stringToByteArray((String) it.next())));
            }
        }
        Object[] args = { idRef.getAssertionIDReference(), destSet };
        assertion = (String) stub.send("getAssertionByIdRef", args, null, null);
        return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
    } catch (Exception re) {
        if (SAMLUtils.debug.warningEnabled()) {
            SAMLUtils.debug.warning("AMC:getAssertion: " + idRef, 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 67 with SAMLException

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

the class AssertionManagerImpl method getAssertions.

public Set getAssertions(String ssoToken) throws SAMLException {
    checkInitialization();
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        Object token = sessionProvider.getSession(ssoToken);
        return (assertionManager.getAssertions(token));
    } catch (SessionException ssoe) {
        if (SAMLUtils.debug.messageEnabled()) {
            SAMLUtils.debug.message("AssertionManagerImpl:getAssertions: " + ssoe);
        }
        throw (new SAMLException(ssoe.getMessage()));
    }
}
Also used : SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 68 with SAMLException

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

the class AssertionManagerImpl method getAssertionArtifacts.

public Set getAssertionArtifacts(String ssoToken) throws SAMLException {
    checkInitialization();
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        Object token = sessionProvider.getSession(ssoToken);
        return (assertionManager.getAssertionArtifacts(token));
    } catch (SessionException ssoe) {
        if (SAMLUtils.debug.messageEnabled()) {
            SAMLUtils.debug.message("AssertionManagerImpl:getAssertionArtifacts: " + ssoe);
        }
        throw (new SAMLException(ssoe.getMessage()));
    }
}
Also used : SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 69 with SAMLException

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

the class AssertionManagerImpl method createAssertion2.

public String createAssertion2(String ssoToken, List attributes) throws SAMLException {
    checkInitialization();
    Object token = null;
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        token = sessionProvider.getSession(ssoToken);
    } catch (SessionException ssoe) {
        if (SAMLUtils.debug.messageEnabled()) {
            SAMLUtils.debug.message("AssertionManagerImpl:createAssertion(SSO + attrs) " + ssoe);
        }
        throw (new SAMLException(ssoe.getMessage()));
    }
    LinkedList ll = new LinkedList();
    for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
        ll.add(new Attribute(XMLUtils.toDOMDocument((String) iter.next(), SAMLUtils.debug).getDocumentElement()));
    }
    Assertion a = assertionManager.createAssertion(token, ll);
    return (a.toString(true, true));
}
Also used : Attribute(com.sun.identity.saml.assertion.Attribute) Assertion(com.sun.identity.saml.assertion.Assertion) SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 70 with SAMLException

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

the class DefaultIDPAttributeMapper method getSAMLAttribute.

/**
     * Returns the SAML <code>Attribute</code> object.
     * @param name attribute name.
     * @param values attribute values.
     * @exception WSFederationException if any failure.
     */
protected Attribute getSAMLAttribute(String name, String[] values) throws WSFederationException {
    if (name == null) {
        throw new WSFederationException(bundle.getString("nullInput"));
    }
    List list = new ArrayList();
    if (values != null) {
        for (int i = 0; i < values.length; i++) {
            // Make the AttributeValue element 'by hand', since Attribute 
            // constructor below is expecting a list of AttributeValue 
            // elements
            String attrValueString = SAMLUtils.makeStartElementTagXML("AttributeValue", true, true) + (XMLUtils.escapeSpecialCharacters(values[i])) + SAMLUtils.makeEndElementTagXML("AttributeValue", true);
            list.add(XMLUtils.toDOMDocument(attrValueString, SAMLUtils.debug).getDocumentElement());
        }
    }
    Attribute attribute = null;
    try {
        attribute = new Attribute(name, WSFederationConstants.CLAIMS_URI, list);
    } catch (SAMLException se) {
        throw new WSFederationException(se);
    }
    return attribute;
}
Also used : WSFederationException(com.sun.identity.wsfederation.common.WSFederationException) Attribute(com.sun.identity.saml.assertion.Attribute) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) 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