BearerTokenRealm extends AuthenticatingRealm { @Override public boolean supports(final AuthenticationToken token) { return token instanceof NexusApiKeyAuthenticationToken && format.equals(token.getPrincipal()); } BearerTokenRealm(final ApiKeyStore keyStore,
                          final UserPrincipalsHelper principalsHelper,
                          final String format); @Override boolean supports(final AuthenticationToken token); static final String IS_TOKEN_AUTH_KEY; }
@Test public void supportedWhenCorrectTypeAndFormat() throws Exception { assertTrue(underTest.supports(token)); }
@Test public void notSupportedWhenWrongType() throws Exception { assertFalse(underTest.supports(unsupportedToken)); }
@Test public void notSupportedWhenWrongFormat() throws Exception { when(token.getPrincipal()).thenReturn("UnsupportedFormat"); assertFalse(underTest.supports(token)); }