Stay organized with collections
Save and categorize content based on your preferences.
Group
public
interface
Group
implements
Principal
This interface was deprecated
in API level 33.
This class is deprecated and subject to removal in a future
version of Java SE. It has been replaced by java.security.Policy
and related classes since 1.2.
This interface is used to represent a group of principals. (A principal
represents an entity such as an individual user or a company).
Note that Group extends Principal. Thus, either a Principal or a Group can
be passed as an argument to methods containing a Principal parameter. For
example, you can add either a Principal or a Group to a Group object by
calling the object's addMember
method, passing it the
Principal or Group.
Summary
Inherited methods |
From interface
java.security.Principal
abstract
boolean
|
equals(Object another)
Compares this principal to the specified object.
|
abstract
String
|
getName()
Returns the name of this principal.
|
abstract
int
|
hashCode()
Returns a hashcode for this principal.
|
default
boolean
|
implies(Subject subject)
Returns true if the specified subject is implied by this principal.
|
abstract
String
|
toString()
Returns a string representation of this principal.
|
|
Public methods
addMember
public abstract boolean addMember (Principal user)
Adds the specified member to the group.
Parameters |
user |
Principal : the principal to add to this group. |
Returns |
boolean |
true if the member was successfully added,
false if the principal was already a member. |
isMember
public abstract boolean isMember (Principal member)
Returns true if the passed principal is a member of the 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.
Parameters |
member |
Principal : the principal whose membership is to be checked. |
Returns |
boolean |
true if the principal is a member of this group,
false otherwise. |
members
public abstract Enumeration<? extends Principal> members ()
Returns an enumeration of the members in the group.
The returned objects can be instances of either Principal
or Group (which is a subclass of Principal).
removeMember
public abstract boolean removeMember (Principal user)
Removes the specified member from the group.
Parameters |
user |
Principal : the principal to remove from this group. |
Returns |
boolean |
true if the principal was removed, or
false if the principal was not a member. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# Group\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nDeprecated in [API level\n33](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nGroup\n=====\n\n\n`\npublic\n\n\ninterface\nGroup\n`\n\n\n`\n\n\nimplements\n\n`[Principal](/reference/java/security/Principal)`\n\n\n`\n\n|-------------------------|\n| java.security.acl.Group |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\n**This interface was deprecated\nin API level 33.** \n\nThis class is deprecated and subject to removal in a future\nversion of Java SE. It has been replaced by `java.security.Policy`\nand related classes since 1.2.\n\nThis interface is used to represent a group of principals. (A principal\nrepresents an entity such as an individual user or a company).\n\n\nNote that Group extends Principal. Thus, either a Principal or a Group can\nbe passed as an argument to methods containing a Principal parameter. For\nexample, you can add either a Principal or a Group to a Group object by\ncalling the object's `addMember` method, passing it the\nPrincipal or Group.\n\nSummary\n-------\n\n| ### Public methods ||\n|----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[addMember](/reference/java/security/acl/Group#addMember(java.security.Principal))`(`[Principal](/reference/java/security/Principal)` user) ` Adds the specified member to the group. |\n| ` abstract boolean` | ` `[isMember](/reference/java/security/acl/Group#isMember(java.security.Principal))`(`[Principal](/reference/java/security/Principal)` member) ` Returns true if the passed principal is a member of the group. |\n| ` abstract `[Enumeration](/reference/java/util/Enumeration)`\u003c? extends `[Principal](/reference/java/security/Principal)`\u003e` | ` `[members](/reference/java/security/acl/Group#members())`() ` Returns an enumeration of the members in the group. |\n| ` abstract boolean` | ` `[removeMember](/reference/java/security/acl/Group#removeMember(java.security.Principal))`(`[Principal](/reference/java/security/Principal)` user) ` Removes the specified member from the group. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.security.Principal](/reference/java/security/Principal)` ` |---------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract boolean` | ` `[equals](/reference/java/security/Principal#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` another) ` Compares this principal to the specified object. | | ` abstract `[String](/reference/java/lang/String) | ` `[getName](/reference/java/security/Principal#getName())`() ` Returns the name of this principal. | | ` abstract int` | ` `[hashCode](/reference/java/security/Principal#hashCode())`() ` Returns a hashcode for this principal. | | ` default boolean` | ` `[implies](/reference/java/security/Principal#implies(javax.security.auth.Subject))`(`[Subject](/reference/javax/security/auth/Subject)` subject) ` Returns true if the specified subject is implied by this principal. | | ` abstract `[String](/reference/java/lang/String) | ` `[toString](/reference/java/security/Principal#toString())`() ` Returns a string representation of this principal. | ||\n\nPublic methods\n--------------\n\n### addMember\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean addMember (Principal user)\n```\n\nAdds the specified member to the group.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|---------------------------------------------------------|\n| `user` | `Principal`: the principal to add to this group. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|------------------------------------------------------------------------------------------------|\n| `boolean` | true if the member was successfully added, false if the principal was already a member. \u003cbr /\u003e |\n\n### isMember\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean isMember (Principal member)\n```\n\nReturns true if the passed principal is a member of the group.\nThis method does a recursive search, so if a principal belongs to a\ngroup which is a member of this group, true is returned.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|----------------------------------------------------------------------|\n| `member` | `Principal`: the principal whose membership is to be checked. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------------------------------------------|\n| `boolean` | true if the principal is a member of this group, false otherwise. \u003cbr /\u003e |\n\n### members\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract Enumeration\u003c? extends Principal\u003e members ()\n```\n\nReturns an enumeration of the members in the group.\nThe returned objects can be instances of either Principal\nor Group (which is a subclass of Principal).\n\n\u003cbr /\u003e\n\n| Returns ||\n|----------------------------------------------------------------------------------------------------------------|---------------------------------------------|\n| [Enumeration](/reference/java/util/Enumeration)`\u003c? extends `[Principal](/reference/java/security/Principal)`\u003e` | an enumeration of the group members. \u003cbr /\u003e |\n\n### removeMember\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean removeMember (Principal user)\n```\n\nRemoves the specified member from the group.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|--------------------------------------------------------------|\n| `user` | `Principal`: the principal to remove from this group. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|---------------------------------------------------------------------------------------|\n| `boolean` | true if the principal was removed, or false if the principal was not a member. \u003cbr /\u003e |"]]