public static synchronized boolean pushSubject ( String username ) { if ( securityService == null || username == null ) { if ( tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "returning false because user or securityService is null," + " user= " + username + " secsvc= " + securityService ) ; } return false ; } AuthenticationService authenticationService = securityService . getAuthenticationService ( ) ; Subject tempSubject = new Subject ( ) ; Hashtable < String , Object > hashtable = new Hashtable < String , Object > ( ) ; if ( ! authenticationService . isAllowHashTableLoginWithIdOnly ( ) ) { hashtable . put ( AuthenticationConstants . INTERNAL_ASSERTION_KEY , Boolean . TRUE ) ; } hashtable . put ( "com.ibm.wsspi.security.cred.userId" , username ) ; tempSubject . getPublicCredentials ( ) . add ( hashtable ) ; try { Subject new_subject = authenticationService . authenticate ( JaasLoginConfigConstants . SYSTEM_WEB_INBOUND , tempSubject ) ; return setRunAsSubject ( new_subject ) ; } catch ( AuthenticationException e ) { FFDCFilter . processException ( e , TokenPropagationHelper . class . getName ( ) , "pushSubject" , new Object [ ] { username } ) ; Tr . error ( tc , "ERROR_AUTHENTICATE" , new Object [ ] { e . getMessage ( ) } ) ; // CWWKS6103E return false ; } catch ( Exception e ) { FFDCFilter . processException ( e , TokenPropagationHelper . class . getName ( ) , "pushSubject" , new Object [ ] { username } ) ; return false ; } }
Authenticate the username create it s Subject and push it on to the thread . It s up to the caller to save off the prior subject and make sure it gets restored and guard against any threading issues .