waffle.servlet.WindowsPrincipal.getGroups()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(152)

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

WindowsPrincipal.getGroups介绍

[英]Windows groups that the user is a member of.
[中]用户所属的Windows组。

代码示例

代码示例来源:origin: Waffle/waffle

/**
 * Instantiates a new windows authentication token.
 *
 * @param identity
 *            The {@link WindowsPrincipal} for which this token exists.
 * @param grantedAuthorityFactory
 *            used to construct {@link GrantedAuthority}s for each of the groups to which the
 *            {@link WindowsPrincipal} belongs
 * @param defaultGrantedAuthority
 *            if not null, this {@link GrantedAuthority} will always be added to the granted authorities list
 */
public WindowsAuthenticationToken(final WindowsPrincipal identity,
    final GrantedAuthorityFactory grantedAuthorityFactory, final GrantedAuthority defaultGrantedAuthority) {
  this.principal = identity;
  this.authorities = new ArrayList<>();
  if (defaultGrantedAuthority != null) {
    this.authorities.add(defaultGrantedAuthority);
  }
  for (final WindowsAccount group : this.principal.getGroups().values()) {
    this.authorities.add(grantedAuthorityFactory.createGrantedAuthority(group));
  }
}

代码示例来源:origin: com.github.dblock.waffle/waffle-spring-security4

/**
 * Instantiates a new windows authentication token.
 *
 * @param identity
 *            The {@link WindowsPrincipal} for which this token exists.
 * @param grantedAuthorityFactory
 *            used to construct {@link GrantedAuthority}s for each of the groups to which the
 *            {@link WindowsPrincipal} belongs
 * @param defaultGrantedAuthority
 *            if not null, this {@link GrantedAuthority} will always be added to the granted authorities list
 */
public WindowsAuthenticationToken(final WindowsPrincipal identity,
    final GrantedAuthorityFactory grantedAuthorityFactory, final GrantedAuthority defaultGrantedAuthority) {
  this.principal = identity;
  this.authorities = new ArrayList<>();
  if (defaultGrantedAuthority != null) {
    this.authorities.add(defaultGrantedAuthority);
  }
  for (final WindowsAccount group : this.principal.getGroups().values()) {
    this.authorities.add(grantedAuthorityFactory.createGrantedAuthority(group));
  }
}

代码示例来源:origin: com.github.waffle/waffle-spring-security3

/**
 * Instantiates a new windows authentication token.
 *
 * @param identity
 *            The {@link WindowsPrincipal} for which this token exists.
 * @param grantedAuthorityFactory
 *            used to construct {@link GrantedAuthority}s for each of the groups to which the
 *            {@link WindowsPrincipal} belongs
 * @param defaultGrantedAuthority
 *            if not null, this {@link GrantedAuthority} will always be added to the granted authorities list
 */
public WindowsAuthenticationToken(final WindowsPrincipal identity,
    final GrantedAuthorityFactory grantedAuthorityFactory, final GrantedAuthority defaultGrantedAuthority) {
  this.principal = identity;
  this.authorities = new ArrayList<>();
  if (defaultGrantedAuthority != null) {
    this.authorities.add(defaultGrantedAuthority);
  }
  for (final WindowsAccount group : this.principal.getGroups().values()) {
    this.authorities.add(grantedAuthorityFactory.createGrantedAuthority(group));
  }
}

代码示例来源:origin: Waffle/waffle

/**
 * Instantiates a new windows authentication token.
 *
 * @param identity
 *            The {@link WindowsPrincipal} for which this token exists.
 * @param grantedAuthorityFactory
 *            used to construct {@link GrantedAuthority}s for each of the groups to which the
 *            {@link WindowsPrincipal} belongs
 * @param defaultGrantedAuthority
 *            if not null, this {@link GrantedAuthority} will always be added to the granted authorities list
 */
public WindowsAuthenticationToken(final WindowsPrincipal identity,
    final GrantedAuthorityFactory grantedAuthorityFactory, final GrantedAuthority defaultGrantedAuthority) {
  this.principal = identity;
  this.authorities = new ArrayList<>();
  if (defaultGrantedAuthority != null) {
    this.authorities.add(defaultGrantedAuthority);
  }
  for (final WindowsAccount group : this.principal.getGroups().values()) {
    this.authorities.add(grantedAuthorityFactory.createGrantedAuthority(group));
  }
}

代码示例来源:origin: salyh/elasticsearch-security-plugin

public List<String> getUserRoles() {
  if (request.getUserPrincipal() instanceof GenericPrincipal) {
    final GenericPrincipal wp = (GenericPrincipal) request
        .getUserPrincipal();
    if (wp.getRoles() != null) {
      final List<String> roles = Arrays.asList(wp.getRoles());
      log.debug("GenericPrincipal roles: " + roles);
      return roles;
    }
  }
  if (request.getUserPrincipal() instanceof WindowsPrincipal) {
    final WindowsPrincipal wp = (WindowsPrincipal) request
        .getUserPrincipal();
    log.debug("WindowsPrincipal roles: " + wp.getRolesString());
    log.debug("WindowsPrincipal groups: " + wp.getGroups());
    if (wp.getRolesString() != null) {
      return Arrays.asList(wp.getRolesString().split(","));
    }
  }
  /*if (this.request.getUserPrincipal() instanceof ActiveDirectoryPrincipal) {
    final ActiveDirectoryPrincipal ap = (ActiveDirectoryPrincipal) this.request
        .getUserPrincipal();
    log.debug("ActiveDirectoryPrincipal roles: " + ap.getRoles());
    return ap.getRoles();
  }*/
  return null;
}

代码示例来源:origin: com.github.dblock.waffle/waffle-jna

/**
 * A windows principal.
 * 
 * @param windowsIdentity
 *            Windows identity.
 * @param principalFormat
 *            Principal format.
 * @param roleFormat
 *            Role format.
 */
public WindowsPrincipal(final IWindowsIdentity windowsIdentity, final PrincipalFormat principalFormat,
    final PrincipalFormat roleFormat) {
  this.identity = windowsIdentity;
  this.fqn = windowsIdentity.getFqn();
  this.sid = windowsIdentity.getSid();
  this.sidString = windowsIdentity.getSidString();
  this.groups = WindowsPrincipal.getGroups(windowsIdentity.getGroups());
  this.roles = WindowsPrincipal.getRoles(windowsIdentity, principalFormat, roleFormat);
}

代码示例来源:origin: Waffle/waffle

/**
 * A windows principal.
 *
 * @param windowsIdentity
 *            Windows identity.
 * @param principalFormat
 *            Principal format.
 * @param roleFormat
 *            Role format.
 */
public WindowsPrincipal(final IWindowsIdentity windowsIdentity, final PrincipalFormat principalFormat,
    final PrincipalFormat roleFormat) {
  this.identity = windowsIdentity;
  this.fqn = windowsIdentity.getFqn();
  this.sid = windowsIdentity.getSid();
  this.sidString = windowsIdentity.getSidString();
  this.groups = WindowsPrincipal.getGroups(windowsIdentity.getGroups());
  this.roles = WindowsPrincipal.getRoles(windowsIdentity, principalFormat, roleFormat);
}

代码示例来源:origin: com.github.waffle/waffle-jna

/**
 * A windows principal.
 *
 * @param windowsIdentity
 *            Windows identity.
 * @param principalFormat
 *            Principal format.
 * @param roleFormat
 *            Role format.
 */
public WindowsPrincipal(final IWindowsIdentity windowsIdentity, final PrincipalFormat principalFormat,
    final PrincipalFormat roleFormat) {
  this.identity = windowsIdentity;
  this.fqn = windowsIdentity.getFqn();
  this.sid = windowsIdentity.getSid();
  this.sidString = windowsIdentity.getSidString();
  this.groups = WindowsPrincipal.getGroups(windowsIdentity.getGroups());
  this.roles = WindowsPrincipal.getRoles(windowsIdentity, principalFormat, roleFormat);
}

相关文章