org.springframework.security.authentication.AuthenticationCredentialsNotFoundException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(470)

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

AuthenticationCredentialsNotFoundException.<init>介绍

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

代码示例

代码示例来源:origin: spring-projects/spring-security

/**
 * Helper method which generates an exception containing the passed reason, and
 * publishes an event to the application context.
 * <p>
 * Always throws an exception.
 *
 * @param reason to be provided in the exception detail
 * @param secureObject that was being called
 * @param configAttribs that were defined for the secureObject
 */
private void credentialsNotFound(String reason, Object secureObject,
    Collection<ConfigAttribute> configAttribs) {
  AuthenticationCredentialsNotFoundException exception = new AuthenticationCredentialsNotFoundException(
      reason);
  AuthenticationCredentialsNotFoundEvent event = new AuthenticationCredentialsNotFoundEvent(
      secureObject, configAttribs, exception);
  publishEvent(event);
  throw exception;
}

代码示例来源:origin: org.springframework.security/spring-security-core

/**
 * Helper method which generates an exception containing the passed reason, and
 * publishes an event to the application context.
 * <p>
 * Always throws an exception.
 *
 * @param reason to be provided in the exception detail
 * @param secureObject that was being called
 * @param configAttribs that were defined for the secureObject
 */
private void credentialsNotFound(String reason, Object secureObject,
    Collection<ConfigAttribute> configAttribs) {
  AuthenticationCredentialsNotFoundException exception = new AuthenticationCredentialsNotFoundException(
      reason);
  AuthenticationCredentialsNotFoundEvent event = new AuthenticationCredentialsNotFoundEvent(
      secureObject, configAttribs, exception);
  publishEvent(event);
  throw exception;
}

代码示例来源:origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void testRejectsNulls() {
  new AuthenticationCredentialsNotFoundEvent(null,
      SecurityConfig.createList("TEST"),
      new AuthenticationCredentialsNotFoundException("test"));
}

代码示例来源:origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void testRejectsNulls2() {
  new AuthenticationCredentialsNotFoundEvent(new SimpleMethodInvocation(), null,
      new AuthenticationCredentialsNotFoundException("test"));
}

代码示例来源:origin: cloudfoundry/uaa

public DirContextOperations localCompareAuthenticate(DirContextOperations user, String password) {
  boolean match = false;
  try {
    Attributes attributes = user.getAttributes();
    Attribute attr = attributes.get(getPasswordAttributeName());
    if (attr.size()==0) {
      throw new AuthenticationCredentialsNotFoundException("Missing "+getPasswordAttributeName()+" attribute.");
    }
    for (int i = 0; (attr != null) && (!match) && (i < attr.size()); i++) {
      Object valObject = attr.get(i);
      if (valObject != null && valObject instanceof byte[]) {
        if (passwordEncoder instanceof DynamicPasswordComparator) {
          byte[] received = password.getBytes();
          byte[] stored = (byte[]) valObject;
          match = ((DynamicPasswordComparator) passwordEncoder).comparePasswords(received, stored);
        } else {
          String encodedPassword = passwordEncoder.encodePassword(password, null);
          byte[] passwordBytes = Utf8.encode(encodedPassword);
          match = Arrays.equals(passwordBytes, (byte[]) valObject);
        }
      }
    }
  } catch (NamingException e) {
    throw new BadCredentialsException("Bad credentials", e);
  }
  if (!match)
    throw new BadCredentialsException("Bad credentials");
  return user;
}

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

throw new AuthenticationCredentialsNotFoundException("Authentication was null, not authenticated, or not logged in.");

代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server

throw new AuthenticationCredentialsNotFoundException("No authentication credentials found");

代码示例来源:origin: yujunhao8831/spring-boot-start-current

/**
 * 得到凭证
 */
private static Authentication getAuthentication () {
  final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
  if ( Objects.isNull( authentication ) ) {
    throw new AuthenticationCredentialsNotFoundException( "未授权" );
  }
  return authentication;
}

代码示例来源:origin: peholmst/vaadin4spring

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
  SecurityContext securityContext = SecurityContextHolder.getContext();
  Authentication authentication = securityContext.getAuthentication();
  if (authentication == null) {
    throw new AuthenticationCredentialsNotFoundException("No authentication found in current security context");
  }
  return invocation.getMethod().invoke(authentication, invocation.getArguments());
}

代码示例来源:origin: org.vaadin.spring.extensions/vaadin-spring-ext-security

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
  SecurityContext securityContext = SecurityContextHolder.getContext();
  Authentication authentication = securityContext.getAuthentication();
  if (authentication == null) {
    throw new AuthenticationCredentialsNotFoundException("No authentication found in current security context");
  }
  return invocation.getMethod().invoke(authentication, invocation.getArguments());
}

代码示例来源:origin: org.vaadin.spring/spring-vaadin-security

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
  SecurityContext securityContext = SecurityContextHolder.getContext();
  Authentication authentication = securityContext.getAuthentication();
  if (authentication == null) {
    throw new AuthenticationCredentialsNotFoundException("No authentication found in current security context");
  }
  return invocation.getMethod().invoke(authentication, invocation.getArguments());
}

代码示例来源:origin: yujunhao8831/spring-boot-start-current

/**
 * 未登录
 *
 * @throws ForbiddenException
 */
public static void assertNotLogin () throws ForbiddenException {
  if ( isNotLogin() ) {
    throw new AuthenticationCredentialsNotFoundException( "未登录" );
  }
}

代码示例来源:origin: naturalprogrammer/spring-lemon

/**
   * Default behaviour is to throw error. To be overridden in auth service.
   * 
   * @param username
   * @return
   */
  protected UserDto fetchUserDto(JWTClaimsSet claims) {
    throw new AuthenticationCredentialsNotFoundException(
        LexUtils.getMessage("com.naturalprogrammer.spring.userClaimAbsent"));
  }
}

代码示例来源:origin: jiwhiz/JiwhizBlogWeb

protected UserAccount getCurrentAuthenticatedUser() {
  UserAccount currentUser = this.userAccountService.getCurrentUser();
  if (currentUser == null) {
    throw new AuthenticationCredentialsNotFoundException("User not logged in.");
  }
  return currentUser;
}

代码示例来源:origin: io.macgyver/macgyver-core

@Override
public Authentication authenticate(Authentication auth) throws AuthenticationException {
  try {
    return validateToken(Objects.toString(auth.getCredentials(), null)).orElse(null);
  } catch (RuntimeException e) {
    throw new AuthenticationCredentialsNotFoundException("could not validate token", e);
  }
}

代码示例来源:origin: Evolveum/midpoint

@Override
protected void validateCredentialNotNull(ConnectionEnvironment connEnv, @NotNull MidPointPrincipal principal, PasswordType credential) {
  ProtectedStringType protectedString = credential.getValue();
  if (protectedString == null) {
    recordAuthenticationFailure(principal, connEnv, "no stored password value");
    throw new AuthenticationCredentialsNotFoundException("web.security.provider.password.bad");
  }
}

代码示例来源:origin: org.springframework.security/spring-security-webflux

private <T> Mono<T> commenceAuthentication(ServerWebExchange exchange, AccessDeniedException denied) {
    return this.authenticationEntryPoint.commence(exchange, new AuthenticationCredentialsNotFoundException("Not Authenticated", denied))
      .then(Mono.empty());
  }
}

代码示例来源:origin: apache/servicemix-bundles

private <T> Mono<T> commenceAuthentication(ServerWebExchange exchange, AccessDeniedException denied) {
    return this.authenticationEntryPoint.commence(exchange, new AuthenticationCredentialsNotFoundException("Not Authenticated", denied))
      .then(Mono.empty());
  }
}

代码示例来源:origin: naturalprogrammer/spring-lemon

/**
 * Default behaviour is to throw error. To be overridden in auth service.
 * 
 * @param username
 * @return
 */
protected Mono<UserDto> fetchUserDto(JWTClaimsSet claims) {
  return Mono.error(new AuthenticationCredentialsNotFoundException(
      LexUtils.getMessage("com.naturalprogrammer.spring.userClaimAbsent")));
}

代码示例来源:origin: Evolveum/midpoint

@Override
protected void validateCredentialNotNull(ConnectionEnvironment connEnv, MidPointPrincipal principal,
    NonceType credential) {
  if (credential.getValue() == null) {
    recordAuthenticationFailure(principal, connEnv, "no stored password value");
    throw new AuthenticationCredentialsNotFoundException("web.security.provider.password.bad");
  }
}

相关文章

微信公众号

最新文章

更多