AbstractLoginModule implements LoginModule { @Nullable protected String getSharedLoginName() { if (sharedState.containsKey(SHARED_KEY_LOGIN_NAME)) { return sharedState.get(SHARED_KEY_LOGIN_NAME).toString(); } else { return null; } }  @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 testGetSharedLoginName() { Map<String, String> sharedState = new HashMap<>(); sharedState.put(AbstractLoginModule.SHARED_KEY_LOGIN_NAME, "test"); AbstractLoginModule lm = initLoginModule(TestCredentials.class, sharedState); assertEquals("test", lm.getSharedLoginName()); sharedState.clear(); lm = initLoginModule(TestCredentials.class, sharedState); assertNull(lm.getSharedLoginName()); }