AbstractLoginModule implements LoginModule { @Nullable protected Whiteboard getWhiteboard() { if (whiteboard == null && callbackHandler != null) { WhiteboardCallback cb = new WhiteboardCallback(); try { callbackHandler.handle(new Callback[]{cb}); whiteboard = cb.getWhiteboard(); } catch (IOException | UnsupportedCallbackException e) { onError(); log.error(e.getMessage(), e); } } return whiteboard; }  @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 testGetWhiteboardFromCallback() { AbstractLoginModule loginModule = initLoginModule(new TestCallbackHandler(new DefaultWhiteboard())); Whiteboard wb = loginModule.getWhiteboard(); assertNotNull(wb); assertSame(wb, loginModule.getWhiteboard()); }
@Test public void testGetWhiteboardFromIncompleteCallback() { AbstractLoginModule loginModule = initLoginModule(new TestCallbackHandler()); assertNull(loginModule.getWhiteboard()); }
@Test public void testGetWhiteboardIOException() { AbstractLoginModule loginModule = initLoginModule(new ThrowingCallbackHandler(true)); assertNull(loginModule.getWhiteboard()); }
@Test public void testGetWhiteboardUnsupportedCallbackException() { AbstractLoginModule loginModule = initLoginModule(new ThrowingCallbackHandler(false)); assertNull(loginModule.getWhiteboard()); }
@Test public void testGetWhiteBoardMissingCallbackHandler() { AbstractLoginModule loginModule = initLoginModule((CallbackHandler) null); assertNull(loginModule.getWhiteboard()); }