Class PrivilegeHelper
java.lang.Object
edu.internet2.middleware.grouper.privs.PrivilegeHelper
Privilege helper class.
TODO 20070823 Relocate these methods once I figure out the best home for them.
- Since:
- 1.2.1
- Version:
- $Id: PrivilegeHelper.java,v 1.12 2009-09-28 05:06:46 mchyzer Exp $
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canAdmin
(GrouperSession s, Group g, Subject subj) static boolean
canAttrAdmin
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canAttrDefAttrRead
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canAttrDefAttrUpdate
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canAttrOptin
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canAttrOptout
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canAttrRead
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canAttrUpdate
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canAttrView
(GrouperSession s, AttributeDef attributeDef, Subject subj) static boolean
canCopyStems
(Subject subject) Is this user allowed to copy stems?static boolean
canCreate
(GrouperSession s, Stem ns, Subject subj) TODO 20070823 find a real home for this and/or add testsstatic boolean
canGroupAttrRead
(GrouperSession s, Group group, Subject subj) static boolean
canGroupAttrUpdate
(GrouperSession s, Group group, Subject subj) static boolean
canMoveStems
(Subject subject) Is this user allowed to move stems?static boolean
canOptin
(GrouperSession s, Group g, Subject subj) TODO 20070823 find a real home for this and/or add testsstatic boolean
canOptout
(GrouperSession s, Group g, Subject subj) TODO 20070823 find a real home for this and/or add testsstatic boolean
canRead
(GrouperSession s, Group g, Subject subj) TODO 20070823 find a real home for this and/or add testsstatic boolean
canRenameStems
(Subject subject) Is this user allowed to rename stems?static boolean
canStem
(GrouperSession s, Stem ns, Subject subj) TODO 20070823 find a real home for this and/or add testsstatic boolean
TODO 20070823 find a real home for this and/or add testsstatic boolean
canStemAdmin
(GrouperSession s, Stem ns, Subject subj) static boolean
canStemAdmin
(Stem ns, Subject subj) static boolean
canStemAttrRead
(GrouperSession s, Stem stem, Subject subj) static boolean
canStemAttrUpdate
(GrouperSession s, Stem stem, Subject subj) static boolean
canStemView
(GrouperSession s, Stem stem, Subject subj) static boolean
canUpdate
(GrouperSession s, Group g, Subject subj) TODO 20070823 find a real home for this and/or add testsstatic boolean
canView
(GrouperSession s, Group g, Subject subj) TODO 20070823 find a real home for this and/or add testsstatic boolean
canViewAttributeAssign
(GrouperSession grouperSession, AttributeAssign attributeAssign, boolean checkUnderlyingIfAssignmentOnAssignment) see if the attribute assigns are viewablestatic Set<AttributeAssign>
canViewAttributeAssigns
(GrouperSession grouperSession, Collection<AttributeAssign> inputAttributeAssigns, boolean checkUnderlyingIfAssignmentOnAssignment) see if the attribute assigns are viewablestatic Set<AttributeDef>
canViewAttributeDefs
(GrouperSession s, Collection<AttributeDef> inputAttributeDefs) TODO 20070823 find a real home for this and/or add testsstatic Set
canViewGroups
(GrouperSession s, Set candidates) TODO 20070823 find a real home for this and/or add testsstatic boolean
canViewMembers
(GrouperSession grouperSession, Group group, Field field) static boolean
canViewMembership
(GrouperSession grouperSession, Membership membership) static Set<Membership>
canViewMemberships
(GrouperSession grouperSession, Collection<Membership> inputMemberships) static Set<PermissionEntry>
canViewPermissions
(GrouperSession grouperSession, Collection<PermissionEntry> inputPermissionEntries) see if the attribute assigns are viewablestatic Set<PITAttributeAssign>
canViewPITAttributeAssigns
(GrouperSession grouperSession, Collection<PITAttributeAssign> inputPITAttributeAssigns, boolean checkUnderlyingIfAssignmentOnAssignment) see if the pit attribute assigns are viewablestatic void
dispatch
(GrouperSession s, AttributeDef attributeDef, Subject subj, Privilege priv) TODO 20070823 find a real home for this and/or add testsstatic void
dispatch
(GrouperSession s, Group g, Subject subj, Privilege priv) TODO 20070823 find a real home for this and/or add testsstatic void
dispatch
(GrouperSession s, Stem ns, Subject subj, Privilege priv) TODO 20070823 find a real home for this and/or add testsstatic Collection<String>
fieldIdsFromPrivileges
(Collection<Privilege> privileges) convert a collection of privileges to a collection of fieldIdsstatic void
flush all privilege cachesstatic Privilege[]
getAccessPrivileges
(Privilege[] privileges) TODO 20070824 add testsstatic Privilege[]
getAttributeDefPrivileges
(Privilege[] privileges) TODO 20070824 add testsstatic Privilege[]
getNamingPrivileges
(Privilege[] privileges) TODO 20070824 add testsstatic boolean
hasImmediatePrivilege
(AttributeDef attributeDef, Subject subject, Privilege privilege) see if an attributeDef has an immediate privilegestatic boolean
hasImmediatePrivilege
(Group group, Subject subject, Privilege privilege) see if a group has an immediate privilegestatic boolean
hasImmediatePrivilege
(Stem stem, Subject subject, Privilege privilege) see if a stem has an immediate privilegestatic boolean
hasPrivilege
(GrouperSession s, AttributeDef attributeDef, Subject subj, Set<Privilege> privInSet) static boolean
hasPrivilege
(GrouperSession s, Group g, Subject subj, Set<Privilege> privInSet) static boolean
hasPrivilege
(GrouperSession s, Stem stem, Subject subj, Set<Privilege> privInSet) static boolean
TODO 20070823 find a real home for this and/or add testsstatic boolean
isSystemSubject
(Subject subject) see if system subjectstatic boolean
TODO 20070823 find a real home for this and/or add testsstatic boolean
isWheelOrRoot
(Subject subject) see if a subject is wheel or rootstatic boolean
isWheelOrRootOrReadonlyRoot
(Subject subject) see if a subject is wheel or root or readonly rootstatic boolean
isWheelOrRootOrViewonlyRoot
(Subject subject) see if a subject is wheel or root or viewonly root (or readonly)static void
static void
resolveSubjects
(Collection<GrouperPrivilege> grouperPrivileges, boolean resolveAllAlways) resolve subjects in one batchstatic void
clear cache on this jvm when adjusting wheel members
-
Constructor Details
-
PrivilegeHelper
public PrivilegeHelper()
-
-
Method Details
-
main
-
fieldIdsFromPrivileges
convert a collection of privileges to a collection of fieldIds- Parameters:
privileges
-- Returns:
- the field
-
hasImmediatePrivilege
see if a group has an immediate privilege- Parameters:
group
-subject
-privilege
-- Returns:
- true if has immediate privilege, false if not
-
flushCache
public static void flushCache()flush all privilege caches -
resolveSubjects
public static void resolveSubjects(Collection<GrouperPrivilege> grouperPrivileges, boolean resolveAllAlways) resolve subjects in one batch- Parameters:
grouperPrivileges
-resolveAllAlways
- true to always resolve all no matter how many, false if there are more than 2000 or however many (e.g. for UI)
-
canAdmin
- Parameters:
s
-g
-subj
-- Returns:
- admin
- Since:
- 1.2.1
-
canAttrAdmin
- Parameters:
s
-attributeDef
-subj
-- Returns:
- admin
-
canAttrRead
- Parameters:
s
-attributeDef
-subj
-- Returns:
- admin
-
canAttrView
- Parameters:
s
-attributeDef
-subj
-- Returns:
- admin
-
canGroupAttrRead
- Parameters:
s
-group
-subj
-- Returns:
- true if allowed
-
canGroupAttrUpdate
- Parameters:
s
-group
-subj
-- Returns:
- true if allowed
-
canAttrDefAttrRead
- Parameters:
s
-attributeDef
-subj
-- Returns:
- true if allowed
-
canAttrDefAttrUpdate
public static boolean canAttrDefAttrUpdate(GrouperSession s, AttributeDef attributeDef, Subject subj) - Parameters:
s
-attributeDef
-subj
-- Returns:
- true if allowed
-
canStemAttrRead
- Parameters:
s
-stem
-subj
-- Returns:
- true if allowed
-
canStemView
- Parameters:
s
-stem
-subj
-- Returns:
- true if allowed
-
canStemAttrUpdate
- Parameters:
s
-stem
-subj
-- Returns:
- true if allowed
-
canAttrUpdate
- Parameters:
s
-attributeDef
-subj
-- Returns:
- admin
-
canAttrOptin
- Parameters:
s
-attributeDef
-subj
-- Returns:
- admin
-
canAttrOptout
- Parameters:
s
-attributeDef
-subj
-- Returns:
- admin
-
canCreate
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-ns
-subj
-- Returns:
- can create
- Since:
- 1.2.1
-
canOptin
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-g
-subj
-- Returns:
- can
- Since:
- 1.2.1
-
hasPrivilege
public static boolean hasPrivilege(GrouperSession s, Stem stem, Subject subj, Set<Privilege> privInSet) - Parameters:
s
-stem
-subj
-privInSet
-- Returns:
- if has privilege
-
hasPrivilege
public static boolean hasPrivilege(GrouperSession s, Group g, Subject subj, Set<Privilege> privInSet) - Parameters:
s
-g
-subj
-privInSet
-- Returns:
- if has privilege
-
canOptout
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-g
-subj
-- Returns:
- can optout
- Since:
- 1.2.1
-
canRead
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-g
-subj
-- Returns:
- can read
- Since:
- 1.2.1
-
canStem
TODO 20070823 find a real home for this and/or add tests- Parameters:
ns
-subj
-- Returns:
- can stem
- Since:
- 1.2.1
-
canStemAdmin
- Parameters:
ns
-subj
-- Returns:
- can stem admin
-
canStem
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-ns
-subj
-- Returns:
- can stem
- Since:
- 1.2.1
-
canStemAdmin
- Parameters:
s
-ns
-subj
-- Returns:
- can stem admin
-
canUpdate
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-g
-subj
-- Returns:
- can update
- Since:
- 1.2.1
-
canView
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-g
-subj
-- Returns:
- can view
- Since:
- 1.2.1
-
canViewGroups
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-candidates
-- Returns:
- can view
- Since:
- 1.2.1
-
canViewMembership
- Parameters:
grouperSession
-membership
-- Returns:
- true if ok, false if not
-
canViewMemberships
public static Set<Membership> canViewMemberships(GrouperSession grouperSession, Collection<Membership> inputMemberships) - Parameters:
grouperSession
-inputMemberships
-- Returns:
- filtered memberships
-
canViewMembers
- Parameters:
grouperSession
-group
-field
-- Returns:
- true or false
-
dispatch
public static void dispatch(GrouperSession s, Group g, Subject subj, Privilege priv) throws InsufficientPrivilegeException, SchemaException TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-g
-subj
-priv
-- Throws:
InsufficientPrivilegeException
SchemaException
-
dispatch
public static void dispatch(GrouperSession s, Stem ns, Subject subj, Privilege priv) throws InsufficientPrivilegeException, SchemaException TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-ns
-subj
-priv
-- Throws:
InsufficientPrivilegeException
SchemaException
-
dispatch
public static void dispatch(GrouperSession s, AttributeDef attributeDef, Subject subj, Privilege priv) throws InsufficientPrivilegeException, SchemaException TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-attributeDef
-subj
-priv
-- Throws:
InsufficientPrivilegeException
SchemaException
-
getAccessPrivileges
TODO 20070824 add tests- Parameters:
privileges
-- Returns:
- Given an array of privileges return an array of access privileges.
- Since:
- 1.2.1
-
getAttributeDefPrivileges
TODO 20070824 add tests- Parameters:
privileges
-- Returns:
- Given an array of privileges return an array of access privileges.
- Since:
- 1.2.1
-
getNamingPrivileges
TODO 20070824 add tests- Parameters:
privileges
-- Returns:
- Given an array of privileges return an array of naming privileges.
- Since:
- 1.2.1
-
isRoot
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-- Returns:
- is root
-
isSystemSubject
see if system subject- Parameters:
subject
-- Returns:
- true if grouper system
-
isWheel
TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-- Returns:
- is wheel
-
isWheelOrRootOrViewonlyRoot
see if a subject is wheel or root or viewonly root (or readonly)- Parameters:
subject
-- Returns:
- true or false
-
isWheelOrRootOrReadonlyRoot
see if a subject is wheel or root or readonly root- Parameters:
subject
-- Returns:
- true or false
-
wheelMemberCacheClear
public static void wheelMemberCacheClear()clear cache on this jvm when adjusting wheel members -
isWheelOrRoot
see if a subject is wheel or root- Parameters:
subject
-- Returns:
- true or false
-
canMoveStems
Is this user allowed to move stems?- Parameters:
subject
-- Returns:
- boolean
-
canCopyStems
Is this user allowed to copy stems?- Parameters:
subject
-- Returns:
- boolean
-
canRenameStems
Is this user allowed to rename stems?- Parameters:
subject
-- Returns:
- boolean
-
hasPrivilege
public static boolean hasPrivilege(GrouperSession s, AttributeDef attributeDef, Subject subj, Set<Privilege> privInSet) - Parameters:
s
-attributeDef
-subj
-privInSet
-- Returns:
- if has privilege
-
canViewAttributeDefs
public static Set<AttributeDef> canViewAttributeDefs(GrouperSession s, Collection<AttributeDef> inputAttributeDefs) TODO 20070823 find a real home for this and/or add tests- Parameters:
s
-inputAttributeDefs
-- Returns:
- filtered attributeDefs
-
canViewAttributeAssign
public static boolean canViewAttributeAssign(GrouperSession grouperSession, AttributeAssign attributeAssign, boolean checkUnderlyingIfAssignmentOnAssignment) see if the attribute assigns are viewable- Parameters:
grouperSession
-attributeAssign
-checkUnderlyingIfAssignmentOnAssignment
- if deep security check should take place on underlying assignments- Returns:
- filtered memberships
-
canViewAttributeAssigns
public static Set<AttributeAssign> canViewAttributeAssigns(GrouperSession grouperSession, Collection<AttributeAssign> inputAttributeAssigns, boolean checkUnderlyingIfAssignmentOnAssignment) see if the attribute assigns are viewable- Parameters:
grouperSession
-inputAttributeAssigns
-checkUnderlyingIfAssignmentOnAssignment
- if deep security check should take place on underlying assignments- Returns:
- filtered memberships
-
canViewPermissions
public static Set<PermissionEntry> canViewPermissions(GrouperSession grouperSession, Collection<PermissionEntry> inputPermissionEntries) see if the attribute assigns are viewable- Parameters:
grouperSession
-inputPermissionEntries
-- Returns:
- filtered memberships
-
canViewPITAttributeAssigns
public static Set<PITAttributeAssign> canViewPITAttributeAssigns(GrouperSession grouperSession, Collection<PITAttributeAssign> inputPITAttributeAssigns, boolean checkUnderlyingIfAssignmentOnAssignment) see if the pit attribute assigns are viewable- Parameters:
grouperSession
-inputPITAttributeAssigns
-checkUnderlyingIfAssignmentOnAssignment
- if deep security check should take place on underlying assignments- Returns:
- filtered pit attribute assignments
-
hasImmediatePrivilege
see if a stem has an immediate privilege- Parameters:
stem
-subject
-privilege
-- Returns:
- true if has immediate privilege, false if not
-
hasImmediatePrivilege
public static boolean hasImmediatePrivilege(AttributeDef attributeDef, Subject subject, Privilege privilege) see if an attributeDef has an immediate privilege- Parameters:
attributeDef
-subject
-privilege
-- Returns:
- true if has immediate privilege, false if not
-