Package org.springframework.security.authentication

Examples of org.springframework.security.authentication.BadCredentialsException


          user.setPicture("http://www.gravatar.com/avatar?d=mm&size=200");
        }
      }
      String id = user.create();
      if (id == null) {
        throw new BadCredentialsException("Authentication failed: cannot create new user.");
      }
    }

    return user;
  }
View Full Code Here


        }
      }
    }

    if (userAuth == null || user == null || user.getIdentifier() == null) {
      throw new BadCredentialsException("Bad credentials.");
    } else if (!user.isEnabled()) {
      throw new LockedException("Account is locked.");
    }
    return userAuth;
  }
View Full Code Here

            auditManager.audit(Category.authentication, AuthenticationSubCategory.login, Result.failure,
                    "User " + authentication.getPrincipal() + " not authenticated");

            LOG.debug("User {} not authenticated", authentication.getPrincipal());

            throw new BadCredentialsException("User " + authentication.getPrincipal() + " not authenticated");
        }

        return token;
    }
View Full Code Here

      throws AuthenticationException {
   
    if (authentication.getCredentials() == null) {
      logger.debug("Authentication failed: no credentials provided");

      throw new BadCredentialsException(messages.getMessage(
          "AbstractUserDetailsAuthenticationProvider.badCredentials",
          "Bad credentials"));
    }
   
    String presentedPasswd = authentication.getCredentials().toString();
   
    String salt = null;
    if(userDetails instanceof CartUserDetails){
      CartUserDetails cartUserDetails = (CartUserDetails)userDetails;
      salt = cartUserDetails.getSalt();
    }else{
      throw new AuthenticationServiceException("UserDetails cannot be casted to CartUserDetails");
    }
   
    String encPass = Password.encode(salt.toString(), presentedPasswd);
   
    if(!StringUtils.equals(userDetails.getPassword(), encPass)){
      logger.debug("Authentication failed: password does not match stored value");
     
      throw new BadCredentialsException(messages.getMessage(
          "AbstractUserDetailsAuthenticationProvider.badCredentials",
          "Bad credentials"));
    }
  }
View Full Code Here

    InternalAuthenticationToken token = (InternalAuthenticationToken) authentication;
    if (internalTokenStorage.isValidInternalToken(token.getCredentials())) {
      token.setAuthenticated(true);
    } else {
      String message = "Bad credentials";
      throw new BadCredentialsException(message);
    }
    return token;
  }
View Full Code Here

            auditManager.audit(Category.authentication, AuthenticationSubCategory.login, Result.failure,
                    "User " + authentication.getPrincipal() + " not authenticated");

            LOG.debug("User {} not authenticated", authentication.getPrincipal());

            throw new BadCredentialsException("User " + authentication.getPrincipal() + " not authenticated");
        }

        return token;
    }
View Full Code Here

    @Test
    public void testCommence() throws IOException, ServletException {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        AuthenticationException exception = new BadCredentialsException("Bad Credential");

        restAuthenticationEntryPoint.commence(request, response, exception);

        assertEquals(response.getStatus(), MockHttpServletResponse.SC_UNAUTHORIZED);
View Full Code Here

    String username = token.getName();
    String password = (String)token.getCredentials();
    User account = accountRepository.findByEmailAndPassword(username, password);
    if (account == null) {
      logger.info("Invalid login. username={} password={}", username, password);
      throw new BadCredentialsException("Bad credentials");
    }
    return authenticatedToken(account, authentication);
  }
View Full Code Here

        result.setDetails(authenticationDetailsSource.buildDetails(request));
      }
      return result;
    }
    catch (InvalidTokenException e) {
      throw new BadCredentialsException("Could not obtain user details from token", e);
    }

  }
View Full Code Here

          logger.debug("Authentication success: " + authResult.getName());
        }

        Authentication clientAuth = SecurityContextHolder.getContext().getAuthentication();
        if (clientAuth == null) {
          throw new BadCredentialsException(
              "No client authentication found. Remember to put a filter upstream of the TokenEndpointAuthenticationFilter.");
        }
       
        Map<String, String> map = getSingleValueMap(request);
        map.put(OAuth2Utils.CLIENT_ID, clientAuth.getName());
View Full Code Here

TOP

Related Classes of org.springframework.security.authentication.BadCredentialsException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.