org.acegisecurity.BadCredentialsException.<init>()方法的使用及代码示例

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

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

BadCredentialsException.<init>介绍

[英]Constructs a BadCredentialsException with the specified message.
[中]使用指定的消息构造一个BadCredentialsException

代码示例

代码示例来源: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/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: org.jvnet.hudson.main/hudson-core

@Override
protected Details authenticate(String username, String password) throws AuthenticationException {
  Details u = loadUserByUsername(username);
  if (!PASSWORD_ENCODER.isPasswordValid(u.getPassword(),password,null))
    throw new BadCredentialsException("Failed to login as "+username);
  return u;
}

代码示例来源:origin: hudson/hudson-2.x

@Override
protected Details authenticate(String username, String password) throws AuthenticationException {
  Details u = loadUserByUsername(username);
  if (!PASSWORD_ENCODER.isPasswordValid(u.getPassword(),password,null))
    throw new BadCredentialsException("Failed to login as "+username);
  return u;
}

代码示例来源:origin: Diabol/delivery-pipeline-plugin

@Override
public void abortBuild(String projectName, String buildId) throws TriggerException {
  AbstractProject project = ProjectUtil.getProject(projectName, Jenkins.getInstance());
  if (!project.hasPermission(Item.CANCEL)) {
    throw new BadCredentialsException("Not authorized to abort build");
  }
  AbstractBuild build = project.getBuildByNumber(Integer.parseInt(buildId));
  try {
    build.doStop();
  } catch (IOException | ServletException e) {
    throw new TriggerException("Could not abort build");
  }
}

相关文章

微信公众号

最新文章

更多