use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.
the class SAMLUtils method getListOfAssertions.
/**
* Gets the list of <code>Assertion</code> objects from a list of
* 'String' assertions.
* @param assertions List of assertions in string format
* @return List of <code>Assertion</code> objects
*/
public static List getListOfAssertions(List assertions) {
List returnAssertions = new ArrayList();
try {
if (assertions != null) {
Iterator it = assertions.iterator();
while (it.hasNext()) {
Document doc = XMLUtils.toDOMDocument((String) it.next(), debug);
Element root = doc.getDocumentElement();
if (root != null) {
Assertion assertion = new Assertion(root);
returnAssertions.add(assertion);
}
}
}
} catch (Exception e) {
if (debug.messageEnabled()) {
debug.message("SAMLUtils.getListOfAssertions : " + "Exception : ", e);
}
}
return returnAssertions;
}
use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.
the class SAMLUtils method examAssertions.
/**
* Determines if there is a valid SSO Assertion
* inside of SAML Response.
*
* @param assertions a List of <code>Assertion</code> objects
* @return a Subject object
* @exception IOException IOException
*/
public static com.sun.identity.saml.assertion.Subject examAssertions(List assertions) throws IOException {
if (assertions == null) {
return null;
}
boolean validation = false;
com.sun.identity.saml.assertion.Subject subject = null;
Iterator iter = assertions.iterator();
while (iter.hasNext()) {
Assertion assertion = (Assertion) iter.next();
if (!checkCondition(assertion)) {
return null;
}
debug.message("Passed checking Conditions!");
// exam the Statement inside the Assertion
Set statements = new HashSet();
statements = assertion.getStatement();
if (statements == null || statements.isEmpty()) {
debug.error(bundle.getString("noStatement"));
return null;
}
Iterator iterator = statements.iterator();
while (iterator.hasNext()) {
Statement statement = (Statement) iterator.next();
subject = ((SubjectStatement) statement).getSubject();
SubjectConfirmation sc = subject.getSubjectConfirmation();
Set cm = new HashSet();
cm = sc.getConfirmationMethod();
if (cm == null || cm.isEmpty()) {
debug.error("Subject confirmation method is null");
return null;
}
String conMethod = (String) cm.iterator().next();
// on Assertion version number
if ((conMethod != null) && (assertion.getMajorVersion() == SAMLConstants.ASSERTION_MAJOR_VERSION) && (((assertion.getMinorVersion() == SAMLConstants.ASSERTION_MINOR_VERSION_ONE) && conMethod.equals(SAMLConstants.CONFIRMATION_METHOD_ARTIFACT)) || ((assertion.getMinorVersion() == SAMLConstants.ASSERTION_MINOR_VERSION_ZERO) && (conMethod.equals(SAMLConstants.DEPRECATED_CONFIRMATION_METHOD_ARTIFACT))))) {
if (debug.messageEnabled()) {
debug.message("Correct Confirmation method");
}
} else {
debug.error("Wrong Confirmation Method.");
return null;
}
if (statement instanceof AuthenticationStatement) {
//found an SSO Assertion
validation = true;
}
}
// end of while (iterator.hasNext()) for Statements
}
if (!validation) {
debug.error(bundle.getString("noSSOAssertion"));
return null;
}
return subject;
}
use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.
the class AssertionManagerImpl method createAssertion.
public String createAssertion(String ssoToken) 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) " + ssoe);
}
throw (new SAMLException(ssoe.getMessage()));
}
Assertion a = assertionManager.createAssertion(token);
// would be thrown
return (a.toString(true, true));
}
use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.
the class AssertionManagerImpl method getAssertionByIdRefToken.
public String getAssertionByIdRefToken(String idref, String ssoToken) 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:getAssertionByIdRefToken: " + ssoe);
}
throw (new SAMLException(ssoe.getMessage()));
}
Assertion a = assertionManager.getAssertion(new AssertionIDReference(idref), token);
return (a.toString(true, true));
}
use of com.sun.identity.saml.assertion.Assertion in project OpenAM by OpenRock.
the class AssertionManagerImpl method getAssertionByIdRef2.
public String getAssertionByIdRef2(String idref, String destID) throws SAMLException {
checkInitialization();
Assertion a = assertionManager.getAssertion(new AssertionIDReference(idref), SAMLUtils.byteArrayToString(Base64.decode(destID)));
return (a.toString(true, true));
}
Aggregations