Search in sources :

Example 1 with FSAssertionArtifact

use of com.sun.identity.federation.message.FSAssertionArtifact in project OpenAM by OpenRock.

the class FSAssertionManager method createFSAssertionArtifact.

/**
     * Creates an assertion artifact.
     * @param id session ID
     * @param realm the realm in which the provider resides
     * @param spEntityID service provider's entity ID
     * @param spHandle service provider issued <code>NameIdentifier</code>
     * @param idpHandle identity provider issued <code>NameIdentifier</code>
     * @param inResponseTo value to InResponseTo attribute. It's the request ID.
     * @param minorVersion request minor version, used to determine assertion's
     *  minor version
     * @exception FSException,SAMLException if error occurrs
     */
public AssertionArtifact createFSAssertionArtifact(String id, String realm, String spEntityID, NameIdentifier spHandle, NameIdentifier idpHandle, String inResponseTo, int minorVersion) throws FSException, SAMLException {
    // check input
    if ((id == null) || (spEntityID == null)) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionManager: null input for" + " method createFSAssertionArtifact.");
        }
        throw new FSException("nullInput", null);
    }
    // create assertion id and artifact
    String handle = SAMLUtils.generateAssertionHandle();
    if (handle == null) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionManager.createFSAssertionArt" + "ifact: couldn't generate assertion handle.");
        }
        throw new FSException("errorCreateArtifact", null);
    }
    // TODO: should obtain it through meta
    String sourceSuccinctID = FSUtils.generateSourceID(hostEntityId);
    byte[] bytesSourceId = SAMLUtils.stringToByteArray(sourceSuccinctID);
    byte[] bytesHandle = null;
    try {
        bytesHandle = handle.getBytes(IFSConstants.SOURCEID_ENCODING);
    } catch (Exception e) {
        FSUtils.debug.error("FSAssertionManager.createFSAssertionArt: ", e);
        return null;
    }
    AssertionArtifact art = new FSAssertionArtifact(bytesSourceId, bytesHandle);
    int assertionMinorVersion = IFSConstants.FF_11_ASSERTION_MINOR_VERSION;
    if (minorVersion == IFSConstants.FF_12_PROTOCOL_MINOR_VERSION) {
        assertionMinorVersion = IFSConstants.FF_12_ART_ASSERTION_MINOR_VERSION;
    }
    Assertion assertion = createFSAssertion(id, art, realm, spEntityID, spHandle, idpHandle, inResponseTo, assertionMinorVersion);
    return art;
}
Also used : FSException(com.sun.identity.federation.common.FSException) Assertion(com.sun.identity.saml.assertion.Assertion) FSAssertion(com.sun.identity.federation.message.FSAssertion) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) SessionException(com.sun.identity.plugin.session.SessionException) IDFFMetaException(com.sun.identity.federation.meta.IDFFMetaException) ParseException(java.text.ParseException) SAMLException(com.sun.identity.saml.common.SAMLException) FSException(com.sun.identity.federation.common.FSException) UnknownHostException(java.net.UnknownHostException) AssertionArtifact(com.sun.identity.saml.protocol.AssertionArtifact) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact)

Example 2 with FSAssertionArtifact

use of com.sun.identity.federation.message.FSAssertionArtifact in project OpenAM by OpenRock.

the class FSAssertionManagerImpl method getErrorStatus.

public String getErrorStatus(String metaAlias, String artifact) throws FSRemoteException {
    try {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionManagerImpl.getErrStatus(" + metaAlias + ", " + artifact);
        }
        AssertionArtifact aa = new FSAssertionArtifact(artifact);
        Status s = FSAssertionManager.getInstance(metaAlias).getErrorStatus(aa);
        if (null != s)
            return s.toString(true, true);
    } catch (FSMsgException e) {
        FSUtils.debug.error("getErrStatus: FSMsgException:" + e.getMessage());
        throw new FSRemoteException(e.getMessage());
    } catch (FSException e) {
        FSUtils.debug.error("getErrStatus: FSException:" + e.getMessage());
        throw new FSRemoteException(e.getMessage());
    }
    if (FSUtils.debug.messageEnabled()) {
        FSUtils.debug.message("getErrStatus: returning null");
    }
    return null;
}
Also used : Status(com.sun.identity.saml.protocol.Status) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) FSException(com.sun.identity.federation.common.FSException) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) AssertionArtifact(com.sun.identity.saml.protocol.AssertionArtifact) FSRemoteException(com.sun.identity.federation.common.FSRemoteException)

Example 3 with FSAssertionArtifact

use of com.sun.identity.federation.message.FSAssertionArtifact in project OpenAM by OpenRock.

the class FSAssertionManagerImpl method getAssertion.

/**
     * Returns assertion associated with the artifact.
     * @param metaAlias hosted provider's meta alias.
     * @param artifact assertion artifact.
     * @param destID The destination site requesting the assertion using
     *  the artifact.
     * @return The Assertion referenced to by artifact.
     * @exception FSRemoteException, RemoteException If an error occurred during     *  the process
     */
public String getAssertion(String metaAlias, String artifact, String destID) throws FSRemoteException {
    try {
        FSAssertionManager assertionManager = FSAssertionManager.getInstance(metaAlias);
        FSAssertion a = (FSAssertion) assertionManager.getAssertion(new FSAssertionArtifact(artifact), SAMLUtils.byteArrayToString(Base64.decode(destID)));
        if (a == null) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSAssertionManagerImpl: Unable to " + "get assertion from Artifact: " + artifact);
            }
            return (null);
        }
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSAssertionManagerImpl: Assertion got from " + "assertionManager.getAssertion: " + a.toXMLString(true, true));
        }
        return (a.toXMLString(true, true));
    } catch (Exception e) {
        throw new FSRemoteException(e.getMessage());
    }
}
Also used : FSAssertion(com.sun.identity.federation.message.FSAssertion) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) FSException(com.sun.identity.federation.common.FSException) FSRemoteException(com.sun.identity.federation.common.FSRemoteException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) FSRemoteException(com.sun.identity.federation.common.FSRemoteException)

Example 4 with FSAssertionArtifact

use of com.sun.identity.federation.message.FSAssertionArtifact in project OpenAM by OpenRock.

the class FSAssertionManagerImpl method getDestIdForArtifact.

/**
     * Returns the destination id the artifact is created for.
     * @param metaAlias hosted provider's meta alias
     * @param artifact assertion artifact string
     * @return destination id
     * @exception FSRemoteException if error occurred.
     */
public String getDestIdForArtifact(String metaAlias, String artifact) throws FSRemoteException {
    try {
        FSAssertionManager assertionManager = FSAssertionManager.getInstance(metaAlias);
        String destID = assertionManager.getDestIdForArtifact(new FSAssertionArtifact(artifact));
        if (destID == null) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSAssertionManagerImpl: Unable to " + "get destination ID from remote : ");
            }
        }
        return destID;
    } catch (Exception e) {
        throw new FSRemoteException(e.getMessage());
    }
}
Also used : FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) FSException(com.sun.identity.federation.common.FSException) FSRemoteException(com.sun.identity.federation.common.FSRemoteException) FSMsgException(com.sun.identity.federation.message.common.FSMsgException) FSRemoteException(com.sun.identity.federation.common.FSRemoteException)

Example 5 with FSAssertionArtifact

use of com.sun.identity.federation.message.FSAssertionArtifact in project OpenAM by OpenRock.

the class FSSSOBrowserArtifactProfileHandler method createFaultSAMLArtifact.

/**
    * Generates a valid SAML artifact, in response
    * to a single sign on request for a non federated user.
    */
private List createFaultSAMLArtifact() {
    FSUtils.debug.message("FSSSOBrowserArtifactProfileHandler. In createFaultSAMLArtifacts");
    // create assertion id and artifact
    String handle = SAMLUtils.generateAssertionHandle();
    if (handle == null) {
        if (FSUtils.debug.messageEnabled()) {
            FSUtils.debug.message("FSSSOBrowserArtifactProfileHandler." + "create FaultSAMLArtifacts: couldn't generate assertion " + "handle.");
        }
        return null;
    }
    try {
        String sourceSuccinctID = FSUtils.generateSourceID(hostedEntityId);
        AssertionArtifact art = new FSAssertionArtifact(SAMLUtils.stringToByteArray(sourceSuccinctID), handle.getBytes(IFSConstants.SOURCEID_ENCODING));
        List artis = new ArrayList();
        artis.add(art.getAssertionArtifact());
        FSAssertionManager am = FSAssertionManager.getInstance(metaAlias);
        am.setErrStatus(art, noFedStatus);
        return artis;
    } catch (Exception e) {
        FSUtils.debug.error("FSBrowserArtifactProfileHandler.createFaultSAMLArtifacts: ", e);
        return null;
    }
}
Also used : FSAssertionManager(com.sun.identity.federation.services.FSAssertionManager) ArrayList(java.util.ArrayList) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) ArrayList(java.util.ArrayList) List(java.util.List) AssertionArtifact(com.sun.identity.saml.protocol.AssertionArtifact) FSAssertionArtifact(com.sun.identity.federation.message.FSAssertionArtifact) SAMLResponderException(com.sun.identity.saml.common.SAMLResponderException) SessionException(com.sun.identity.plugin.session.SessionException) SAMLException(com.sun.identity.saml.common.SAMLException) FSException(com.sun.identity.federation.common.FSException)

Aggregations

FSException (com.sun.identity.federation.common.FSException)6 FSAssertionArtifact (com.sun.identity.federation.message.FSAssertionArtifact)6 FSMsgException (com.sun.identity.federation.message.common.FSMsgException)4 FSRemoteException (com.sun.identity.federation.common.FSRemoteException)3 SAMLException (com.sun.identity.saml.common.SAMLException)3 AssertionArtifact (com.sun.identity.saml.protocol.AssertionArtifact)3 FSAssertion (com.sun.identity.federation.message.FSAssertion)2 SessionException (com.sun.identity.plugin.session.SessionException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)1 FSRequest (com.sun.identity.federation.message.FSRequest)1 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)1 FSAssertionManager (com.sun.identity.federation.services.FSAssertionManager)1 FSServiceManager (com.sun.identity.federation.services.FSServiceManager)1 SPDescriptorType (com.sun.identity.liberty.ws.meta.jaxb.SPDescriptorType)1 Assertion (com.sun.identity.saml.assertion.Assertion)1 SAMLResponderException (com.sun.identity.saml.common.SAMLResponderException)1 Status (com.sun.identity.saml.protocol.Status)1 IOException (java.io.IOException)1