本文整理了Java中fathom.realm.Account.hasRole()
方法的一些代码示例,展示了Account.hasRole()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Account.hasRole()
方法的具体详情如下:
包路径:fathom.realm.Account
类名称:Account
方法名:hasRole
[英]Returns true if this Account has the specified role, false otherwise.
[中]
代码示例来源:origin: com.gitblit.fathom/fathom-security
/**
* Asserts this Account has the specified role by returning quietly if they do or throwing an
* {@link fathom.authz.AuthorizationException} if they do not.
*
* @param roleIdentifier the application-specific role identifier (usually a role id or role name ).
* @throws fathom.authz.AuthorizationException if this Account does not have the role.
*/
public void checkRole(String roleIdentifier) throws AuthorizationException {
if (!hasRole(roleIdentifier)) {
throw new AuthorizationException("'{}' does not have the role '{}'", toString(), roleIdentifier);
}
}
代码示例来源:origin: gitblit/fathom
/**
* Asserts this Account has the specified role by returning quietly if they do or throwing an
* {@link fathom.authz.AuthorizationException} if they do not.
*
* @param roleIdentifier the application-specific role identifier (usually a role id or role name ).
* @throws fathom.authz.AuthorizationException if this Account does not have the role.
*/
public void checkRole(String roleIdentifier) throws AuthorizationException {
if (!hasRole(roleIdentifier)) {
throw new AuthorizationException("'{}' does not have the role '{}'", toString(), roleIdentifier);
}
}
代码示例来源:origin: com.gitblit.fathom/fathom-security-ldap
/**
* Set the admin attribute from group memberships retrieved from LDAP.
*
* @param account
*/
private void setAdminAttribute(Account account) {
if (adminGroups != null) {
for (String adminGroup : adminGroups) {
if (adminGroup.startsWith("@") && account.getUsername().equalsIgnoreCase(adminGroup.substring(1))) {
// admin user
account.getAuthorizations().addPermission("*");
} else if (account.hasRole(adminGroup)) {
// admin role
account.getAuthorizations().addPermission("*");
}
}
}
}
代码示例来源:origin: gitblit/fathom
/**
* Set the admin attribute from group memberships retrieved from Windows.
*
* @param account
*/
private void setAdminAttribute(Account account) {
if (adminGroups != null) {
for (String adminGroup : adminGroups) {
if (adminGroup.startsWith("@") && account.getUsername().equalsIgnoreCase(adminGroup.substring(1))) {
// admin user
account.getAuthorizations().addPermission("*");
} else if (account.hasRole(adminGroup)) {
// admin role
account.getAuthorizations().addPermission("*");
}
}
}
}
代码示例来源:origin: gitblit/fathom
/**
* Set the admin attribute from group memberships retrieved from LDAP.
*
* @param account
*/
private void setAdminAttribute(Account account) {
if (adminGroups != null) {
for (String adminGroup : adminGroups) {
if (adminGroup.startsWith("@") && account.getUsername().equalsIgnoreCase(adminGroup.substring(1))) {
// admin user
account.getAuthorizations().addPermission("*");
} else if (account.hasRole(adminGroup)) {
// admin role
account.getAuthorizations().addPermission("*");
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!