本文整理了Java中org.restlet.Application.getRole()
方法的一些代码示例,展示了Application.getRole()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.getRole()
方法的具体详情如下:
包路径:org.restlet.Application
类名称: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);
}
内容来源于网络,如有侵权,请联系作者删除!