org.restlet.Application.getRole()方法的使用及代码示例

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

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

Application.getRole介绍

[英]Returns the role associated to the given name.
[中]返回与给定名称关联的角色。

代码示例

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Finds an existing role or creates a new one if needed.
 * 
 * @param application
 *            The parent application.
 * @param name
 *            The role name to find or create.
 * @param description
 *            The role description if one needs to be created.
 * @return The role found or created.
 */
public static Role get(Application application, String name,
    String description) {
  Role role = (application == null) ? null : application.getRole(name);
  return (role == null) ? new Role(application, name, description) : role;
}

代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs

/**
 * Returns a boolean indicating whether the authenticated user is included
 * in the specified logical "role". If the user has not been authenticated,
 * the method returns <code>false</code>.
 * 
 * @param roleName
 *            a <code>String</code> specifying the name of the role
 * @return a <code>boolean</code> indicating whether the user making the
 *         request belongs to a given role; <code>false</code> if the user
 *         has not been authenticated
 * @see SecurityContext#isUserInRole(String)
 */
public boolean isUserInRole(String roleName) {
  Role role = Application.getCurrent().getRole(roleName);
  return (role != null)
      && this.request.getClientInfo().getRoles().contains(role);
}

相关文章