Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A31DB200C51 for ; Sat, 25 Mar 2017 16:53:10 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A1B6F160B96; Sat, 25 Mar 2017 15:53:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4845C160BA6 for ; Sat, 25 Mar 2017 16:53:07 +0100 (CET) Received: (qmail 49559 invoked by uid 500); 25 Mar 2017 15:53:06 -0000 Mailing-List: contact commits-help@jspwiki.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jspwiki.apache.org Delivered-To: mailing list commits@jspwiki.apache.org Received: (qmail 49177 invoked by uid 99); 25 Mar 2017 15:53:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Mar 2017 15:53:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1EF02DFE7B; Sat, 25 Mar 2017 15:53:06 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: juanpablo@apache.org To: commits@jspwiki.apache.org Date: Sat, 25 Mar 2017 15:53:22 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [18/51] [abbrv] [partial] jspwiki-site git commit: first take at generating content archived-at: Sat, 25 Mar 2017 15:53:10 -0000 http://git-wip-us.apache.org/repos/asf/jspwiki-site/blob/7f9ce779/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.html ---------------------------------------------------------------------- diff --git a/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.html b/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.html new file mode 100755 index 0000000..fecf360 --- /dev/null +++ b/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.html @@ -0,0 +1,848 @@ + + + + + + + +AuthorizationManager (Apache JSPWiki Main War 2.10.1 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.apache.wiki.auth +
+Class AuthorizationManager

+
+java.lang.Object
+  extended by org.apache.wiki.auth.AuthorizationManager
+
+
+
+
public class AuthorizationManager
extends Object
+ + + + + +
+ +

+

Manages all access control and authorization; determines what authenticated + users are allowed to do.

+

Privileges in JSPWiki are expressed as Java-standard Permission + classes. There are two types of permissions:

+
    +
  • WikiPermission - privileges that apply + to an entire wiki instance: e.g., editing user profiles, creating pages, creating groups
  • +
  • PagePermission - privileges that apply + to a single wiki page or range of pages: e.g., reading, editing, renaming +
+

Calling classes determine whether they are entitled to perform a particular action + by constructing the appropriate permission first, then passing it and the current + WikiSession to the + checkPermission(WikiSession, Permission) method. If the session's + Subject possesses the permission, the action is allowed.

+

For WikiPermissions, the decision criteria is relatively simple: the caller either + possesses the permission, as granted by the wiki security policy -- or not.

+

For PagePermissions, the logic is exactly the same if the page being checked + does not have an access control list. However, if the page does have an ACL, the + authorization decision is made based the union of the permissions + granted in the ACL and in the security policy. In other words, the user must + be named in the ACL (or belong to a group or role that is named in the ACL) + and be granted (at least) the same permission in the security policy. We + do this to prevent a user from gaining more permissions than they already + have, based on the security policy.

+

See the checkPermission(WikiSession, Permission) and + hasRoleOrPrincipal(WikiSession, Principal) methods for more information + on the authorization logic.

+

+ +

+

+
Since:
+
2.3
+
See Also:
AuthenticationManager
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static StringDEFAULT_AUTHORIZER + +
+          The default external Authorizer is the WebContainerAuthorizer
+protected static StringDEFAULT_POLICY + +
+          Name of the default security policy file, in WEB-INF.
+protected static StringPOLICY + +
+          Property that supplies the security policy file name, in WEB-INF.
+static StringPROP_AUTHORIZER + +
+          The property name in jspwiki.properties for specifying the external Authorizer.
+  + + + + + + + + + + +
+Constructor Summary
AuthorizationManager() + +
+          Constructs a new AuthorizationManager instance.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddWikiEventListener(WikiEventListener listener) + +
+          Registers a WikiEventListener with this instance.
+protected  booleanallowedByLocalPolicy(Principal[] principals, + Permission permission) + +
+          Checks to see if the local security policy allows a particular static Permission.
+ booleancheckPermission(WikiSession session, + Permission permission) + +
+          Returns true or false, depending on + whether a Permission is allowed for the Subject associated with + a supplied WikiSession.
+protected  booleancheckStaticPermission(WikiSession session, + Permission permission) + +
+          Determines whether a Subject possesses a given "static" Permission as + defined in the security policy file.
+protected  voidfireEvent(int type, + Principal user, + Object permission) + +
+          Fires a WikiSecurityEvent of the provided type, user, + and permission to all registered listeners.
+ AuthorizergetAuthorizer() + +
+          Returns the current external Authorizer in use.
+ booleanhasAccess(WikiContext context, + javax.servlet.http.HttpServletResponse response) + +
+          Checks whether the current user has access to the wiki context, + by obtaining the required Permission (WikiContext.requiredPermission()) + and delegating the access check to checkPermission(WikiSession, Permission).
+ booleanhasAccess(WikiContext context, + javax.servlet.http.HttpServletResponse response, + boolean redirect) + +
+          Checks whether the current user has access to the wiki context (and + optionally redirects if not), by obtaining the required Permission (WikiContext.requiredPermission()) + and delegating the access check to checkPermission(WikiSession, Permission).
+protected  booleanhasRoleOrPrincipal(WikiSession session, + Principal principal) + +
+          Determines if the Subject associated with a supplied WikiSession contains + a desired user Principal or built-in Role principal, OR is a member a + Group or external Role.
+ voidinitialize(WikiEngine engine, + Properties properties) + +
+          Initializes AuthorizationManager with an engine and set of properties.
+protected  booleanisJAASAuthorized() + +
+          Returns true if JSPWiki's JAAS authorization system + is used for authorization in addition to container controls.
+ booleanisUserInRole(WikiSession session, + Principal principal) + +
+          Determines if the Subject associated with a + supplied WikiSession contains a desired Role or GroupPrincipal.
+ voidremoveWikiEventListener(WikiEventListener listener) + +
+          Un-registers a WikiEventListener with this instance.
+ PrincipalresolvePrincipal(String name) + +
+          Given a supplied string representing a Principal's name from an Acl, this + method resolves the correct type of Principal (role, group, or user).
+ + + + + + + +
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+DEFAULT_AUTHORIZER

+
+public static final String DEFAULT_AUTHORIZER
+
+
The default external Authorizer is the WebContainerAuthorizer +

+

+
See Also:
Constant Field Values
+
+
+ +

+POLICY

+
+protected static final String POLICY
+
+
Property that supplies the security policy file name, in WEB-INF. +

+

+
See Also:
Constant Field Values
+
+
+ +

+DEFAULT_POLICY

+
+protected static final String DEFAULT_POLICY
+
+
Name of the default security policy file, in WEB-INF. +

+

+
See Also:
Constant Field Values
+
+
+ +

+PROP_AUTHORIZER

+
+public static final String PROP_AUTHORIZER
+
+
The property name in jspwiki.properties for specifying the external Authorizer. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+AuthorizationManager

+
+public AuthorizationManager()
+
+
Constructs a new AuthorizationManager instance. +

+

+ + + + + + + + +
+Method Detail
+ +

+checkPermission

+
+public boolean checkPermission(WikiSession session,
+                               Permission permission)
+
+
Returns true or false, depending on + whether a Permission is allowed for the Subject associated with + a supplied WikiSession. The access control algorithm works this way: +
    +
  1. The Acl for the page is obtained
  2. +
  3. The Subject associated with the current + WikiSession is obtained
  4. +
  5. If the Subject's Principal set includes the Role Principal that is + the administrator group, always allow the Permission
  6. +
  7. For all permissions, check to see if the Permission is allowed according + to the default security policy. If it isn't, deny the permission and halt + further processing.
  8. +
  9. If there is an Acl, get the list of Principals assigned this + Permission in the Acl: these will be role, group or user Principals, or + UnresolvedPrincipals (see below). + Then iterate through the Subject's Principal set and determine whether + the user (Subject) possesses any one of these specified Roles or + Principals. The matching process delegates to + hasRoleOrPrincipal(WikiSession, Principal). +
+

+ Note that when iterating through the Acl's list of authorized Principals, + it is possible that one or more of the Acl's Principal entries are of + type UnresolvedPrincipal. This means that the last time + the ACL was read, the Principal (user, built-in Role, authorizer Role, or + wiki Group) could not be resolved: the Role was not valid, the user + wasn't found in the UserDatabase, or the Group wasn't known to (e.g., + cached) in the GroupManager. If an UnresolvedPrincipal is + encountered, this method will attempt to resolve it first before + checking to see if the Subject possesses this principal, by calling + resolvePrincipal(String). If the (re-)resolution does not + succeed, the access check for the principal will fail by definition (the + Subject should never contain UnresolvedPrincipals). +

+

+ If security not set to JAAS, will return true. +

+

+

+
Parameters:
session - the current wiki session
permission - the Permission being checked +
Returns:
the result of the Permission check
See Also:
hasRoleOrPrincipal(WikiSession, Principal)
+
+
+
+ +

+isUserInRole

+
+public boolean isUserInRole(WikiSession session,
+                            Principal principal)
+
+

Determines if the Subject associated with a + supplied WikiSession contains a desired Role or GroupPrincipal. + The algorithm simply checks to see if the Subject possesses + the Role or GroupPrincipal it in its Principal set. Note that + any user (anonymous, asserted, authenticated) can possess + a built-in role. But a user must be authenticated to + possess a role other than one of the built-in ones. + We do this to prevent privilege escalation.

+

For all other cases, this method returns false.

+

Note that this method does not consult the external + Authorizer or GroupManager; it relies on the Principals that + have been injected into the user's Subject at login time, or + after group creation/modification/deletion.

+

+

+
Parameters:
session - the current wiki session, which must be non-null. If null, + the result of this method always returns false
principal - the Principal (role or group principal) to look + for, which must be non-null. If null, + the result of this method always returns false +
Returns:
true if the Subject supplied with the WikiContext + posesses the Role or GroupPrincipal, false otherwise
+
+
+
+ +

+getAuthorizer

+
+public Authorizer getAuthorizer()
+                         throws WikiSecurityException
+
+
Returns the current external Authorizer in use. This method + is guaranteed to return a properly-initialized Authorizer, unless + it could not be initialized. In that case, this method throws + a WikiSecurityException. +

+

+ +
Returns:
the current Authorizer +
Throws: +
WikiSecurityException - if the Authorizer could + not be initialized
+
+
+
+ +

+hasRoleOrPrincipal

+
+protected boolean hasRoleOrPrincipal(WikiSession session,
+                                     Principal principal)
+
+

Determines if the Subject associated with a supplied WikiSession contains + a desired user Principal or built-in Role principal, OR is a member a + Group or external Role. The rules are as follows:

+
    +
  1. First, if desired Principal is a Role or GroupPrincipal, delegate to + isUserInRole(WikiSession, Principal) and + return the result.
  2. +
  3. Otherwise, we're looking for a user Principal, + so iterate through the Principal set and see if + any share the same name as the one we are looking for.
  4. +
+

Note: if the Principal parameter is a user principal, the session + must be authenticated in order for the user to "possess it". Anonymous + or asserted sessions will never posseess a named user principal.

+

+

+
Parameters:
session - the current wiki session, which must be non-null. If null, + the result of this method always returns false
principal - the Principal (role, group, or user principal) to look + for, which must be non-null. If null, the result of this + method always returns false +
Returns:
true if the Subject supplied with the WikiContext + posesses the Role, GroupPrincipal or desired + user Principal, false otherwise
+
+
+
+ +

+hasAccess

+
+public boolean hasAccess(WikiContext context,
+                         javax.servlet.http.HttpServletResponse response)
+                  throws IOException
+
+
Checks whether the current user has access to the wiki context, + by obtaining the required Permission (WikiContext.requiredPermission()) + and delegating the access check to checkPermission(WikiSession, Permission). + If the user is allowed, this method returns true; + false otherwise. If access is allowed, + the wiki context will be added to the request as an attribute + with the key name WikiTagBase.ATTR_CONTEXT. + Note that this method will automatically redirect the user to + a login or error page, as appropriate, if access fails. This is + NOT guaranteed to be default behavior in the future. +

+

+
Parameters:
context - wiki context to check if it is accesible
response - the http response +
Returns:
the result of the access check +
Throws: +
IOException - In case something goes wrong
+
+
+
+ +

+hasAccess

+
+public boolean hasAccess(WikiContext context,
+                         javax.servlet.http.HttpServletResponse response,
+                         boolean redirect)
+                  throws IOException
+
+
Checks whether the current user has access to the wiki context (and + optionally redirects if not), by obtaining the required Permission (WikiContext.requiredPermission()) + and delegating the access check to checkPermission(WikiSession, Permission). + If the user is allowed, this method returns true; + false otherwise. If access is allowed, + the wiki context will be added to the request as attribute + with the key name WikiTagBase.ATTR_CONTEXT. +

+

+
Parameters:
context - wiki context to check if it is accesible
response - The servlet response object
redirect - If true, makes an automatic redirect to the response +
Returns:
the result of the access check +
Throws: +
IOException - If something goes wrong
+
+
+
+ +

+initialize

+
+public void initialize(WikiEngine engine,
+                       Properties properties)
+                throws WikiException
+
+
Initializes AuthorizationManager with an engine and set of properties. + Expects to find property 'jspwiki.authorizer' with a valid Authorizer + implementation name to take care of role lookup operations. +

+

+
Parameters:
engine - the wiki engine
properties - the set of properties used to initialize the wiki engine +
Throws: +
WikiException - if the AuthorizationManager cannot be initialized
+
+
+
+ +

+isJAASAuthorized

+
+protected boolean isJAASAuthorized()
+
+
Returns true if JSPWiki's JAAS authorization system + is used for authorization in addition to container controls. +

+

+ +
Returns:
the result
+
+
+
+ +

+allowedByLocalPolicy

+
+protected boolean allowedByLocalPolicy(Principal[] principals,
+                                       Permission permission)
+
+
Checks to see if the local security policy allows a particular static Permission. + Do not use this method for normal permission checks; use + checkPermission(WikiSession, Permission) instead. +

+

+
Parameters:
principals - the Principals to check
permission - the Permission +
Returns:
the result
+
+
+
+ +

+checkStaticPermission

+
+protected boolean checkStaticPermission(WikiSession session,
+                                        Permission permission)
+
+
Determines whether a Subject possesses a given "static" Permission as + defined in the security policy file. This method uses standard Java 2 + security calls to do its work. Note that the current access control + context's codeBase is effectively this class, + not that of the caller. Therefore, this method will work best when what + matters in the policy is who makes the permission check, not + what the caller's code source is. Internally, this method works by + executing Subject.doAsPrivileged with a privileged action + that simply calls AccessController.checkPermission(Permission). +

+

+
Parameters:
session - the WikiSession whose permission status is being queried
permission - the Permission the Subject must possess +
Returns:
true if the Subject possesses the permission, + false otherwise
See Also:
. A + caught exception (or lack thereof) determines whether the privilege + is absent (or present).
+
+
+
+ +

+resolvePrincipal

+
+public Principal resolvePrincipal(String name)
+
+

Given a supplied string representing a Principal's name from an Acl, this + method resolves the correct type of Principal (role, group, or user). + This method is guaranteed to always return a Principal. + The algorithm is straightforward:

+
    +
  1. If the name matches one of the built-in Role names, + return that built-in Role
  2. +
  3. If the name matches one supplied by the current + Authorizer, return that Role
  4. +
  5. If the name matches a group managed by the + current GroupManager, return that Group
  6. +
  7. Otherwise, assume that the name represents a user + principal. Using the current UserDatabase, find the + first user who matches the supplied name by calling + UserDatabase.find(String).
  8. +
  9. Finally, if a user cannot be found, manufacture + and return a generic UnresolvedPrincipal
  10. +
+

+

+
Parameters:
name - the name of the Principal to resolve +
Returns:
the fully-resolved Principal
+
+
+
+ +

+addWikiEventListener

+
+public void addWikiEventListener(WikiEventListener listener)
+
+
Registers a WikiEventListener with this instance. +

+

+
Parameters:
listener - the event listener
+
+
+
+ +

+removeWikiEventListener

+
+public void removeWikiEventListener(WikiEventListener listener)
+
+
Un-registers a WikiEventListener with this instance. +

+

+
Parameters:
listener - the event listener
+
+
+
+ +

+fireEvent

+
+protected void fireEvent(int type,
+                         Principal user,
+                         Object permission)
+
+
Fires a WikiSecurityEvent of the provided type, user, + and permission to all registered listeners. +

+

+
Parameters:
type - the event type to be fired
user - the user associated with the event
permission - the permission the subject must possess
See Also:
WikiSecurityEvent
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved. + + http://git-wip-us.apache.org/repos/asf/jspwiki-site/blob/7f9ce779/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.png ---------------------------------------------------------------------- diff --git a/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.png b/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.png new file mode 100755 index 0000000..7e005f3 Binary files /dev/null and b/content/apidocs/2.10.1/org/apache/wiki/auth/AuthorizationManager.png differ http://git-wip-us.apache.org/repos/asf/jspwiki-site/blob/7f9ce779/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.html ---------------------------------------------------------------------- diff --git a/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.html b/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.html new file mode 100755 index 0000000..3fd66be --- /dev/null +++ b/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.html @@ -0,0 +1,328 @@ + + + + + + + +Authorizer (Apache JSPWiki Main War 2.10.1 API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +org.apache.wiki.auth +
+Interface Authorizer

+
+
All Known Subinterfaces:
WebAuthorizer
+
+
+
All Known Implementing Classes:
GroupManager, WebContainerAuthorizer
+
+
+
+
public interface Authorizer
+ + + + + + +
+ +

+Interface for service providers of authorization information. After a user + successfully logs in, the + AuthenticationManager consults the configured + Authorizer to determine which additional + Role principals should be added to + the user's WikiSession. To determine which roles should be injected, the + Authorizer is queried for the roles it knows about by calling + getRoles(). Then, each role + returned by the Authorizer is tested by calling + isUserInRole(WikiSession, Principal). + If this check fails, and the Authorizer is of type WebAuthorizer, + AuthenticationManager checks the role again by calling + WebAuthorizer.isUserInRole(javax.servlet.http.HttpServletRequest, Principal)). + Any roles that pass the test are injected into the Subject by firing + appropriate authentication events. +

+ +

+

+
Since:
+
2.3
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ PrincipalfindRole(String role) + +
+          Looks up and returns a role Principal matching a given String.
+ Principal[]getRoles() + +
+          Returns an array of role Principals this Authorizer knows about.
+ voidinitialize(WikiEngine engine, + Properties props) + +
+          Initializes the authorizer.
+ booleanisUserInRole(WikiSession session, + Principal role) + +
+          Determines whether the Subject associated with a WikiSession is in a + particular role.
+  +

+ + + + + + + + +
+Method Detail
+ +

+getRoles

+
+Principal[] getRoles()
+
+
Returns an array of role Principals this Authorizer knows about. This + method will always return an array; an implementing class may choose to + return an zero-length array if it has no ability to identify the roles + under its control. +

+

+ +
Returns:
an array of Principals representing the roles
+
+
+
+ +

+findRole

+
+Principal findRole(String role)
+
+
Looks up and returns a role Principal matching a given String. If a + matching role cannot be found, this method returns null. + Note that it may not always be feasible for an Authorizer implementation + to return a role Principal. +

+

+
Parameters:
role - the name of the role to retrieve +
Returns:
the role Principal
+
+
+
+ +

+initialize

+
+void initialize(WikiEngine engine,
+                Properties props)
+                throws WikiSecurityException
+
+
Initializes the authorizer. +

+

+
Parameters:
engine - the current wiki engine
props - the wiki engine initialization properties +
Throws: +
WikiSecurityException - if the Authorizer could not be initialized
+
+
+
+ +

+isUserInRole

+
+boolean isUserInRole(WikiSession session,
+                     Principal role)
+
+
Determines whether the Subject associated with a WikiSession is in a + particular role. This method takes two parameters: the WikiSession + containing the subject and the desired role ( which may be a Role or a + Group). If either parameter is null, this method must + return false. +

+

+
Parameters:
session - the current WikiSession
role - the role to check +
Returns:
true if the user is considered to be in the role, + false otherwise
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved. + + http://git-wip-us.apache.org/repos/asf/jspwiki-site/blob/7f9ce779/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.png ---------------------------------------------------------------------- diff --git a/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.png b/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.png new file mode 100755 index 0000000..619f912 Binary files /dev/null and b/content/apidocs/2.10.1/org/apache/wiki/auth/Authorizer.png differ