Search in sources :

Example 11 with Assertion

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

the class AssertionManagerClient method createAssertion.

/** 
     * Returns an assertion that contains an authentication statement.
     * @param token User session that contains authentication
     *        information which is needed to create the authentication
     *        statement. 
     * @return the created assertion.
     * @throws SAMLException if the assertion cannot be created.
     */
public Assertion createAssertion(Object token) throws SAMLException {
    if (useLocal) {
        return (assertionManager.createAssertion(token));
    }
    String assertion = null;
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        Object[] args = { sessionProvider.getSessionID(token) };
        assertion = (String) stub.send("createAssertion", args, null, null);
        return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
    } catch (Exception re) {
        if (SAMLUtils.debug.warningEnabled()) {
            SAMLUtils.debug.warning("AMC:createAssertion(SSO)", 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) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 12 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 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, String destID) throws SAMLException {
    if (useLocal) {
        return (assertionManager.getAssertion(idRef, destID));
    }
    String assertion = null;
    try {
        // rpc could not handle destID is null or empty string case
        if (destID == null || destID.length() == 0) {
            destID = " ";
        }
        Object[] args = { idRef.getAssertionIDReference(), Base64.encode(SAMLUtils.stringToByteArray(destID)) };
        assertion = (String) stub.send("getAssertionByIdRef2", 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 13 with Assertion

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

the class AssertionManagerClient method createAssertion.

/**
     * Returns an assertion that contains an authentication and attribute
     * statement.
     * @param token User session that contains authentication
     *        information which is needed to create the authentication
     *        statement for the assertion.
     * @param attributes A list of attribute objects which are used to create
     *        the attribute statement.
     * @return The created assertion.
     * @throws SAMLException If the Assertion cannot be created.
     */
public Assertion createAssertion(Object token, List attributes) throws SAMLException {
    if (useLocal) {
        return (assertionManager.createAssertion(token, attributes));
    }
    // Check for null or empty attributes
    if (attributes == null || attributes.isEmpty())
        return (createAssertion(token));
    String assertion = null;
    try {
        List attrs = new LinkedList();
        for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
            Attribute attribute = (Attribute) iter.next();
            attrs.add(attribute.toString(true, true));
        }
        SessionProvider sessionProvider = SessionManager.getProvider();
        Object[] args = { sessionProvider.getSessionID(token), attrs };
        assertion = (String) stub.send("createAssertion2", args, null, null);
        return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
    } catch (Exception re) {
        if (SAMLUtils.debug.warningEnabled()) {
            SAMLUtils.debug.warning("AMC:createAssertion(SSO, attrs)", re);
        }
        throw (new SAMLException(re.getMessage()));
    }
}
Also used : Attribute(com.sun.identity.saml.assertion.Attribute) 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) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 14 with Assertion

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

the class AssertionManagerImpl method getAssertionByIdRef.

public String getAssertionByIdRef(String idref, 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 AssertionIDReference(idref), destSet);
    return (a.toString(true, true));
}
Also used : Assertion(com.sun.identity.saml.assertion.Assertion) AssertionIDReference(com.sun.identity.saml.assertion.AssertionIDReference)

Example 15 with Assertion

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

the class FSAssertionManager method setErrStatus.

/**
     * Store the status of a given artifact (original error)
     * @param aa reference artifact
     * @param s stored status
     */
public void setErrStatus(AssertionArtifact aa, Status s) {
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("setErrStatus( " + aa + ", " + s + " )");
    }
    String artString = aa.getAssertionArtifact();
    Assertion assertion = new ErrorAssertion(new java.util.Date(), s);
    Entry e = new Entry(assertion, null, artString, null);
    Object oldEntry = null;
    synchronized (idEntryMap) {
        oldEntry = idEntryMap.put(artString, e);
    }
    if (oldEntry != null) {
        assertionTimeoutRunnable.removeElement(artString);
        if ((agent != null) && agent.isRunning() && (idffSvc != null)) {
            idffSvc.setAssertions((long) idEntryMap.size());
        }
    }
    assertionTimeoutRunnable.addElement(artString);
}
Also used : Date(java.util.Date) Assertion(com.sun.identity.saml.assertion.Assertion) FSAssertion(com.sun.identity.federation.message.FSAssertion)

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