Package org.apache.wiki.auth
Class SecurityVerifier
java.lang.Object
org.apache.wiki.auth.SecurityVerifier
public final class SecurityVerifier extends java.lang.Object
Helper class for verifying JSPWiki's security configuration. Invoked by
admin/SecurityConfig.jsp.- Since:
- 2.4
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringERRORMessage prefix for errors.static java.lang.StringERROR_DBMessage topic for user database errors.static java.lang.StringERROR_GROUPSMessage topic for group database errors.static java.lang.StringERROR_JAASMessage topic for JAAS errors.static java.lang.StringERROR_POLICYMessage topic for policy errors.static java.lang.StringERROR_ROLESMessage topic for role-checking errors.static java.lang.StringINFOMessage prefix for information messages.static java.lang.StringINFO_DBMessage topic for user database information messages.static java.lang.StringINFO_GROUPSMessage topic for group database information messages.static java.lang.StringINFO_JAASMessage topic for JAAS information messages.static java.lang.StringINFO_POLICYMessage topic for policy information messages.static java.lang.StringINFO_ROLESMessage topic for role-checking information messages.static java.lang.StringWARNINGMessage prefix for warnings.static java.lang.StringWARNING_DBMessage topic for user database warnings.static java.lang.StringWARNING_GROUPSMessage topic for group database warnings.static java.lang.StringWARNING_JAASMessage topic for JAAS warnings.static java.lang.StringWARNING_POLICYMessage topic for policy warnings. -
Constructor Summary
Constructors Constructor Description SecurityVerifier(Engine engine, Session session)Constructs a new SecurityVerifier for a supplied Engine and WikiSession. -
Method Summary
Modifier and Type Method Description java.lang.StringcontainerRoleTable()Formats and returns an HTML table containing the roles the web container is aware of, and whether each role maps to particular JSPs.protected java.io.FilegetFileFromProperty(java.lang.String property)Looks up a file name based on a JRE system property and returns the associated File object if it exists.booleanisSecurityPolicyConfigured()Returnstrueif the Java security policy is configured correctly, and it verifies as valid.java.security.Principal[]policyPrincipals()Returns an array of unique Principals from the JSPWIki security policy file.java.lang.StringpolicyRoleTable()Formats and returns an HTML table containing sample permissions and what roles are allowed to have them.protected voidverifyGroupDatabase()Verifies that the group datbase was initialized properly, and that user add and delete operations work as they should.protected voidverifyJaas()Verfies the JAAS configuration.protected voidverifyPolicy()Verfies the Java security policy configuration.protected voidverifyPolicyAndContainerRoles()Verifies that the roles given in the security policy are reflected by the containerweb.xmlfile.protected booleanverifyStaticPermission(java.security.Principal principal, java.security.Permission permission)Verifies that a particular Principal possesses a Permission, as defined in the security policy file.protected voidverifyUserDatabase()Verifies that the user datbase was initialized properly, and that user add and delete operations work as they should.java.security.Principal[]webContainerRoles()If the active Authorizer is the WebContainerAuthorizer, returns the roles it knows about; otherwise, a zero-length array.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
ERROR
Message prefix for errors.- See Also:
- Constant Field Values
-
WARNING
Message prefix for warnings.- See Also:
- Constant Field Values
-
INFO
Message prefix for information messages.- See Also:
- Constant Field Values
-
ERROR_POLICY
Message topic for policy errors.- See Also:
- Constant Field Values
-
WARNING_POLICY
Message topic for policy warnings.- See Also:
- Constant Field Values
-
INFO_POLICY
Message topic for policy information messages.- See Also:
- Constant Field Values
-
ERROR_JAAS
Message topic for JAAS errors.- See Also:
- Constant Field Values
-
WARNING_JAAS
Message topic for JAAS warnings.- See Also:
- Constant Field Values
-
ERROR_ROLES
Message topic for role-checking errors.- See Also:
- Constant Field Values
-
INFO_ROLES
Message topic for role-checking information messages.- See Also:
- Constant Field Values
-
ERROR_DB
Message topic for user database errors.- See Also:
- Constant Field Values
-
WARNING_DB
Message topic for user database warnings.- See Also:
- Constant Field Values
-
INFO_DB
Message topic for user database information messages.- See Also:
- Constant Field Values
-
ERROR_GROUPS
Message topic for group database errors.- See Also:
- Constant Field Values
-
WARNING_GROUPS
Message topic for group database warnings.- See Also:
- Constant Field Values
-
INFO_GROUPS
Message topic for group database information messages.- See Also:
- Constant Field Values
-
INFO_JAAS
Message topic for JAAS information messages.- See Also:
- Constant Field Values
-
-
Constructor Details
-
SecurityVerifier
Constructs a new SecurityVerifier for a supplied Engine and WikiSession.- Parameters:
engine- the wiki enginesession- the wiki session (typically, that of an administrator)
-
-
Method Details
-
policyPrincipals
Returns an array of unique Principals from the JSPWIki security policy file. This array will be zero-length if the policy file was not successfully located, or if the file did not specify any Principals in the policy.- Returns:
- the array of principals
-
policyRoleTable
Formats and returns an HTML table containing sample permissions and what roles are allowed to have them. This method will throw anIllegalStateExceptionif the authorizer is not of typeWebContainerAuthorizer- Returns:
- the formatted HTML table containing the result of the tests
-
containerRoleTable
Formats and returns an HTML table containing the roles the web container is aware of, and whether each role maps to particular JSPs. This method throws anIllegalStateExceptionif the authorizer is not of typeWebContainerAuthorizer- Returns:
- the formatted HTML table containing the result of the tests
- Throws:
WikiException- if tests fail for unexpected reasons
-
isSecurityPolicyConfigured
Returnstrueif the Java security policy is configured correctly, and it verifies as valid.- Returns:
- the result of the configuration check
-
webContainerRoles
If the active Authorizer is the WebContainerAuthorizer, returns the roles it knows about; otherwise, a zero-length array.- Returns:
- the roles parsed from
web.xml, or a zero-length array - Throws:
WikiException- if the web authorizer cannot obtain the list of roles
-
verifyPolicyAndContainerRoles
Verifies that the roles given in the security policy are reflected by the containerweb.xmlfile.- Throws:
WikiException- if the web authorizer cannot verify the roles
-
verifyGroupDatabase
Verifies that the group datbase was initialized properly, and that user add and delete operations work as they should. -
verifyJaas
Verfies the JAAS configuration. The configuration is valid if value of thejspwiki.propertiesproperty "jspwiki.loginModule.class" resolves to a valid class on the classpath. -
getFileFromProperty
Looks up a file name based on a JRE system property and returns the associated File object if it exists. This method adds messages with the topic prefixERRORandINFOas appropriate, with the suffix matching the supplied property.- Parameters:
property- the system property to look up- Returns:
- the file object, or
nullif not found
-
verifyPolicy
Verfies the Java security policy configuration. The configuration is valid if value of the local policy (atWEB-INF/jspwiki.policyresolves to an existing file, and the policy file contained therein represents a valid policy. -
verifyStaticPermission
protected boolean verifyStaticPermission(java.security.Principal principal, java.security.Permission permission)Verifies that a particular Principal possesses a Permission, as defined in the security policy file.- Parameters:
principal- the principalpermission- the permission- Returns:
- the result, based on consultation with the active Java security policy
-
verifyUserDatabase
Verifies that the user datbase was initialized properly, and that user add and delete operations work as they should.
-