use of org.freshcookies.security.policy.LocalPolicy in project jspwiki by apache.
the class AuthorizationManager method initialize.
/**
* 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.
* @param engine the wiki engine
* @param properties the set of properties used to initialize the wiki engine
* @throws WikiException if the AuthorizationManager cannot be initialized
*/
public void initialize(WikiEngine engine, Properties properties) throws WikiException {
m_engine = engine;
//
// JAAS authorization continues
//
m_authorizer = getAuthorizerImplementation(properties);
m_authorizer.initialize(engine, properties);
// Initialize local security policy
try {
String policyFileName = properties.getProperty(POLICY, DEFAULT_POLICY);
URL policyURL = AuthenticationManager.findConfigFile(engine, policyFileName);
if (policyURL != null) {
File policyFile = new File(policyURL.toURI().getPath());
log.info("We found security policy URL: " + policyURL + " and transformed it to file " + policyFile.getAbsolutePath());
m_localPolicy = new LocalPolicy(policyFile, engine.getContentEncoding());
m_localPolicy.refresh();
log.info("Initialized default security policy: " + policyFile.getAbsolutePath());
} else {
String sb = "JSPWiki was unable to initialize the default security policy (WEB-INF/jspwiki.policy) file. " + "Please ensure that the jspwiki.policy file exists in the default location. " + "This file should exist regardless of the existance of a global policy file. " + "The global policy file is identified by the java.security.policy variable. ";
WikiSecurityException wse = new WikiSecurityException(sb);
log.fatal(sb, wse);
throw wse;
}
} catch (Exception e) {
log.error("Could not initialize local security policy: " + e.getMessage());
throw new WikiException("Could not initialize local security policy: " + e.getMessage(), e);
}
}
Aggregations