protected Subject createBasicAuthSubject ( AuthenticationData authenticationData , Subject subject ) throws WSLoginFailedException , CredentialException { Subject basicAuthSubject = subject != null ? subject : new Subject ( ) ; String loginRealm = ( String ) authenticationData . get ( AuthenticationData . REALM ) ; String username = ( String ) authenticationData . get ( AuthenticationData . USERNAME ) ; String password = getPassword ( ( char [ ] ) authenticationData . get ( AuthenticationData . PASSWORD ) ) ; if ( username == null || username . isEmpty ( ) || password == null || password . isEmpty ( ) ) { throw new WSLoginFailedException ( TraceNLS . getFormattedMessage ( this . getClass ( ) , TraceConstants . MESSAGE_BUNDLE , "JAAS_LOGIN_MISSING_CREDENTIALS" , new Object [ ] { } , "CWWKS1171E: The login on the client application failed because the user name or password is null. Ensure the CallbackHandler implementation is gathering the necessary credentials." ) ) ; } CredentialsService credentialsService = credentialsServiceRef . getServiceWithException ( ) ; credentialsService . setBasicAuthCredential ( basicAuthSubject , loginRealm , username , password ) ; Principal principal = new WSPrincipal ( username , null , WSPrincipal . AUTH_METHOD_BASIC ) ; basicAuthSubject . getPrincipals ( ) . add ( principal ) ; return basicAuthSubject ; }
Create the basic auth subject using the given authentication data