本文整理了Java中java.security.acl.Group.isMember()
方法的一些代码示例,展示了Group.isMember()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Group.isMember()
方法的具体详情如下:
包路径:java.security.acl.Group
类名称:Group
方法名:isMember
[英]Returns whether the specified principal is a member of this group.
[中]返回指定的主体是否是此组的成员。
代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel
@Override
public boolean isMember(Principal member) {
if (_members.containsKey(member)) {
return true;
}
for (Principal principal : _members.values()) {
if (principal instanceof Group) {
Group group = (Group)principal;
if (group.isMember(member)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: apache/jackrabbit-oak
@Override
public boolean isMember(Principal member) {
return group.isMember(member);
}
代码示例来源:origin: org.picketbox/picketbox
/** Returns true if the passed principal is a member of the active group.
This method does a recursive search, so if a principal belongs to a
group which is a member of this group, true is returned.
@param member the principal whose membership is to be checked.
@return true if the principal is a member of this group, false otherwise.
*/
public boolean isMember(Principal member)
{
if( rolesStack.size() == 0 )
return false;
Group activeGroup = (Group) rolesStack.getFirst();
boolean isMember = activeGroup.isMember(member);
return isMember;
}
代码示例来源:origin: org.jboss.seam/jboss-seam
public boolean isMember(Principal member)
{
if ( members.contains(member) )
{
return true;
}
else
{
for (Principal m : members)
{
if (m instanceof Group && ((Group) m).isMember(member))
{
return true;
}
}
}
return false;
}
代码示例来源:origin: org.jboss.security/jbosssx-bare
/** Returns true if the passed principal is a member of the active group.
This method does a recursive search, so if a principal belongs to a
group which is a member of this group, true is returned.
@param member the principal whose membership is to be checked.
@return true if the principal is a member of this group, false otherwise.
*/
public boolean isMember(Principal member)
{
if( rolesStack.size() == 0 )
return false;
Group activeGroup = (Group) rolesStack.getFirst();
boolean isMember = activeGroup.isMember(member);
return isMember;
}
代码示例来源:origin: org.jboss.microcontainer/jboss-reliance-identity
public boolean isMember(Principal member)
{
if (members.contains(member))
{
return true;
}
else
{
for (Principal m : members)
{
if (m instanceof Group && ((Group)m).isMember(member))
{
return true;
}
}
}
return false;
}
代码示例来源:origin: Waffle/waffle
@Override
public boolean isMember(final Principal user) {
boolean isMember = this.members.containsKey(user);
if (!isMember) {
final Collection<Principal> values = this.members.values();
for (final Principal principal : values) {
if (principal instanceof Group) {
final Group group = (Group) principal;
isMember = group.isMember(user);
if (isMember) {
break;
}
}
}
}
return isMember;
}
代码示例来源:origin: com.github.waffle/waffle-jna
@Override
public boolean isMember(final Principal user) {
boolean isMember = this.members.containsKey(user);
if (!isMember) {
final Collection<Principal> values = this.members.values();
for (final Principal principal : values) {
if (principal instanceof Group) {
final Group group = (Group) principal;
isMember = group.isMember(user);
if (isMember) {
break;
}
}
}
}
return isMember;
}
代码示例来源:origin: com.liferay.portal/portal-kernel
public boolean isMember(Principal member) {
boolean isMember = _members.containsKey(member);
if (!isMember) {
Iterator<Principal> itr = _members.values().iterator();
while (!isMember && itr.hasNext()) {
Principal principal = itr.next();
if (principal instanceof Group) {
Group group = (Group)principal;
isMember = group.isMember(member);
}
}
}
return isMember;
}
代码示例来源:origin: apache/jackrabbit
/**
* Returns true if the passed principal is a member of the group.
* @param principal the principal whose members are being checked.
* @param member the principal whose membership is to be checked.
* @return true if the principal is a member of this group, false otherwise.
*/
public static boolean isMember(Principal principal, Principal member) {
if (principal instanceof Group) {
return ((Group) principal).isMember(member);
}
if (principal instanceof GroupPrincipal) {
return ((GroupPrincipal) principal).isMember(member);
}
return false;
}
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Returns true if the passed principal is a member of the group.
* @param principal the principal whose members are being checked.
* @param member the principal whose membership is to be checked.
* @return true if the principal is a member of this group, false otherwise.
*/
public static boolean isMember(@NotNull Principal principal, @NotNull Principal member) {
if (principal instanceof Group) {
return ((Group) principal).isMember(member);
}
if (principal instanceof GroupPrincipal) {
return ((GroupPrincipal) principal).isMember(member);
}
return false;
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-core
/**
* Returns true if the passed principal is a member of the group.
* @param principal the principal whose members are being checked.
* @param member the principal whose membership is to be checked.
* @return true if the principal is a member of this group, false otherwise.
*/
public static boolean isMember(Principal principal, Principal member) {
if (principal instanceof Group) {
return ((Group) principal).isMember(member);
}
if (principal instanceof GroupPrincipal) {
return ((GroupPrincipal) principal).isMember(member);
}
return false;
}
}
代码示例来源:origin: wildfly-extras/wildfly-camel
@Override
protected void authorize(LoginContext context) throws LoginException {
HashSet<String> required = new HashSet<>(requiredRoles);
Set<Group> groups = context.getSubject().getPrincipals(Group.class);
if (groups != null) {
for (Group group : groups) {
if ("Roles".equals(group.getName())) {
for (String role : requiredRoles) {
if (group.isMember(new SimplePrincipal(role))) {
required.remove(role);
}
}
}
}
}
if (!required.isEmpty())
throw new LoginException("User does not have required roles: " + required);
}
}
代码示例来源:origin: org.jboss.security/jbosssx-bare
/**
* Process the group with the roles that are mapped in the
* properies file
* @param group Group that needs to be processed
* @param props Properties file
*/
private void processRoles(Group group,Properties props) throws Exception
{
Enumeration<?> enumer = props.propertyNames();
while(enumer.hasMoreElements())
{
String roleKey = (String)enumer.nextElement();
String comma_separated_roles = props.getProperty(roleKey);
Principal pIdentity = createIdentity(roleKey);
if(group.isMember(pIdentity))
Util.parseGroupMembers(group,comma_separated_roles,this);
if(REPLACE_ROLE)
group.removeMember(pIdentity);
}
}
}
代码示例来源:origin: org.jspresso.framework/jspresso-security
protected static boolean isMember(Group subjectRoles, String grantedRole) {
if (subjectRoles.isMember(new SimplePrincipal(grantedRole))) {
return true;
} else {
// Try regexps
try {
Pattern regex = Pattern.compile(grantedRole);
for (String role : getRoles(subjectRoles)) {
if (regex.matcher(role).matches()) {
return true;
}
}
} catch (Throwable t) {
// Nothing to do here
}
List<String> roles = getRoles(subjectRoles);
}
return false;
}
代码示例来源:origin: com.github.nyla-solutions/nyla.solutions.core
private boolean isMemberRecurse(Principal principal, Vector<Principal> vector)
{
for(Enumeration<Principal> enumeration = members(); enumeration.hasMoreElements();)
{
boolean flag = false;
Principal principal1 = (Principal)enumeration.nextElement();
if(principal1.equals(principal))
return true;
if(principal1 instanceof SecurityGroup)
{
SecurityGroup groupimpl = (SecurityGroup)principal1;
vector.addElement(this);
if(!vector.contains(groupimpl))
flag = groupimpl.isMemberRecurse(principal, vector);
}
else
if(principal1 instanceof Group)
{
Group group1 = (Group)principal1;
if(!vector.contains(group1))
flag = group1.isMember(principal);
}
if(flag)
return flag;
}
return false;
}//--------------------------------------------
@Override
代码示例来源:origin: org.jboss.seam/jboss-seam
/**
* Checks if the authenticated user is a member of the specified role.
*
* @param role String The name of the role to check
* @return boolean True if the user is a member of the specified role
*/
public boolean hasRole(String role)
{
if (!securityEnabled) return true;
if (systemOp != null && Boolean.TRUE.equals(systemOp.get())) return true;
tryLogin();
for ( Group sg : getSubject().getPrincipals(Group.class) )
{
if ( ROLES_GROUP.equals( sg.getName() ) )
{
return sg.isMember( new Role(role) );
}
}
return false;
}
代码示例来源:origin: org.jboss.microcontainer/jboss-reliance-identity
/**
* Checks if the authenticated Identity is a member of the specified role.
*
* @param role String The name of the role to check
* @return boolean True if the user is a member of the specified role
*/
public boolean hasRole(String role)
{
isLoggedIn(true);
for (Group sg : getSubject().getPrincipals(Group.class))
{
if (ROLES_GROUP.equals(sg.getName()))
{
return sg.isMember(new SimplePrincipal(role));
}
}
return false;
}
代码示例来源:origin: org.picketbox/picketbox
/**
* Process the group with the roles that are mapped in the
* properies file
* @param group Group that needs to be processed
* @param props Properties file
*/
private void processRoles(Group group,Properties props) //throws Exception
{
Enumeration<?> enumer = props.propertyNames();
while(enumer.hasMoreElements())
{
String roleKey = (String)enumer.nextElement();
String comma_separated_roles = props.getProperty(roleKey);
try {
Principal pIdentity = createIdentity(roleKey);
if (group != null)
{
if(group.isMember(pIdentity))
Util.parseGroupMembers(group,comma_separated_roles,this);
if(REPLACE_ROLE)
group.removeMember(pIdentity);
}
}
catch(Exception e) {
PicketBoxLogger.LOGGER.debugFailureToCreatePrincipal(roleKey, e);
}
}
}
}
代码示例来源:origin: org.picketlink/picketlink-consolidated-social
@Override
protected Group[] getRoleSets() throws LoginException {
Group group = new SimpleGroup("Roles");
List<String> roles = OpenIDProcessor.cachedRoles.get();
if (roles != null) {
for (String role : roles) {
group.addMember(new SimplePrincipal(role));
}
}
roles = FacebookProcessor.cachedRoles.get();
if (roles != null) {
for (String role : roles) {
Principal rolePrincipal = new SimplePrincipal(role);
if (group.isMember(rolePrincipal) == false) {
group.addMember(rolePrincipal);
}
}
}
return new Group[] { group };
}
}
内容来源于网络,如有侵权,请联系作者删除!