Search in sources :

Example 21 with Assertion

use of com.sun.identity.saml.assertion.Assertion 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 22 with Assertion

use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.

the class AssertionManagerImpl method createAssertionArtifact.

public String createAssertionArtifact(String assertion, String target) throws SAMLException {
    checkInitialization();
    Assertion a = new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement());
    // no need to check null since SAMLException would be thrown if
    // there is any error.
    AssertionArtifact aa = assertionManager.createAssertionArtifact(a, SAMLUtils.byteArrayToString(Base64.decode(target)));
    return (aa.getAssertionArtifact());
}
Also used : Assertion(com.sun.identity.saml.assertion.Assertion) AssertionArtifact(com.sun.identity.saml.protocol.AssertionArtifact)

Example 23 with Assertion

use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.

the class AssertionManagerImpl method getAssertion.

public String getAssertion(String artifact, Set destID) throws SAMLException {
    checkInitialization();
    Set destSet = new HashSet();
    Iterator it = destID.iterator();
    while (it.hasNext()) {
        destSet.add(SAMLUtils.byteArrayToString(Base64.decode(((String) it.next()))));
    }
    Assertion a = assertionManager.getAssertion(new AssertionArtifact(artifact), destSet);
    return (a.toString(true, true));
}
Also used : Assertion(com.sun.identity.saml.assertion.Assertion) AssertionArtifact(com.sun.identity.saml.protocol.AssertionArtifact)

Example 24 with Assertion

use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.

the class AssertionManagerImpl method getAssertion2.

public String getAssertion2(String artifact, String destID) throws SAMLException {
    checkInitialization();
    Assertion a = assertionManager.getAssertion(new AssertionArtifact(artifact), SAMLUtils.byteArrayToString(Base64.decode(destID)));
    return (a.toString(true, true));
}
Also used : Assertion(com.sun.identity.saml.assertion.Assertion) AssertionArtifact(com.sun.identity.saml.protocol.AssertionArtifact)

Example 25 with Assertion

use of com.sun.identity.saml.assertion.Assertion 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)

Aggregations

Assertion (com.sun.identity.saml.assertion.Assertion)32 SAMLException (com.sun.identity.saml.common.SAMLException)18 SessionException (com.sun.identity.plugin.session.SessionException)16 Iterator (java.util.Iterator)9 SessionProvider (com.sun.identity.plugin.session.SessionProvider)7 AssertionIDReference (com.sun.identity.saml.assertion.AssertionIDReference)6 AssertionArtifact (com.sun.identity.saml.protocol.AssertionArtifact)6 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Set (java.util.Set)6 FSException (com.sun.identity.federation.common.FSException)4 FSAssertion (com.sun.identity.federation.message.FSAssertion)4 AssertionManager (com.sun.identity.saml.AssertionManager)4 Statement (com.sun.identity.saml.assertion.Statement)4 Subject (com.sun.identity.saml.assertion.Subject)4 SubjectConfirmation (com.sun.identity.saml.assertion.SubjectConfirmation)4 SubjectStatement (com.sun.identity.saml.assertion.SubjectStatement)4 Status (com.sun.identity.saml.protocol.Status)4 AttributeStatement (com.sun.identity.saml.assertion.AttributeStatement)3 StatusCode (com.sun.identity.saml.protocol.StatusCode)3