org.apache.catalina.connector.Request.doGetUserPrincipal()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(99)

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

Request.doGetUserPrincipal介绍

[英]Return the principal that has been authenticated for this Request.
[中]返回已为此请求进行身份验证的主体。

代码示例

代码示例来源:origin: jboss.web/jbossweb

/**
 * Return the principal that has been authenticated for this Request.
 */
public Principal getUserPrincipal() {
  Principal principal = doGetUserPrincipal();
  if (principal instanceof GenericPrincipal) {
    return ((GenericPrincipal) principal).getUserPrincipal();
  } else {
    return (principal);
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

/**
 * Return the principal that has been authenticated for this Request.
 */
public Principal getUserPrincipal() {
  Principal principal = doGetUserPrincipal();
  if (principal instanceof GenericPrincipal) {
    return ((GenericPrincipal) principal).getUserPrincipal();
  } else {
    return (principal);
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

/**
 * Return the name of the remote user that has been authenticated
 * for this Request.
 */
public String getRemoteUser() {
  Principal principal = doGetUserPrincipal();
  if (principal instanceof GenericPrincipal) {
    return ((GenericPrincipal) principal).getUserPrincipal().getName();
  } else if (principal != null) {
    return (principal.getName());
  } else {
    return (null);
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

/**
 * Return <code>true</code> if the authenticated user principal
 * possesses the specified role name.
 *
 * @param role Role name to be validated
 */
public boolean isUserInRole(String role) {
  // Have we got an authenticated principal at all?
  Principal principal = doGetUserPrincipal();
  if (principal == null)
    return (false);
  // Identify the Realm we will use for checking role assignmenets
  if (context == null)
    return (false);
  Realm realm = context.getRealm();
  if (realm == null)
    return (false);
  // Check for a role alias defined in a <security-role-ref> element
  if (wrapper != null) {
    String realRole = wrapper.findSecurityReference(role);
    if ((realRole != null) &&
      realm.hasRole(principal, realRole))
      return (true);
  }
  // Check for a role defined directly as a <security-role>
  return (realm.hasRole(principal, role));
}

代码示例来源:origin: jboss.web/jbossweb

/**
 * Return <code>true</code> if the authenticated user principal
 * possesses the specified role name.
 *
 * @param role Role name to be validated
 */
public boolean isUserInRole(String role) {
  // Have we got an authenticated principal at all?
  Principal principal = doGetUserPrincipal();
  if (principal == null)
    return (false);
  // Identify the Realm we will use for checking role assignmenets
  if (context == null)
    return (false);
  Realm realm = context.getRealm();
  if (realm == null)
    return (false);
  // Check for a role alias defined in a <security-role-ref> element
  if (wrapper != null) {
    String realRole = wrapper.findSecurityReference(role);
    if ((realRole != null) &&
      realm.hasRole(principal, realRole))
      return (true);
  }
  // Check for a role defined directly as a <security-role>
  return (realm.hasRole(principal, role));
}

相关文章

微信公众号

最新文章

更多

Request类方法