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;
}
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;
}
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());
}
}
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());
}
}
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;
}
}
Aggregations