@Override public boolean doAuthenticate(Context context) { return getLoginPasswordAuthenticator().authenticate(context.getUsername(), context.getPassword()); } };
@Override public void init() { authenticator.init(); }
@Test public void getLoginPasswordAuthenticator_deprecated_method_replaced_by_getAuthenticator() { final LoginPasswordAuthenticator deprecatedAuthenticator = mock(LoginPasswordAuthenticator.class); SecurityRealm realm = new SecurityRealm() { @Override public LoginPasswordAuthenticator getLoginPasswordAuthenticator() { return deprecatedAuthenticator; } }; Authenticator proxy = realm.doGetAuthenticator(); Authenticator.Context context = new Authenticator.Context("foo", "bar", mock(HttpServletRequest.class)); proxy.doAuthenticate(context); verify(deprecatedAuthenticator).authenticate("foo", "bar"); } }
@Test public void shouldDelegate() { LoginPasswordAuthenticator authenticator = mock(LoginPasswordAuthenticator.class); CompatibilityRealm realm = new CompatibilityRealm(authenticator); realm.init(); verify(authenticator).init(); assertThat(realm.getLoginPasswordAuthenticator()).isSameAs(authenticator); assertThat(realm.getName()).isEqualTo("CompatibilityRealm[" + authenticator.getClass().getName() + "]"); }
@Override public boolean doAuthenticate(Context context) { return getLoginPasswordAuthenticator().authenticate(context.getUsername(), context.getPassword()); } };
@Override public void init() { authenticator.init(); }
@Override public boolean doAuthenticate(Context context) { return getLoginPasswordAuthenticator().authenticate(context.getUsername(), context.getPassword()); } };