org.acegisecurity.BadCredentialsException类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(181)

本文整理了Java中org.acegisecurity.BadCredentialsException类的一些代码示例,展示了BadCredentialsException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BadCredentialsException类的具体详情如下:
包路径:org.acegisecurity.BadCredentialsException
类名称:BadCredentialsException

BadCredentialsException介绍

[英]Thrown if an authentication request is rejected because the credentials are invalid. For this exception to be thrown, it means the account is neither locked nor disabled.
[中]如果由于凭据无效而拒绝身份验证请求,则引发。对于要引发的此异常,这意味着该帐户既没有被锁定也没有被禁用。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override
protected Details authenticate(String username, String password) throws AuthenticationException {
  Details u = loadUserByUsername(username);
  if (!u.isPasswordCorrect(password)) {
    String message;
    try {
      message = ResourceBundle.getBundle("org.acegisecurity.messages").getString("AbstractUserDetailsAuthenticationProvider.badCredentials");
    } catch (MissingResourceException x) {
      message = "Bad credentials";
    }
    throw new BadCredentialsException(message);
  }
  return u;
}

代码示例来源:origin: jenkinsci/active-directory-plugin

Throwable t = e.getCause();
if (t instanceof CommunicationException) {
  return FormValidation.error(e, "Any Domain Controller is reachable");

代码示例来源:origin: org.acegisecurity/acegi-security

private LdapUserDetails bindWithDn(String userDn, String username, String password) {
  LdapTemplate template = new LdapTemplate(getInitialDirContextFactory(), userDn, password);
  try {
    LdapUserDetailsImpl.Essence user = (LdapUserDetailsImpl.Essence) template.retrieveEntry(userDn,
        getUserDetailsMapper(), getUserAttributes());
    user.setUsername(username);
    user.setPassword(password);
    return user.createUserDetails();
  } catch (BadCredentialsException e) {
    // This will be thrown if an invalid user name is used and the method may
    // be called multiple times to try different names, so we trap the exception
    // unless a subclass wishes to implement more specialized behaviour.
    handleBindException(userDn, username, e.getCause());
  }
  return null;
}

代码示例来源:origin: jenkinsci/jenkins

fail(req, rsp, new BadCredentialsException("Invalid password/token for user: " + username));
} else {
  fail(req, rsp, new BadCredentialsException("Malformed HTTP basic Authorization header"));

代码示例来源:origin: jenkinsci/jenkins

public Authentication authenticate() throws AuthenticationException, IOException, InterruptedException {
    if (userName==null)
      return command.getTransportAuthentication();    // no authentication parameter. fallback to the transport
    if (passwordFile!=null)
      try {
        password = new FilePath(command.checkChannel(), passwordFile).readToString().trim();
      } catch (IOException e) {
        throw new BadCredentialsException("Failed to read "+passwordFile,e);
      }
    if (password==null)
      password = command.checkChannel().call(new InteractivelyAskForPassword());
    if (password==null)
      throw new BadCredentialsException("No password specified");
    UserDetails d = doAuthenticate(userName, password);
    return new UsernamePasswordAuthenticationToken(d, password, d.getAuthorities());
  }
};

代码示例来源:origin: mocleiri/github-oauth-plugin

public Authentication authenticate(Authentication authentication)
      throws AuthenticationException {
    if (authentication instanceof GithubAuthenticationToken)
      return authentication;
    throw new BadCredentialsException(
        "Unexpected authentication type: " + authentication);
  }
}, new UserDetailsService() {

代码示例来源:origin: org.acegisecurity/acegi-security

public Authentication doAuthentication(Authentication authentication)
    throws AuthenticationException {
    if (grantAccess) {
      return authentication;
    } else {
      throw new BadCredentialsException("MockAuthenticationManager instructed to deny access");
    }
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/oic-auth

public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    if (authentication instanceof AnonymousAuthenticationToken)
      return authentication;
    throw new BadCredentialsException("Unexpected authentication type: " + authentication);
  }
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-test-harness

@Override
protected UserDetails authenticate(String username, String password) throws AuthenticationException {
  if (username.equals(password))
    return loadUserByUsername(username);
  throw new BadCredentialsException(username);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-test-framework

@Override
protected UserDetails authenticate(String username, String password) throws AuthenticationException {
  if (username.equals(password))
    return loadUserByUsername(username);
  throw new BadCredentialsException(username);
}

代码示例来源:origin: jenkinsci/jenkins-test-harness

@Override
protected UserDetails authenticate(String username, String password) throws AuthenticationException {
  if (username.equals(password))
    return loadUserByUsername(username);
  throw new BadCredentialsException(username);
}

代码示例来源:origin: jenkinsci/jenkins-test-harness

@Override
protected UserDetails authenticate(String username, String password) throws AuthenticationException {
  if (username.equals(password))
    return loadUserByUsername(username);
  throw new BadCredentialsException(username);
}

代码示例来源:origin: org.jenkins-ci.plugins/mock-security-realm

@Override protected UserDetails authenticate(String username, String password) throws AuthenticationException {
  doDelay();
  UserDetails u = loadUserByUsername(username);
  if (!password.equals(username)) {
    throw new BadCredentialsException(password);
  }
  return u;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Override
protected Details authenticate(String username, String password) throws AuthenticationException {
  Details u = loadUserByUsername(username);
  if (!u.isPasswordCorrect(password)) {
    String message;
    try {
      message = ResourceBundle.getBundle("org.acegisecurity.messages").getString("AbstractUserDetailsAuthenticationProvider.badCredentials");
    } catch (MissingResourceException x) {
      message = "Bad credentials";
    }
    throw new BadCredentialsException(message);
  }
  return u;
}

代码示例来源:origin: org.acegisecurity/acegi-security

public Authentication authenticate(Authentication authentication)
  throws AuthenticationException {
  AuthByAdapter token = (AuthByAdapter) authentication;
  if (token.getKeyHash() == key.hashCode()) {
    return authentication;
  } else {
    throw new BadCredentialsException(messages.getMessage("AuthByAdapterProvider.incorrectKey",
        "The presented AuthByAdapter implementation does not contain the expected key"));
  }
}

代码示例来源:origin: org.acegisecurity/acegi-security

public Authentication authenticate(Authentication authentication)
  throws AuthenticationException {
  RunAsUserToken token = (RunAsUserToken) authentication;
  if (token.getKeyHash() == key.hashCode()) {
    return authentication;
  } else {
    throw new BadCredentialsException(messages.getMessage("RunAsImplAuthenticationProvider.incorrectKey",
        "The presented RunAsUserToken does not contain the expected key"));
  }
}

代码示例来源:origin: org.acegisecurity/acegi-security

public Authentication authenticate(Authentication authentication)
  throws AuthenticationException {
  if (!supports(authentication.getClass())) {
    return null;
  }
  if (this.key.hashCode() != ((RememberMeAuthenticationToken) authentication).getKeyHash()) {
    throw new BadCredentialsException(messages.getMessage("RememberMeAuthenticationProvider.incorrectKey",
        "The presented RememberMeAuthenticationToken does not contain the expected key"));
  }
  return authentication;
}

代码示例来源:origin: org.acegisecurity/acegi-security

public Authentication authenticate(Authentication authentication)
  throws AuthenticationException {
  if (!supports(authentication.getClass())) {
    return null;
  }
  if (this.key.hashCode() != ((AnonymousAuthenticationToken) authentication).getKeyHash()) {
    throw new BadCredentialsException(messages.getMessage("AnonymousAuthenticationProvider.incorrectKey",
        "The presented AnonymousAuthenticationToken does not contain the expected key"));
  }
  return authentication;
}

代码示例来源:origin: org.acegisecurity/acegi-security

protected void additionalAuthenticationChecks(UserDetails userDetails,
                       UsernamePasswordAuthenticationToken authentication)
  throws AuthenticationException {
  if (!userDetails.getPassword().equals(authentication.getCredentials().toString())) {
    throw new BadCredentialsException(messages.getMessage(
        "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"),
        includeDetailsObject ? userDetails : null);
  }
}

代码示例来源:origin: jenkinsci/active-directory-plugin

throw new BadCredentialsException("Either no such user '" + principalName + "' or incorrect password", namingException);
} catch (NamingException e) {
  LOGGER.log(Level.WARNING, "Failed to bind to "+ldapServer, e);

相关文章

微信公众号

最新文章

更多