AbstractLoginModule implements LoginModule { @Nullable protected SecurityProvider getSecurityProvider() { if (securityProvider == null && callbackHandler != null) { RepositoryCallback rcb = new RepositoryCallback(); try { callbackHandler.handle(new Callback[]{rcb}); securityProvider = rcb.getSecurityProvider(); } catch (IOException | UnsupportedCallbackException e) { onError(); log.error(e.getMessage(), e); } } return securityProvider; }  @Override void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options); @Override boolean logout(); @Override boolean abort(); static final String SHARED_KEY_CREDENTIALS; static final String SHARED_KEY_LOGIN_NAME; static final String SHARED_KEY_ATTRIBUTES; static final String SHARED_KEY_PRE_AUTH_LOGIN; }
@Test public void testGetSecurityProvider() { AbstractLoginModule loginModule = initLoginModule(new TestCallbackHandler(null, new OpenSecurityProvider())); SecurityProvider securityProvider = loginModule.getSecurityProvider(); assertNotNull(securityProvider); assertSame(securityProvider, loginModule.getSecurityProvider()); }
@Test public void testGetSecurityProviderIOException() { AbstractLoginModule loginModule = initLoginModule(new ThrowingCallbackHandler(true)); assertNull(loginModule.getSecurityProvider()); }
@Test public void testGetSecurityProviderMissingCallbackHandler() { AbstractLoginModule loginModule = initLoginModule((CallbackHandler) null); assertNull(loginModule.getSecurityProvider()); }