@Test public void testNewSubjectWithoutThreadSecurityManager() { SecurityUtils.setSecurityManager(null); try { SecurityUtils.getSecurityManager(); } catch (UnavailableSecurityManagerException e) { assertTrue(e.getMessage().startsWith("No SecurityManager accessible")); } DelegatingSubject subject = (DelegatingSubject)(new Subject.Builder(sm)).buildSubject(); AuthenticationToken token = new UsernamePasswordToken("guest", "guest"); subject.login(token); assertEquals(sm, subject.getSecurityManager()); }
public Subject login(Subject subject, AuthenticationToken token) throws AuthenticationException { AuthenticationInfo info; try { info = authenticate(token); } catch (AuthenticationException ae) { try { onFailedLogin(token, ae, subject); } catch (Exception e) { if (log.isInfoEnabled()) { log.info("onFailedLogin method threw an " + "exception. Logging and propagating original AuthenticationException.", e); } } throw ae; } Subject loggedIn = createSubject(token, info, subject); onSuccessfulLogin(token, info, loggedIn); return loggedIn; }
DefaultSecurityManager extends SessionsSecurityManager { public Subject login(Subject subject, AuthenticationToken token) throws AuthenticationException { AuthenticationInfo info; try { info = authenticate(token); } catch (AuthenticationException ae) { try { onFailedLogin(token, ae, subject); } catch (Exception e) { if (log.isInfoEnabled()) { log.info("onFailedLogin method threw an " + "exception. Logging and propagating original AuthenticationException.", e); } } throw ae; } Subject loggedIn = createSubject(token, info, subject); onSuccessfulLogin(token, info, loggedIn); return loggedIn; } }
DefaultSecurityManager extends SessionsSecurityManager { public Subject login(Subject subject, AuthenticationToken token) throws AuthenticationException { AuthenticationInfo info; try { info = authenticate(token); } catch (AuthenticationException ae) { try { onFailedLogin(token, ae, subject); } catch (Exception e) { if (log.isInfoEnabled()) { log.info("onFailedLogin method threw an " + "exception. Logging and propagating original AuthenticationException.", e); } } throw ae; } Subject loggedIn = createSubject(token, info, subject); onSuccessfulLogin(token, info, loggedIn); return loggedIn; } DefaultSecurityManager();  DefaultSecurityManager(Realm singleRealm);  DefaultSecurityManager(Collection<Realm> realms); }
DefaultSecurityManager extends SessionsSecurityManager { public Subject login(Subject subject, AuthenticationToken token) throws AuthenticationException { AuthenticationInfo info; try { info = authenticate(token); } catch (AuthenticationException ae) { try { onFailedLogin(token, ae, subject); } catch (Exception e) { if (log.isInfoEnabled()) { log.info("onFailedLogin method threw an " + "exception. Logging and propagating original AuthenticationException.", e); } } throw ae; } Subject loggedIn = createSubject(token, info, subject); onSuccessfulLogin(token, info, loggedIn); return loggedIn; } DefaultSecurityManager();  DefaultSecurityManager(Realm singleRealm);  DefaultSecurityManager(Collection<Realm> realms); SubjectFactory getSubjectFactory(); void setSubjectFactory(SubjectFactory subjectFactory); SubjectDAO getSubjectDAO(); void setSubjectDAO(SubjectDAO subjectDAO); RememberMeManager getRememberMeManager(); void setRememberMeManager(RememberMeManager rememberMeManager); Subject login(Subject subject, AuthenticationToken token); Subject createSubject(SubjectContext subjectContext); void logout(Subject subject); }
DefaultSecurityManager extends SessionsSecurityManager { public Subject login(Subject subject, AuthenticationToken token) throws AuthenticationException { AuthenticationInfo info; try { info = authenticate(token); } catch (AuthenticationException ae) { try { onFailedLogin(token, ae, subject); } catch (Exception e) { if (log.isInfoEnabled()) { log.info("onFailedLogin method threw an " + "exception. Logging and propagating original AuthenticationException.", e); } } throw ae; } Subject loggedIn = createSubject(token, info, subject); onSuccessfulLogin(token, info, loggedIn); return loggedIn; } DefaultSecurityManager();  DefaultSecurityManager(Realm singleRealm);  DefaultSecurityManager(Collection<Realm> realms); SubjectFactory getSubjectFactory(); void setSubjectFactory(SubjectFactory subjectFactory); SubjectDAO getSubjectDAO(); void setSubjectDAO(SubjectDAO subjectDAO); RememberMeManager getRememberMeManager(); void setRememberMeManager(RememberMeManager rememberMeManager); Subject login(Subject subject, AuthenticationToken token); Subject createSubject(SubjectContext subjectContext); void logout(Subject subject);  }