String responseDestinationURI = sp.getResponseDestinationURI();
XMLGregorianCalendar issueInstant = XMLTimeUtil.getIssueInstant();
//Create an assertion
AssertionType assertionType = JBossSAMLBaseFactory.createAssertion();
assertionType.setID("ID_" + JBossSAMLBaseFactory.createUUID());
assertionType.setVersion(issuerInfo.getSamlVersion());
assertionType.setIssueInstant(issueInstant);
assertionType.setIssuer(issuerInfo.getIssuer());
//Create assertion -> subject
SubjectType subjectType = JBossSAMLBaseFactory.createSubject();
//subject -> nameid
NameIDType nameIDType = JBossSAMLBaseFactory.createNameID();
nameIDType.setFormat(idp.getNameIDFormat());
nameIDType.setValue(idp.getNameIDFormatValue());
JAXBElement<NameIDType> jaxbNameIDType = JBossSAMLBaseFactory.createNameID(nameIDType);
subjectType.getContent().add(jaxbNameIDType);
SubjectConfirmationType subjectConfirmation =
JBossSAMLBaseFactory.createSubjectConfirmation(idp.getSubjectConfirmationMethod());
SubjectConfirmationDataType subjectConfirmationData =
JBossSAMLBaseFactory.createSubjectConfirmationData(sp.getRequestID(),
responseDestinationURI, issueInstant);
subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
JAXBElement<SubjectConfirmationType> jaxbSubjectConfirmationType =
JBossSAMLBaseFactory.createSubjectConfirmation(subjectConfirmation);
subjectType.getContent().add(jaxbSubjectConfirmationType);
assertionType.setSubject(subjectType);
ResponseType responseType = createResponseType(ID, issuerInfo, assertionType);
//InResponseTo ID
responseType.setInResponseTo(sp.getRequestID());
//Destination