@Test public void nullOnAuthException() throws Exception { when(apiKeyStore.getApiKey(any(), any())).thenThrow(new AuthenticationException()); assertThat(underTest.login("username", "password"), is(nullValue())); }
public String login(final String username, final String password) { checkNotNull(username); checkNotNull(password); try { AuthenticationInfo authenticationInfo = securityHelper.getSecurityManager().authenticate( new UsernamePasswordToken(username, password)); return super.createToken(authenticationInfo.getPrincipals()); } catch (AuthenticationException e) { log.debug("Bad credentials provided for npm token creation", e); return null; } }
NpmTokenManager extends BearerTokenManager { public String login(final String username, final String password) { checkNotNull(username); checkNotNull(password); try { AuthenticationInfo authenticationInfo = securityHelper.getSecurityManager().authenticate( new UsernamePasswordToken(username, password)); return super.createToken(authenticationInfo.getPrincipals()); } catch (AuthenticationException e) { log.debug("Bad credentials provided for npm token creation", e); return null; } } }
NpmTokenManager extends BearerTokenManager { public String login(final String username, final String password) { checkNotNull(username); checkNotNull(password); try { AuthenticationInfo authenticationInfo = securityHelper.getSecurityManager().authenticate( new UsernamePasswordToken(username, password)); return super.createToken(authenticationInfo.getPrincipals()); } catch (AuthenticationException e) { log.debug("Bad credentials provided for npm token creation", e); return null; } } @Inject  NpmTokenManager(final ApiKeyStore apiKeyStore, final SecurityHelper securityHelper); }
NpmTokenManager extends BearerTokenManager { public String login(final String username, final String password) { checkNotNull(username); checkNotNull(password); try { AuthenticationInfo authenticationInfo = securityHelper.getSecurityManager().authenticate( new UsernamePasswordToken(username, password)); return super.createToken(authenticationInfo.getPrincipals()); } catch (AuthenticationException e) { log.debug("Bad credentials provided for npm token creation", e); return null; } } @Inject  NpmTokenManager(final ApiKeyStore apiKeyStore, final SecurityHelper securityHelper); String login(final String username, final String password); boolean logout(); }
NpmTokenManager extends BearerTokenManager { public String login(final String username, final String password) { checkNotNull(username); checkNotNull(password); try { AuthenticationInfo authenticationInfo = securityHelper.getSecurityManager().authenticate( new UsernamePasswordToken(username, password)); return super.createToken(authenticationInfo.getPrincipals()); } catch (AuthenticationException e) { log.debug("Bad credentials provided for npm token creation", e); return null; } } @Inject  NpmTokenManager(final ApiKeyStore apiKeyStore, final SecurityHelper securityHelper); String login(final String username, final String password); boolean logout();  }