Package com.attivio.sdk.security
Class AttivioPrincipal
- java.lang.Object
- 
- com.attivio.sdk.security.AttivioPrincipal
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Cloneable,- java.lang.Comparable<AttivioPrincipal>,- java.security.Principal
 
 public class AttivioPrincipal extends java.lang.Object implements java.security.Principal, java.io.Serializable, java.lang.Comparable<AttivioPrincipal>, java.lang.Cloneable Represents a principal (a user or a group).
 
 A principal is characterized by three attributes:- realm ID - the ID of the security realm in which the principal is defined
- principal ID - the unique ID of the principal
- principal name - the name of the principal
 - See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classAttivioPrincipal.PrincipalTypeContains the possible principal types.
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringANONYMOUSConstant to signify anonymous (realm or user).static AttivioPrincipalANONYMOUS_USERRepresents the anonymous user (whose realm ID, principal ID, and principal name areANONYMOUS).static java.lang.StringANONYMOUS_USER_GUIDThe GUID of the anonymous user.protected java.util.UUIDcorrelationIdcorrelation id if setstatic java.lang.StringFIELD_PRINCIPAL_IDThe name of the field that stores the principal ID.static java.lang.StringFIELD_PRINCIPAL_NAMEThe name of the field that stores the principal name.static java.lang.StringFIELD_REALM_IDThe name of the field that stores the security realm ID.protected java.util.Set<AttivioGroupMembership>groupMembershipsAny group memberships of this principal.static java.lang.StringPARAMETER_PRINCIPAL_IDThe CGI parameter or query request property for the principal ID.static java.lang.StringPARAMETER_PRINCIPAL_NAMEThe CGI parameter or query request property for the principal name.static java.lang.StringPARAMETER_REALM_IDThe CGI parameter or query request property for the realm ID.static java.lang.StringPRIN_NAME_UNKNOWNThe constant for the 'unknown' principal name.protected java.lang.StringprincipalIdThe principal ID.protected java.lang.StringprincipalNameThe principal name.protected AttivioPrincipal.PrincipalTypeprincipalTypeThe principal type.protected BaseTypesMap<java.lang.String,java.lang.Object>propertiesAny additional properties.protected java.lang.StringrealmIdThe security realm ID.protected java.util.Set<AttivioRole>rolesOptional roles used by the Security Client API authorization.
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAttivioPrincipal()The default constructor.AttivioPrincipal(AttivioPrincipalKey principalKey, java.lang.String principalName, AttivioPrincipal.PrincipalType principalType)Constructs an Attivio principal from a principal key, name, and type.AttivioPrincipal(java.lang.String realmId, java.lang.String principalId, java.lang.String principalName, AttivioPrincipal.PrincipalType principalType)Creates an Attivio principal object from a realm ID, a principal ID, a principal name, and a principal type.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGroupMembership(AttivioGroupMembership groupMembership)Adds a group membership to the set of this principal's group memberships.voidaddRole(AttivioRole role)Add a role to the principal.AttivioPrincipalclone()intcompareTo(AttivioPrincipal other){inheritDoc}booleanequals(java.lang.Object obj){inheritDoc}static AttivioPrincipalfromPrincipalString(java.lang.String principalString)Creates an attivio principal from a principal string in the form of realmId:principalId:principalNamejava.util.UUIDgetCorrelationId()Get the correlation ID used to tie different instances of the same document sent in back to their original source.java.util.Set<AttivioGroupMembership>getGroupMemberships()java.lang.StringgetName()java.lang.StringgetPassword()java.lang.StringgetPrincipalId()AttivioPrincipalKeygetPrincipalKey()java.lang.StringgetPrincipalName()java.lang.StringgetPrincipalString()AttivioPrincipal.PrincipalTypegetPrincipalType()BaseTypesMap<java.lang.String,java.lang.Object>getProperties()java.lang.ObjectgetProperty(java.lang.String propName)java.lang.StringgetRealmId()java.util.Set<AttivioRole>getRoles()java.util.Set<AttivioRole>getRoles(java.lang.Enum<?> enumRole)Return allAttivioRoleobjects that have the same name as the givenEnum.java.util.Set<AttivioRole>getRoles(java.lang.String roleName)Return allAttivioRoleobjects that have the given role name.inthashCode(){inheritDoc}booleanhasRole(java.lang.Enum<?> enumRole)Equivalent to hasRule(enumRole, AttivioRole.SUBGROUP_ANY);booleanhasRole(java.lang.Enum<?> enumRole, java.lang.String subgroup)booleanhasRole(java.lang.String role)Equivalent to hasRule(role , AttivioRole.SUBGROUP_ANY);booleanhasRole(java.lang.String roleName, java.lang.String subgroup)booleanisAnonymous()static booleanisAnonymous(AttivioPrincipalKey prinKey)static booleanisAnonymous(java.lang.String realmId, java.lang.String principalId)booleanisGroup()booleanisUser()booleanremoveGroupMembership(AttivioGroupMembership groupMembership)Removes a group membership from the set of this principal's group memberships.voidsetCorrelationId(java.util.UUID correlationId)Set the correlation idvoidsetGroupMemberships(java.util.Set<AttivioGroupMembership> groupMemberships)Sets the group memberships for this principal.voidsetPassword(java.lang.String password)Set a password with this principalvoidsetPrincipalId(java.lang.String principalId)Sets the principal ID.voidsetPrincipalName(java.lang.String principalName)Sets the principal name.voidsetPrincipalType(AttivioPrincipal.PrincipalType principalType)Set the principal typevoidsetProperty(java.lang.String propName, java.lang.Object propValue)Sets a property on the principal.voidsetRealmId(java.lang.String realmId)Sets the realm ID.voidsetRoles(java.util.Set<AttivioRole> roles)Set roles for this principal.java.lang.StringtoString(){inheritDoc}
 
- 
- 
- 
Field Detail- 
PRIN_NAME_UNKNOWNpublic static final java.lang.String PRIN_NAME_UNKNOWN The constant for the 'unknown' principal name.- See Also:
- Constant Field Values
 
 - 
ANONYMOUSpublic static final java.lang.String ANONYMOUS Constant to signify anonymous (realm or user).- See Also:
- Constant Field Values
 
 - 
ANONYMOUS_USERpublic static final AttivioPrincipal ANONYMOUS_USER Represents the anonymous user (whose realm ID, principal ID, and principal name areANONYMOUS).
 - 
ANONYMOUS_USER_GUIDpublic static final java.lang.String ANONYMOUS_USER_GUID The GUID of the anonymous user.
 - 
FIELD_REALM_IDpublic static final java.lang.String FIELD_REALM_ID The name of the field that stores the security realm ID.- See Also:
- Constant Field Values
 
 - 
FIELD_PRINCIPAL_IDpublic static final java.lang.String FIELD_PRINCIPAL_ID The name of the field that stores the principal ID.- See Also:
- Constant Field Values
 
 - 
FIELD_PRINCIPAL_NAMEpublic static final java.lang.String FIELD_PRINCIPAL_NAME The name of the field that stores the principal name.- See Also:
- Constant Field Values
 
 - 
PARAMETER_REALM_IDpublic static final java.lang.String PARAMETER_REALM_ID The CGI parameter or query request property for the realm ID.- See Also:
- Constant Field Values
 
 - 
PARAMETER_PRINCIPAL_IDpublic static final java.lang.String PARAMETER_PRINCIPAL_ID The CGI parameter or query request property for the principal ID.- See Also:
- Constant Field Values
 
 - 
PARAMETER_PRINCIPAL_NAMEpublic static final java.lang.String PARAMETER_PRINCIPAL_NAME The CGI parameter or query request property for the principal name.- See Also:
- Constant Field Values
 
 - 
realmIdprotected java.lang.String realmId The security realm ID.
 - 
principalIdprotected java.lang.String principalId The principal ID.
 - 
principalNameprotected java.lang.String principalName The principal name.
 - 
principalTypeprotected AttivioPrincipal.PrincipalType principalType The principal type.
 - 
rolesprotected java.util.Set<AttivioRole> roles Optional roles used by the Security Client API authorization.
 - 
groupMembershipsprotected java.util.Set<AttivioGroupMembership> groupMemberships Any group memberships of this principal.
 - 
correlationIdprotected java.util.UUID correlationId correlation id if set
 - 
propertiesprotected BaseTypesMap<java.lang.String,java.lang.Object> properties Any additional properties.
 
- 
 - 
Constructor Detail- 
AttivioPrincipalprotected AttivioPrincipal() The default constructor.
 - 
AttivioPrincipalpublic AttivioPrincipal(java.lang.String realmId, java.lang.String principalId, java.lang.String principalName, AttivioPrincipal.PrincipalType principalType)Creates an Attivio principal object from a realm ID, a principal ID, a principal name, and a principal type.- Parameters:
- realmId- the security realm ID; may not be null or empty
- principalId- the principal ID; may not be null or empty
- principalName- the principal name; may be null or empty
- principalType- the principal type; may not be null or empty
 
 - 
AttivioPrincipalpublic AttivioPrincipal(AttivioPrincipalKey principalKey, java.lang.String principalName, AttivioPrincipal.PrincipalType principalType) Constructs an Attivio principal from a principal key, name, and type.- Parameters:
- principalKey- the principal key; may not be null
- principalName- the principal name; may be null or empty
- principalType- the principal type; may not be null or empty
 
 
- 
 - 
Method Detail- 
setRealmIdpublic void setRealmId(java.lang.String realmId) Sets the realm ID.- Parameters:
- realmId- the realm ID
 
 - 
getRealmIdpublic java.lang.String getRealmId() - Returns:
- the security realm ID
 
 - 
setPrincipalIdpublic void setPrincipalId(java.lang.String principalId) Sets the principal ID.- Parameters:
- principalId- the principal ID
 
 - 
getPrincipalIdpublic java.lang.String getPrincipalId() - Returns:
- the principal ID
 
 - 
getPrincipalKeypublic AttivioPrincipalKey getPrincipalKey() - Returns:
- the principal key
 
 - 
getPrincipalStringpublic java.lang.String getPrincipalString() - Returns:
- string in the form of realmId:principalId:principalName
 
 - 
fromPrincipalStringpublic static AttivioPrincipal fromPrincipalString(java.lang.String principalString) Creates an attivio principal from a principal string in the form of realmId:principalId:principalName- Parameters:
- principalString-
- Returns:
- the created principal
 
 - 
getNamepublic java.lang.String getName() - Specified by:
- getNamein interface- java.security.Principal
- Returns:
- the principal name; may be null or empty if not filled in
 
 - 
setPrincipalNamepublic void setPrincipalName(java.lang.String principalName) Sets the principal name.- Parameters:
- principalName- the principal name
 
 - 
getPrincipalNamepublic java.lang.String getPrincipalName() - Returns:
- the principal name; may be null or empty if not filled in
 
 - 
getPrincipalTypepublic AttivioPrincipal.PrincipalType getPrincipalType() - Returns:
- the principal type
 
 - 
setPrincipalTypepublic void setPrincipalType(AttivioPrincipal.PrincipalType principalType) Set the principal type- Parameters:
- principalType-
 
 - 
isAnonymouspublic boolean isAnonymous() - Returns:
- true if this principal represents the anonymous
 
 - 
isAnonymouspublic static boolean isAnonymous(java.lang.String realmId, java.lang.String principalId)- Parameters:
- realmId- the realm ID
- principalId- the principal ID
- Returns:
- true if the principal denoted by the realm ID and the principal ID is anonymous
 
 - 
isAnonymouspublic static boolean isAnonymous(AttivioPrincipalKey prinKey) - Parameters:
- prinKey- the principal key
- Returns:
- true if the principal denoted by the given key is anonymous
 
 - 
isUserpublic boolean isUser() - Returns:
- true if the principal represents a user
 
 - 
isGrouppublic boolean isGroup() - Returns:
- true if the principal represents a group
 
 - 
getRolespublic java.util.Set<AttivioRole> getRoles() - Returns:
- the roles
 
 - 
getRolespublic java.util.Set<AttivioRole> getRoles(java.lang.String roleName) Return allAttivioRoleobjects that have the given role name.- Parameters:
- roleName- the role name to match
- Returns:
- the matching roles
 
 - 
hasRolepublic boolean hasRole(java.lang.String roleName, java.lang.String subgroup)- Parameters:
- roleName- role name
- subgroup- subgroup id,resource id, or- AttivioRole.SUBGROUP_ANY
- Returns:
- true, if the principal has the given role/subgroup.
 
 - 
hasRolepublic boolean hasRole(java.lang.Enum<?> enumRole, java.lang.String subgroup)- Parameters:
- enumRole- enum used for roles
- subgroup- subgroup ID, resource ID, or- AttivioRole.SUBGROUP_ANY
- Returns:
- true, if the principal has the given role/subgroup.
 
 - 
hasRolepublic boolean hasRole(java.lang.Enum<?> enumRole) Equivalent to hasRule(enumRole, AttivioRole.SUBGROUP_ANY);- Parameters:
- enumRole- enum used for roles
- Returns:
- true, if the principal has the given role
 
 - 
hasRolepublic boolean hasRole(java.lang.String role) Equivalent to hasRule(role , AttivioRole.SUBGROUP_ANY);- Parameters:
- role- role name
- Returns:
- true, if the principal has the given role
 
 - 
getRolespublic java.util.Set<AttivioRole> getRoles(java.lang.Enum<?> enumRole) Return allAttivioRoleobjects that have the same name as the givenEnum.- Parameters:
- enumRole- enum used for roles
- Returns:
- matching roles
 
 - 
addRolepublic void addRole(AttivioRole role) Add a role to the principal.
 - 
setRolespublic void setRoles(java.util.Set<AttivioRole> roles) Set roles for this principal.- Parameters:
- roles- the roles to set
 
 - 
getGroupMembershipspublic java.util.Set<AttivioGroupMembership> getGroupMemberships() - Returns:
- the group memberships for this principal
 
 - 
setGroupMembershipspublic void setGroupMemberships(java.util.Set<AttivioGroupMembership> groupMemberships) Sets the group memberships for this principal.- Parameters:
- groupMemberships- the group memberships
 
 - 
addGroupMembershippublic void addGroupMembership(AttivioGroupMembership groupMembership) Adds a group membership to the set of this principal's group memberships.- Parameters:
- groupMembership- the group membership to add
 
 - 
removeGroupMembershippublic boolean removeGroupMembership(AttivioGroupMembership groupMembership) Removes a group membership from the set of this principal's group memberships.- Parameters:
- groupMembership- the group membership to remove
- Returns:
- true if the group membership was present and removed
 
 - 
getCorrelationIdpublic java.util.UUID getCorrelationId() Get the correlation ID used to tie different instances of the same document sent in back to their original source.- Returns:
- correlation id or null if not set
 
 - 
setCorrelationIdpublic void setCorrelationId(java.util.UUID correlationId) Set the correlation id- Parameters:
- correlationId-
 
 - 
setPropertypublic void setProperty(java.lang.String propName, java.lang.Object propValue)Sets a property on the principal.- Parameters:
- propName- the property name
- propValue- the property value
 
 - 
setPasswordpublic void setPassword(java.lang.String password) Set a password with this principal- Parameters:
- password-
 
 - 
getPasswordpublic java.lang.String getPassword() - Returns:
- null or a password if set on the principal
 
 - 
getPropertypublic java.lang.Object getProperty(java.lang.String propName) - Parameters:
- propName- the name of the property
- Returns:
- the property value
 
 - 
getPropertiespublic BaseTypesMap<java.lang.String,java.lang.Object> getProperties() 
 - 
hashCodepublic int hashCode() {inheritDoc}- Specified by:
- hashCodein interface- java.security.Principal
- Overrides:
- hashCodein class- java.lang.Object
 
 - 
equalspublic boolean equals(java.lang.Object obj) {inheritDoc}- Specified by:
- equalsin interface- java.security.Principal
- Overrides:
- equalsin class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() {inheritDoc}- Specified by:
- toStringin interface- java.security.Principal
- Overrides:
- toStringin class- java.lang.Object
 
 - 
compareTopublic int compareTo(AttivioPrincipal other) {inheritDoc}- Specified by:
- compareToin interface- java.lang.Comparable<AttivioPrincipal>
 
 - 
clonepublic AttivioPrincipal clone() - Overrides:
- clonein class- java.lang.Object
 
 
- 
 
-