List of usage examples for org.apache.shiro.authc AuthenticationToken AuthenticationToken
AuthenticationToken
From source file:org.codice.ddf.security.guest.realm.GuestRealmTest.java
License:Open Source License
@Test public void testSupportsNotBase() { AuthenticationToken authenticationToken = new AuthenticationToken() { @Override//from w w w .j a v a 2 s.c o m public Object getPrincipal() { return "principal"; } @Override public Object getCredentials() { return "credentials"; } }; boolean supports = guestRealm.supports(authenticationToken); assertFalse(supports); }
From source file:org.graylog2.radio.security.RadioSecurityContextFactory.java
License:Open Source License
@Override public SecurityContext create(String userName, String credential, boolean isSecure, String authcScheme, String host) {//w ww. j a v a2 s.c o m final Subject subject = new RadioSubject(); final AuthenticationToken authenticationToken = new AuthenticationToken() { @Override public Object getPrincipal() { return new RadioPrinipal(); } @Override public Object getCredentials() { return null; } }; return new RadioSecurityContext(subject, authenticationToken); }
From source file:org.killbill.billing.util.security.api.DefaultSecurityApi.java
License:Apache License
@Override public synchronized void login(final Object principal, final Object credentials) { final Subject currentUser = SecurityUtils.getSubject(); if (currentUser.isAuthenticated()) { logout();/* ww w. j a v a 2s .c o m*/ } // Workaround for https://issues.apache.org/jira/browse/SHIRO-510 // TODO Not sure if it's a good fix? if (principal.equals(currentUser.getPrincipal()) && currentUser.isAuthenticated()) { return; } // UsernamePasswordToken is hardcoded in AuthenticatingRealm if (principal instanceof String && credentials instanceof String) { currentUser.login(new UsernamePasswordToken((String) principal, (String) credentials)); } else if (principal instanceof String && credentials instanceof char[]) { currentUser.login(new UsernamePasswordToken((String) principal, (char[]) credentials)); } else { currentUser.login(new AuthenticationToken() { @Override public Object getPrincipal() { return principal; } @Override public Object getCredentials() { return credentials; } }); } }
From source file:org.opendaylight.aaa.shiro.realm.KeystoneAuthRealmTest.java
License:Open Source License
@Test(expected = AuthenticationException.class) public void doGetAuthenticationInfoUnknownTokenType() throws Exception { AuthenticationToken token = new AuthenticationToken() { @Override//from w w w . j ava 2 s. co m public Object getPrincipal() { return null; } @Override public Object getCredentials() { return null; } }; keystoneAuthRealm.doGetAuthenticationInfo(token, client); }
From source file:org.openengsb.framework.vfs.webdavprotocol.resourcetypes.AbstractResource.java
License:Apache License
@Override public Object authenticate(final String user, final String requestedPassword) { AuthenticationToken token = new AuthenticationToken() { @Override/*from w w w. ja va 2 s . c o m*/ public Object getPrincipal() { return user; } @Override public Object getCredentials() { return new Password(requestedPassword); } }; if (authenticator == null) { authenticator = webDavHandler.getAuthenticationDomainService(); if (authenticator == null) { log.error("Authenticator is still null, not able to get it from webDavHandler"); return null; } } Authentication authenticate = null; try { if (!authenticator.supports((Credentials) token.getCredentials())) { return null; } authenticate = authenticator.authenticate(token.getPrincipal().toString(), (Credentials) token.getCredentials()); } catch (AuthenticationException ex) { log.debug("Login Error: " + ex.getMessage()); } if (authenticate == null) { return null; } return authenticate.getUsername(); }