Source:
protected boolean executeAnonymousLogin( ServletRequest request, ServletResponse response ) { getLogger().debug( "Attempting to authenticate Subject as Anonymous request..." ); boolean anonymousLoginSuccessful = false; Subject subject = getSubject( request, response ); UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken( getNexusConfiguration().getAnonymousUsername(), getNexusConfiguration().getAnonymousPassword() ); try { request.setAttribute( ANONYMOUS_LOGIN, Boolean.TRUE ); subject.login( usernamePasswordToken ); } catch( UnknownSessionException e ) { Session anonSession = subject.getSession( false ); this.getLogger().warn( "UnknownSessionException was thrown for with session: '{}'", anonSession, e ); if( anonSession != null ) { this.getLogger().debug( "Logging out the current anonymous user, to clear the session." ); try { subject.logout(); } catch( UnknownSessionException expectedException ) { this.logger.trace( "Forced a logout with an Unknown Session so the current subject would get cleaned up.", e ); } this.getLogger().debug( "Attempting to login as anonymous for the second time." ); subject.login( usernamePasswordToken ); anonymousLoginSuccessful = true; } } catch ( AuthenticationException ae ) { getLogger().info( "Unable to authenticate user [anonymous] from IP Address " + RemoteIPFinder.findIP( (HttpServletRequest) request ) ); getLogger().debug( "Unable to log in subject as anonymous", ae ); } if( anonymousLoginSuccessful ) { getLogger().debug( "Successfully logged in as anonymous" ); postAuthcEvent( request, getNexusConfiguration().getAnonymousUsername(), getUserAgent( request ), true ); return true; } return false; }

Target:
protected boolean executeAnonymousLogin( ServletRequest request, ServletResponse response ) { getLogger().debug( "Attempting to authenticate Subject as Anonymous request..." ); boolean anonymousLoginSuccessful = false; Subject subject = getSubject( request, response ); UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken( getNexusConfiguration().getAnonymousUsername(), getNexusConfiguration().getAnonymousPassword() ); try { request.setAttribute( ANONYMOUS_LOGIN, Boolean.TRUE ); subject.login( usernamePasswordToken ); anonymousLoginSuccessful = true; } catch( UnknownSessionException e ) { Session anonSession = subject.getSession( false ); this.getLogger().debug( "Unknown session exception while logging in anonymous user: '{}'", anonSession, e ); if( anonSession != null ) { this.getLogger().debug( "Logging out the current anonymous user, to clear the session." ); try { subject.logout(); } catch( UnknownSessionException expectedException ) { this.logger.trace( "Forced a logout with an Unknown Session so the current subject would get cleaned up.", e ); } this.getLogger().debug( "Attempting to login as anonymous for the second time." ); subject.login( usernamePasswordToken ); anonymousLoginSuccessful = true; } } catch ( AuthenticationException ae ) { getLogger().info( "Unable to authenticate user [anonymous] from IP Address " + RemoteIPFinder.findIP( (HttpServletRequest) request ) ); getLogger().debug( "Unable to log in subject as anonymous", ae ); } if( anonymousLoginSuccessful ) { getLogger().debug( "Successfully logged in as anonymous" ); postAuthcEvent( request, getNexusConfiguration().getAnonymousUsername(), getUserAgent( request ), true ); return true; } return false; }