org.springframework.security.authentication.AnonymousAuthenticationToken.setAuthenticated()方法的使用及代码示例

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

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

AnonymousAuthenticationToken.setAuthenticated介绍

暂无

代码示例

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

/**
 * Constructor helps in Jackson Deserialization
 *
 * @param keyHash     hashCode of provided Key, constructed by above constructor
 * @param principal   the principal (typically a <code>UserDetails</code>)
 * @param authorities the authorities granted to the principal
 * @since 4.2
 */
private AnonymousAuthenticationToken(Integer keyHash, Object principal,
                  Collection<? extends GrantedAuthority> authorities) {
  super(authorities);
  if (principal == null || "".equals(principal)) {
    throw new IllegalArgumentException("principal cannot be null or empty");
  }
  Assert.notEmpty(authorities, "authorities cannot be null or empty");
  this.keyHash = keyHash;
  this.principal = principal;
  setAuthenticated(true);
}

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

/**
 * Constructor helps in Jackson Deserialization
 *
 * @param keyHash     hashCode of provided Key, constructed by above constructor
 * @param principal   the principal (typically a <code>UserDetails</code>)
 * @param authorities the authorities granted to the principal
 * @since 4.2
 */
private AnonymousAuthenticationToken(Integer keyHash, Object principal,
                  Collection<? extends GrantedAuthority> authorities) {
  super(authorities);
  if (principal == null || "".equals(principal)) {
    throw new IllegalArgumentException("principal cannot be null or empty");
  }
  Assert.notEmpty(authorities, "authorities cannot be null or empty");
  this.keyHash = keyHash;
  this.principal = principal;
  setAuthenticated(true);
}

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

@Test
public void testSetAuthenticatedIgnored() {
  AnonymousAuthenticationToken token = new AnonymousAuthenticationToken("key",
      "Test", ROLES_12);
  assertThat(token.isAuthenticated()).isTrue();
  token.setAuthenticated(false);
  assertThat(!token.isAuthenticated()).isTrue();
}

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

/**
 * Constructor helps in Jackson Deserialization
 *
 * @param keyHash     hashCode of provided Key, constructed by above constructor
 * @param principal   the principal (typically a <code>UserDetails</code>)
 * @param authorities the authorities granted to the principal
 * @since 4.2
 */
private AnonymousAuthenticationToken(Integer keyHash, Object principal,
                  Collection<? extends GrantedAuthority> authorities) {
  super(authorities);
  if (principal == null || "".equals(principal)) {
    throw new IllegalArgumentException("principal cannot be null or empty");
  }
  Assert.notEmpty(authorities, "authorities cannot be null or empty");
  this.keyHash = keyHash;
  this.principal = principal;
  setAuthenticated(true);
}

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

/**
 * Constructor.
 *
 * @param key to identify if this object made by an authorised client
 * @param principal the principal (typically a <code>UserDetails</code>)
 * @param authorities the authorities granted to the principal
 *
 * @throws IllegalArgumentException if a <code>null</code> was passed
 */
public AnonymousAuthenticationToken(String key, Object principal, Collection<? extends GrantedAuthority> authorities) {
  super(authorities);
  if ((key == null) || ("".equals(key)) || (principal == null) || "".equals(principal) || (authorities == null)
    || (authorities.isEmpty())) {
    throw new IllegalArgumentException("Cannot pass null or empty values to constructor");
  }
  this.keyHash = key.hashCode();
  this.principal = principal;
  setAuthenticated(true);
}

相关文章