public void prepareSuccessfulResponse ( final Response response , final Service service , final Authentication authentication , final Principal principal , final Map < String , List < Object > > authnAttributes , final Map < String , List < Object > > principalAttributes ) { val issuedAt = DateTimeUtils . zonedDateTimeOf ( response . getIssueInstant ( ) ) ; LOGGER . debug ( "Preparing SAML response for service [{}]" , service ) ; final Collection < Object > authnMethods = CollectionUtils . toCollection ( authentication . getAttributes ( ) . get ( SamlAuthenticationMetaDataPopulator . ATTRIBUTE_AUTHENTICATION_METHOD ) ) ; LOGGER . debug ( "Authentication methods found are [{}]" , authnMethods ) ; val authnStatement = this . samlObjectBuilder . newAuthenticationStatement ( authentication . getAuthenticationDate ( ) , authnMethods , principal . getId ( ) ) ; LOGGER . debug ( "Built authentication statement for [{}] dated at [{}]" , principal , authentication . getAuthenticationDate ( ) ) ; val assertion = this . samlObjectBuilder . newAssertion ( authnStatement , this . issuer , issuedAt , this . samlObjectBuilder . generateSecureRandomId ( ) ) ; LOGGER . debug ( "Built assertion for issuer [{}] dated at [{}]" , this . issuer , issuedAt ) ; val conditions = this . samlObjectBuilder . newConditions ( issuedAt , service . getId ( ) , this . issueLength ) ; assertion . setConditions ( conditions ) ; LOGGER . debug ( "Built assertion conditions for issuer [{}] and service [{}] " , this . issuer , service . getId ( ) ) ; val subject = this . samlObjectBuilder . newSubject ( principal . getId ( ) ) ; LOGGER . debug ( "Built subject for principal [{}]" , principal ) ; val attributesToSend = prepareSamlAttributes ( service , authnAttributes , principalAttributes ) ; LOGGER . debug ( "Authentication statement shall include these attributes [{}]" , attributesToSend ) ; if ( ! attributesToSend . isEmpty ( ) ) { assertion . getAttributeStatements ( ) . add ( this . samlObjectBuilder . newAttributeStatement ( subject , attributesToSend , this . defaultAttributeNamespace ) ) ; } response . setStatus ( this . samlObjectBuilder . newStatus ( StatusCode . SUCCESS , null ) ) ; LOGGER . debug ( "Set response status code to [{}]" , response . getStatus ( ) ) ; response . getAssertions ( ) . add ( assertion ) ; }
Prepare successful response .