Package org.springframework.security.authentication

Examples of org.springframework.security.authentication.BadCredentialsException


        if (logger.isDebugEnabled()) {
            logger.debug("Processing authentication request for user: " + username);
        }

        if (!StringUtils.hasLength(username)) {
            throw new BadCredentialsException(messages.getMessage("LdapAuthenticationProvider.emptyUsername",
                    "Empty Username"));
        }

        if (!StringUtils.hasLength(password)) {
            throw new BadCredentialsException(messages.getMessage("AbstractLdapAuthenticationProvider.emptyPassword",
                    "Empty Password"));
        }

        Assert.notNull(password, "Null password was supplied in authentication token");
View Full Code Here


                ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, oldPassword);
                // TODO: reconnect doesn't appear to actually change the credentials
                try {
                    ctx.reconnect(null);
                } catch (javax.naming.AuthenticationException e) {
                    throw new BadCredentialsException("Authentication for password change failed.");
                }

                ctx.modifyAttributes(dn, passwordChange);

                return null;
View Full Code Here

    @Test
    public void changePasswordFailsIfReAuthenticationFails() {
        insertJoe();
        authenticateJoe();
        AuthenticationManager am = mock(AuthenticationManager.class);
        when(am.authenticate(any(Authentication.class))).thenThrow(new BadCredentialsException(""));

        manager.setAuthenticationManager(am);

        try {
            manager.changePassword("password", "newPassword");
View Full Code Here

    public void callIsntMadeWhenAuthenticationManagerRejectsAuthentication() throws Exception {
        final TestingAuthenticationToken token = new TestingAuthenticationToken("Test", "Password");
        SecurityContextHolder.getContext().setAuthentication(token);

        mdsReturnsUserRole();
        when(authman.authenticate(token)).thenThrow(new BadCredentialsException("rejected"));

        advisedTarget.makeLowerCase("HELLO");
    }
View Full Code Here

    }

    @Test
    public void testValidateCertificateInvalid() throws Exception {
        expect(authenticationManager.authenticate(isA(X509AuthenticationToken.class)))
                .andThrow(new BadCredentialsException(""));

        replay(authenticationManager);

        callbackHandler.handleInternal(callback);
        boolean authenticated = callback.getResult();
View Full Code Here

        }

        X509Certificate clientCertificate = (X509Certificate) authentication.getCredentials();

        if (clientCertificate == null) {
            throw new BadCredentialsException(messages.getMessage("X509AuthenticationProvider.certificateNull",
                    "Certificate is null"));
        }

        UserDetails user = userCache.getUserFromCache(clientCertificate);
View Full Code Here

        String subjectDN = clientCert.getSubjectDN().getName();

        Matcher matcher = subjectDNPattern.matcher(subjectDN);

        if (!matcher.find()) {
            throw new BadCredentialsException(messages.getMessage("DaoX509AuthoritiesPopulator.noMatching",
                    new Object[] {subjectDN}, "No matching pattern was found in subjectDN: {0}"));
        }

        if (matcher.groupCount() != 1) {
            throw new IllegalArgumentException("Regular expression must contain a single group ");
View Full Code Here

        verify(authenticationManager);
    }

    @Test
    public void testAuthenticateUserPlainTextInvalid() throws Exception {
        expect(authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password))).andThrow(new BadCredentialsException(""));

        replay(authenticationManager);

        callbackHandler.handleInternal(callback);
        boolean authenticated = callback.getResult();
View Full Code Here

      Authentication authRequest = new JwtBearerAssertionAuthenticationToken(clientId, jwt);

      return this.getAuthenticationManager().authenticate(authRequest);
    } catch (ParseException e) {
      throw new BadCredentialsException("Invalid JWT credential: " + assertion);
    }
  }
View Full Code Here

            }

          } else {
            //This should never happen
            logger.fatal("SEVERE: Client is not an instance of OAuth2AccessTokenEntity.");
            throw new BadCredentialsException("SEVERE: Client is not an instance of ClientDetailsEntity; JwtAssertionTokenGranter cannot process this request.");
          }

          claims.setIssueTime(new Date());

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.