String assertionID = (String) session.getAttribute(GeneralConstants.ASSERTION_ID);
if (assertionID != null) {
// Just renew the assertion
AssertionType latestAssertion = (AssertionType) session.getAttribute(GeneralConstants.ASSERTION);
if (latestAssertion != null)
idp.setAssertion(latestAssertion);
}
SPInfoHolder sp = new SPInfoHolder();
sp.setResponseDestinationURI(assertionConsumerURL);
sp.setRequestID(requestID);
sp.setIssuer(art.getIssuer().getValue());
responseType = saml2Response.createResponseType(id, sp, idp, issuerHolder);
// Add information on the roles
AssertionType assertion = responseType.getAssertions().get(0).getAssertion();
// Create an AuthnStatementType
if (handlerConfig.getParameter(DISABLE_AUTHN_STATEMENT) == null) {
String authContextRef = JBossSAMLURIConstants.AC_PASSWORD.get();
if (StringUtil.isNotNull(authMethod))
authContextRef = authMethod;
AuthnStatementType authnStatement = StatementUtil.createAuthnStatement(XMLTimeUtil.getIssueInstant(),
authContextRef);
authnStatement.setSessionIndex(assertion.getID());
assertion.addStatement(authnStatement);
}
if (handlerConfig.getParameter(DISABLE_SENDING_ROLES) == null && (roles != null && !roles.isEmpty())) {
AttributeStatementType attrStatement = null;
if(handlerConfig.getParameter(USE_MULTI_VALUED_ROLES) != null){
attrStatement = StatementUtil.createAttributeStatementForRoles(roles,true);
}else {
attrStatement = StatementUtil.createAttributeStatement(roles);
}
if(attrStatement != null){
assertion.addStatement(attrStatement);
}
}
// Add in the attributes information
if (attribs != null && attribs.size() > 0) {
AttributeStatementType attStatement = StatementUtil.createAttributeStatement(attribs);
assertion.addStatement(attStatement);
}
// Add assertion to the session
session.setAttribute(GeneralConstants.ASSERTION, assertion);