Package org.apache.wiki.auth.acl
Class DefaultAclManager
- java.lang.Object
-
- org.apache.wiki.auth.acl.DefaultAclManager
-
- All Implemented Interfaces:
Initializable
,AclManager
public class DefaultAclManager extends java.lang.Object implements AclManager
Default implementation that parses Acls from wiki page markup.- Since:
- 2.3
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.regex.Pattern
ACL_PATTERN
Identifies ACL strings in wiki text; the first group is the action (view, edit) and the second is the list of Principals separated by commas.
-
Constructor Summary
Constructors Constructor Description DefaultAclManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Acl
getPermissions(Page page)
Returns the access control list for the page.void
initialize(Engine engine, java.util.Properties props)
Initializes this Engine component.Acl
parseAcl(Page page, java.lang.String ruleLine)
A helper method for parsing textual AccessControlLists.protected static java.lang.String
printAcl(Acl acl)
Generates an ACL string for inclusion in a wiki page, based on a supplied Acl object.void
setPermissions(Page page, Acl acl)
Sets the access control list for the page and persists it.
-
-
-
Field Detail
-
ACL_PATTERN
public static final java.util.regex.Pattern ACL_PATTERN
Identifies ACL strings in wiki text; the first group is the action (view, edit) and the second is the list of Principals separated by commas. The overall match is the ACL string from [{ to }].
-
-
Constructor Detail
-
DefaultAclManager
public DefaultAclManager()
-
-
Method Detail
-
initialize
public void initialize(Engine engine, java.util.Properties props)
Initializes this Engine component. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.
- Specified by:
initialize
in interfaceInitializable
- Parameters:
engine
- Engine performing the initialization.props
- Properties for setup.
-
parseAcl
public Acl parseAcl(Page page, java.lang.String ruleLine) throws WikiSecurityException
A helper method for parsing textual AccessControlLists. The line is in form "(ALLOW), , ". This method was moved from Authorizer. - Specified by:
parseAcl
in interfaceAclManager
- Parameters:
page
- The current wiki page. If the page already has an ACL, it will be used as a basis for this ACL in order to avoid the creation of a new one.ruleLine
- The rule line, as described above.- Returns:
- A valid Access Control List. May be empty.
- Throws:
WikiSecurityException
- if the ruleLine was faulty somehow.
-
getPermissions
public Acl getPermissions(Page page)
Returns the access control list for the page. If the ACL has not been parsed yet, it is done on-the-fly. If the page has a parent page, then that is tried also. This method was moved from Authorizer; it was consolidated with some code from AuthorizationManager.- Specified by:
getPermissions
in interfaceAclManager
- Parameters:
page
- the wiki page- Returns:
- the Acl representing permissions for the page
-
setPermissions
public void setPermissions(Page page, Acl acl) throws WikiSecurityException
Sets the access control list for the page and persists it.- Specified by:
setPermissions
in interfaceAclManager
- Parameters:
page
- the wiki pageacl
- the access control list- Throws:
WikiSecurityException
- if the ACL cannot be set or persisted
-
printAcl
protected static java.lang.String printAcl(Acl acl)
Generates an ACL string for inclusion in a wiki page, based on a supplied Acl object. All of the permissions in this Acl are assumed to apply to the same page scope. The names of the pages are ignored; only the actions and principals matter.- Parameters:
acl
- the ACL- Returns:
- the ACL string
-
-