List of usage examples for org.springframework.security.authentication UsernamePasswordAuthenticationToken getCredentials
public Object getCredentials()
From source file:com.telefonica.euro_iaas.paasmanager.rest.auth.OpenStackAuthenticationProvider.java
/** * Add PaasManagerUser to claudiaData.// w ww . j a va 2 s . co m * * @param claudiaData */ public static void addCredentialsToClaudiaData(ClaudiaData claudiaData) { PaasManagerUser paasManagerUser = new PaasManagerUser("unknown", "unknown"); if (SecurityContextHolder.getContext().getAuthentication() != null) { UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = (UsernamePasswordAuthenticationToken) SecurityContextHolder .getContext().getAuthentication(); if (usernamePasswordAuthenticationToken != null) { paasManagerUser.setToken(usernamePasswordAuthenticationToken.getPrincipal().toString()); paasManagerUser.setTenantId(usernamePasswordAuthenticationToken.getCredentials().toString()); } } claudiaData.setUser(paasManagerUser); }
From source file:org.xaloon.wicket.security.spring.XaloonDaoAuthenticationProvider.java
@Override protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (authentication.getCredentials() == null) { throw new BadCredentialsException(messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); }// ww w . j av a 2 s .c om if (authentication.getCredentials() instanceof String) { String encoded = PasswordEncoder.get().encode(authentication.getName(), authentication.getCredentials().toString()); if (!userDetails.getPassword().equals(encoded)) { throw new BadCredentialsException(messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } } }
From source file:shiver.me.timbers.spring.security.UsernamePasswordStormpathAuthenticationRequestFactory.java
@Override public AuthenticationRequest create(String username, UsernamePasswordAuthenticationToken authentication) { return builderFactory.builder().setUsernameOrEmail(username) .setPassword(authentication.getCredentials().toString()) .withResponseOptions(builderFactory.options().withAccount()).build(); }
From source file:miage.ecom.web.security.UserAuthenticationProvider.java
@Override protected void additionalAuthenticationChecks(UserDetails ud, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (authentication.getCredentials() == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), null); }//from w w w.j a v a 2 s. com String presentedPassword = authentication.getCredentials().toString(); if (customerFacade.authenticate(ud.getUsername(), presentedPassword) == null) { logger.debug("Authentication failed: password does not match stored value"); throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), null); } }
From source file:py.una.pol.karaku.services.server.KarakuWSAuthenticationProvider.java
@Override protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) { if (userService.checkAuthenthicationByUID(username, authentication.getCredentials().toString())) { KarakuUser user = new KarakuUser(); user.setUserName(username);/*from www.j av a2s .com*/ return user; } throw new UsernameNotFoundException(username); }
From source file:miage.ecom.web.security.AdminAuthenticationProvider.java
@Override protected void additionalAuthenticationChecks(UserDetails ud, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (authentication.getCredentials() == null) { logger.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), null); }//from w w w. j av a2s .c o m String presentedPassword = authentication.getCredentials().toString(); if (adminFacade.authenticate(ud.getUsername(), presentedPassword) == null) { logger.debug("Authentication failed: password does not match stored value"); throw new BadCredentialsException(messages.getMessage( "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"), null); } }
From source file:io.gravitee.management.idp.memory.authentication.InMemoryAuthentificationProvider.java
@Override protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (authentication.getCredentials() == null) { LOGGER.debug("Authentication failed: no credentials provided"); throw new BadCredentialsException(messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); }/* ww w .java 2 s .c o m*/ String presentedPassword = authentication.getCredentials().toString(); if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) { LOGGER.debug("Authentication failed: password does not match stored value"); throw new BadCredentialsException(messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } }
From source file:architecture.user.security.spring.authentication.ExtendedAuthenticationProvider.java
@Override protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { if (authentication.getCredentials() == null) throw new BadCredentialsException(messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); // ?? ./*from ww w . java 2s .c om*/ super.additionalAuthenticationChecks(userDetails, authentication); ExtendedUserDetails user; try { user = (ExtendedUserDetails) userDetails; } catch (Exception e) { log.error("Unable to coerce user detail to ExtendedUserDetails."); throw new BadCredentialsException(messages .getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); } State state = ApplicationHelper.getState(); log.debug(state); try { if (user.getUser() != null) { UserTemplate template = new UserTemplate(user.getUser()); template.setLastLoggedIn(new Date()); userManager.updateUser(template); } } catch (Exception e) { log.warn(L10NUtils.format("005016", user), e); } }
From source file:com.example.CloudFoundryAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { UsernamePasswordAuthenticationToken user = (UsernamePasswordAuthenticationToken) authentication; String username = user.getName(); String password = user.getCredentials().toString(); CloudCredentials credentials = new CloudCredentials(username, password); CloudFoundryClient client = new CloudFoundryClient(credentials, properties.getApi()); OAuth2AccessToken login = client.login(); CloudFoundryAuthentication result = new CloudFoundryAuthentication(username, login); return result; }
From source file:org.brekka.pegasus.core.security.UnlockAuthenticationProvider.java
@Override protected UserDetails retrieveUser(final String token, final UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { Object credentials = authentication.getCredentials(); String password = credentials.toString(); if (StringUtils.isBlank(password)) { throw new BadCredentialsException("A code is required"); }/*from w w w. java 2 s . c o m*/ AnonymousTransferUser anonymousTransferUser = new AnonymousTransferUser(token); SecurityContext context = SecurityContextHolder.getContext(); // Temporarily bind the authentication user to the security context so that we can do the unlock // this is primarily for the EventService to capture the IP/remote user. UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(anonymousTransferUser, anonymousTransferUser); auth.setDetails(authentication.getDetails()); try { context.setAuthentication(auth); anonymousService.unlock(token, password, true); context.setAuthentication(null); return anonymousTransferUser; } catch (PhalanxException e) { if (e.getErrorCode() == PhalanxErrorCode.CP302) { throw new BadCredentialsException("Code appears to be incorrect"); } throw e; } }