protected void verifySadRequest ( SignatureActivationDataContext sadRequest , ProfileRequestContext < ? , ? > context ) throws ExternalAutenticationErrorCodeException { final AuthnRequest authnRequest = this . getAuthnRequest ( context ) ; if ( authnRequest == null ) { log . error ( "No AuthnRequest available [{}]" , this . getLogString ( context ) ) ; throw new ExternalAutenticationErrorCodeException ( AuthnEventIds . INVALID_AUTHN_CTX , "Missing AuthnRequest" ) ; } final SADRequest r = sadRequest . getSadRequest ( ) ; // Verify the version is what we understand ... // if ( r . getRequestedVersion ( ) != null && ! supportedSadVersions . contains ( r . getRequestedVersion ( ) ) ) { final String msg = String . format ( "Requested SAD version (%s) is not supported by the IdP" , r . getRequestedVersion ( ) ) ; log . info ( "{} [{}]" , msg , this . getLogString ( context ) ) ; throw new ExternalAutenticationErrorCodeException ( ExtAuthnEventIds . BAD_SAD_REQUEST , msg ) ; } // Check the RequesterID ... // if ( ! StringUtils . hasText ( r . getRequesterID ( ) ) ) { final String msg = "RequesterID is not present in the SADRequest - invalid" ; log . info ( "{} [{}]" , msg , this . getLogString ( context ) ) ; throw new ExternalAutenticationErrorCodeException ( ExtAuthnEventIds . BAD_SAD_REQUEST , msg ) ; } final String issuer = authnRequest . getIssuer ( ) . getValue ( ) ; if ( ! r . getRequesterID ( ) . equals ( issuer ) ) { final String msg = String . format ( "Invalid RequestID of SADRequest (%s) - Issuer of AuthnRequest is '%s'" , r . getRequesterID ( ) , issuer ) ; log . info ( "{} [{}]" , msg , this . getLogString ( context ) ) ; throw new ExternalAutenticationErrorCodeException ( ExtAuthnEventIds . BAD_SAD_REQUEST , msg ) ; } // Verify that the SignRequestID is there ... // if ( ! StringUtils . hasText ( r . getSignRequestID ( ) ) ) { final String msg = "SignRequestID is not present in the SADRequest - invalid" ; log . info ( "{} [{}]" , msg , this . getLogString ( context ) ) ; throw new ExternalAutenticationErrorCodeException ( ExtAuthnEventIds . BAD_SAD_REQUEST , msg ) ; } // Assert that we have a DocCount element ... // if ( r . getDocCount ( ) == null ) { final String msg = "DocCount is not present in the SADRequest - invalid" ; log . info ( "{} [{}]" , msg , this . getLogString ( context ) ) ; throw new ExternalAutenticationErrorCodeException ( ExtAuthnEventIds . BAD_SAD_REQUEST , msg ) ; } // Assert that we have an ID for the SADRequest ... // if ( ! StringUtils . hasText ( r . getID ( ) ) ) { final String msg = "ID attribute is not present in the SADRequest - invalid" ; log . info ( "{} [{}]" , msg , this . getLogString ( context ) ) ; throw new ExternalAutenticationErrorCodeException ( ExtAuthnEventIds . BAD_SAD_REQUEST , msg ) ; } }
Verifies a received SAD request .