Class AuthorizationEntity
java.lang.Object
org.opengrok.indexer.authorization.AuthorizationEntity
- All Implemented Interfaces:
Serializable
,Cloneable
,Nameable
- Direct Known Subclasses:
AuthorizationStack
public abstract class AuthorizationEntity
extends Object
implements Nameable, Serializable, Cloneable
This class covers authorization entities used in opengrok.
Currently there are two:
- stack of plugins
- plugin
- name
- role - sufficient/required/requisite
- state - working/failed
- setup - from configuration
- Author:
- Krystof Tulinger
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Predicate specialized for the the plugin decisions.static class
Predicate specialized for the entity skipping decisions. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AuthorizationEntity
(AuthControlFlag flag, String name) protected
Copy constructor for the entity. -
Method Summary
Modifier and TypeMethodDescriptionabstract AuthorizationEntity
clone()
Perform a deep copy of the entity.protected String
colorToString
(String colorElement) Print the color element for this entity.Get the value offorGroups
.Get the value offorProjects
.Get the value of current setup.getFlag()
Get the value offlag
.Get the value offorGroups
.Get the value offorProjects
.getName()
Get the value ofname
.getSetup()
Get the value ofsetup
.Print the entity hierarchy.abstract String
hierarchyToString
(String prefix, String colorElement) Print the entity hierarchy.protected String
infoToString
(String prefix) Print the basic information about this entity.abstract boolean
isAllowed
(Nameable entity, AuthorizationEntity.PluginDecisionPredicate pluginPredicate, AuthorizationEntity.PluginSkippingPredicate skippingPredicate) Test the given entity if it should be allowed with this authorization check.boolean
isFailed()
Check if this plugin has failed during loading or is missing.boolean
Check if this plugin is marked as optional.boolean
Check if this plugin is marked as required.boolean
Check if this plugin is marked as requisite.boolean
Check if this plugin is marked as sufficient.boolean
Check if the plugin exists and has not failed while loading.abstract void
Load this entity with given parameters.protected void
Discover all targeted groups and projects for every group given byforGroups()
.void
setCurrentSetup
(Map<String, Object> currentSetup) Set the value of current setup.void
Set this plugin as failed.void
Set the value offlag
.void
setFlag
(AuthControlFlag flag) Set the value offlag
.void
setForGroups
(String group) Set the value offorGroups
.void
setForGroups
(String[] groups) Set the value offorGroups
.void
setForGroups
(Set<String> forGroups) Set the value offorGroups
.void
setForProjects
(String project) Set the value offorProjects
.void
setForProjects
(String[] projects) Set the value offorProjects
.void
setForProjects
(Set<String> forProjects) Set the value offorProjects
.void
Set the value ofname
.abstract boolean
setPlugin
(IAuthorizationPlugin plugin) Set the plugin to all classes which requires this class in the configuration.void
Set the value ofsetup
.protected String
setupToString
(String prefix) Print the setup into a string.void
Mark this entity as working.protected String
targetsToString
(String prefix) Print the targets for groups and projects into a string.abstract void
unload()
Unload this entity.
-
Field Details
-
flag
One of "required", "requisite", "sufficient". -
name
-
setup
-
currentSetup
Hold current setup - merged with all ancestor's stacks. -
working
protected transient boolean working
-
-
Constructor Details
-
AuthorizationEntity
protected AuthorizationEntity() -
AuthorizationEntity
Copy constructor for the entity.- copy flag
- copy name
- deep copy of the setup
- copy the working attribute
- Parameters:
x
- the entity to be copied
-
AuthorizationEntity
-
-
Method Details
-
load
Load this entity with given parameters.- Parameters:
parameters
- given parameters passed to the plugin's load method- See Also:
-
unload
public abstract void unload()Unload this entity.- See Also:
-
isAllowed
public abstract boolean isAllowed(Nameable entity, AuthorizationEntity.PluginDecisionPredicate pluginPredicate, AuthorizationEntity.PluginSkippingPredicate skippingPredicate) Test the given entity if it should be allowed with this authorization check.- Parameters:
entity
- the given entity - this is either group or project and is passed just for the logging purposes.pluginPredicate
- predicate returning true or false for the given entity which determines if the authorization for such entity is successful or failedskippingPredicate
- predicate returning true if this authorization entity should be omitted from the authorization process- Returns:
- true if successful; false otherwise
-
setPlugin
Set the plugin to all classes which requires this class in the configuration. This creates a new instance of the plugin for each class which needs it.- Parameters:
plugin
- the new instance of a plugin- Returns:
- true if there is such case; false otherwise
-
clone
Perform a deep copy of the entity. -
hierarchyToString
Print the entity hierarchy.- Parameters:
prefix
- this prefix should be prepended to every line produced by this entitycolorElement
- a possible element where any occurrence of %color% will be replaced with a HTML HEX color representing this entity state.- Returns:
- the string containing this entity representation
-
getFlag
Get the value offlag
.- Returns:
- the value of flag
-
setFlag
Set the value offlag
.- Parameters:
flag
- new value of flag
-
setFlag
Set the value offlag
.- Parameters:
flag
- new value of flag
-
getName
Get the value ofname
. -
setName
Set the value ofname
. -
getSetup
Get the value ofsetup
.- Returns:
- the value of setup
-
setSetup
Set the value ofsetup
.- Parameters:
setup
- new value of setup
-
getCurrentSetup
Get the value of current setup.- Returns:
- the value of current setup
-
setCurrentSetup
Set the value of current setup.- Parameters:
currentSetup
- new value of current setup
-
forProjects
Get the value offorProjects
.- Returns:
- the value of forProjects
-
getForProjects
Get the value offorProjects
.- Returns:
- the value of forProjects
-
setForProjects
Set the value offorProjects
.- Parameters:
forProjects
- new value of forProjects
-
setForProjects
Set the value offorProjects
.- Parameters:
project
- add this project into the set
-
setForProjects
Set the value offorProjects
.- Parameters:
projects
- add all projects in this array into the set- See Also:
-
forGroups
Get the value offorGroups
.- Returns:
- the value of forGroups
-
getForGroups
Get the value offorGroups
.- Returns:
- the value of forGroups
-
setForGroups
Set the value offorGroups
.- Parameters:
forGroups
- new value of forGroups
-
setForGroups
Set the value offorGroups
.- Parameters:
group
- add this group into the set
-
setForGroups
Set the value offorGroups
.- Parameters:
groups
- add all groups in this array into the set- See Also:
-
processTargetGroupsAndProjects
protected void processTargetGroupsAndProjects()Discover all targeted groups and projects for every group given byforGroups()
.- add to the
forGroups()
all groups which are descendant groups to the group - add to the
forGroups()
all groups which are parent groups to the group - add to the
forProjects()
all projects and repositories which are in the descendant groups or in the group itself - issue a warning for non-existent groups
- issue a warning for non-existent projects
- add to the
-
isWorking
public boolean isWorking()Check if the plugin exists and has not failed while loading.- Returns:
- true if working, false otherwise
-
setWorking
public void setWorking()Mark this entity as working. -
isFailed
public boolean isFailed()Check if this plugin has failed during loading or is missing. This method has the same effect as !isWorking()
.- Returns:
- true if failed, true otherwise
- See Also:
-
setFailed
public void setFailed()Set this plugin as failed. This plugin will no more call the underlying plugin isAllowed methods.- See Also:
-
isRequired
public boolean isRequired()Check if this plugin is marked as required.- Returns:
- true if is required; false otherwise
-
isSufficient
public boolean isSufficient()Check if this plugin is marked as sufficient.- Returns:
- true if is sufficient; false otherwise
-
isRequisite
public boolean isRequisite()Check if this plugin is marked as requisite.- Returns:
- true if is requisite; false otherwise
-
isOptional
public boolean isOptional()Check if this plugin is marked as optional.- Returns:
- true if is optional; false otherwise
-
hierarchyToString
Print the entity hierarchy.- Returns:
- the string containing this entity representation
-
colorToString
Print the color element for this entity. Replace all occurrences of %color% in the input string by the current state color in the HTML HEX format.- Parameters:
colorElement
- the string, possibly an HTML element, describing the color (can use %color%) to inject the true color of this entity state.- Returns:
- the color element with filled color
-
infoToString
Print the basic information about this entity.- Parameters:
prefix
- prepend this value to each line produced- Returns:
- the string containing the information.
-
setupToString
Print the setup into a string.- Parameters:
prefix
- prepend this value to each line produced- Returns:
- the string representing the entity setup
-
targetsToString
Print the targets for groups and projects into a string.- Parameters:
prefix
- prepend this value to each line produced- Returns:
- the string representing targeted the groups and projects
-