javax.security.jacc.PolicyConfigurationFactory Java Examples

The following examples show how to use javax.security.jacc.PolicyConfigurationFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandardJaccServiceImpl.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private PolicyConfiguration locatePolicyConfiguration(String contextId) {
	try {
		return PolicyConfigurationFactory
				.getPolicyConfigurationFactory()
				.getPolicyConfiguration( contextId, false );
	}
	catch (Exception e) {
		throw new IntegrationException( "Unable to access JACC PolicyConfiguration" );
	}
}
 
Example #2
Source File: JACCConfiguration.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public JACCConfiguration(String contextId) throws HibernateException {
	try {
		policyConfiguration = PolicyConfigurationFactory
				.getPolicyConfigurationFactory()
				.getPolicyConfiguration( contextId, false );
	}
	catch (ClassNotFoundException cnfe) {
		throw new HibernateException( "JACC provider class not found", cnfe );
	}
	catch (PolicyContextException pce) {
		throw new HibernateException( "policy context exception occurred", pce );
	}
}
 
Example #3
Source File: AbstractSecurityService.java    From tomee with Apache License 2.0 5 votes vote down vote up
protected static void installJacc() {
    final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

    final String providerKey = "javax.security.jacc.PolicyConfigurationFactory.provider";
    try {
        if (JavaSecurityManagers.getSystemProperty(providerKey) == null) {
            JavaSecurityManagers.setSystemProperty(providerKey, JaccProvider.Factory.class.getName());
            final ClassLoader cl = JaccProvider.Factory.class.getClassLoader();
            Thread.currentThread().setContextClassLoader(cl);
        }

        // Force the loading of the javax.security.jacc.PolicyConfigurationFactory.provider
        // Hopefully it will be cached thereafter and ClassNotFoundExceptions thrown
        // from the equivalent call in JaccPermissionsBuilder can be avoided.
        PolicyConfigurationFactory.getPolicyConfigurationFactory();
    } catch (final Exception e) {
        throw new IllegalStateException("Could not install JACC Policy Configuration Factory: " + JavaSecurityManagers.getSystemProperty(providerKey), e);
    } finally {
        Thread.currentThread().setContextClassLoader(contextClassLoader);
    }

    // check the system provided provider first - if for some reason it isn't loaded, load it
    final String systemPolicyProvider = SystemInstance.get().getOptions().getProperties().getProperty("javax.security.jacc.policy.provider");
    if (systemPolicyProvider != null && Policy.getPolicy() == null) {
        installPolicy(systemPolicyProvider);
    }

    if (! JaccProvider.Policy.class.getName().equals(Policy.getPolicy().getClass().getName())) {
        // this should delegate to the policy installed above
        installPolicy(JaccProvider.Policy.class.getName());
    }
}