本文整理汇总了Java中org.apache.karaf.jaas.boot.principal.GroupPrincipal类的典型用法代码示例。如果您正苦于以下问题:Java GroupPrincipal类的具体用法?Java GroupPrincipal怎么用?Java GroupPrincipal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupPrincipal类属于org.apache.karaf.jaas.boot.principal包,在下文中一共展示了GroupPrincipal类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCallerInRole
import org.apache.karaf.jaas.boot.principal.GroupPrincipal; //导入依赖的package包/类
/**
* Checks if is caller in role.
*
* @param securityContext
* the security context
* @param roleName
* the role name
* @param securityDomain
* the security domain
* @return true, if is caller in role
*/
public boolean isCallerInRole(SecurityContext securityContext, String roleName, String securityDomain) {
Subject subject = securityContext.getSubject(securityDomain, false);
if (subject != null) {
for (Principal principal : subject.getPrincipals()) {
if (principal instanceof GroupPrincipal) {
if (principal.getName().equalsIgnoreCase(roleName)) {
return true;
}
} else if (principal instanceof org.switchyard.security.principal.GroupPrincipal) {
Enumeration<? extends Principal> e = ((org.switchyard.security.principal.GroupPrincipal) principal).members();
while (e.hasMoreElements()) {
Principal p = e.nextElement();
if (p.getName().equals(roleName)) {
return true;
}
}
}
}
}
return false;
}
示例2: isUserInGroup
import org.apache.karaf.jaas.boot.principal.GroupPrincipal; //导入依赖的package包/类
public boolean isUserInGroup(String g) {
for (GroupPrincipal principal : subject.getPrincipals(GroupPrincipal.class)) {
if (principal.getName().equals(g)) return true;
}
return false;
}
示例3: isUserInGroup
import org.apache.karaf.jaas.boot.principal.GroupPrincipal; //导入依赖的package包/类
static boolean isUserInGroup(Subject subject, String group) {
for (GroupPrincipal principal : subject.getPrincipals(GroupPrincipal.class)) {
if (principal.getName().equals(group)) return true;
}
return false;
}