use of javax.security.jacc.PolicyConfigurationFactory in project wildfly by wildfly.
the class JaccService method start.
/** {@inheritDoc} */
@Override
public void start(StartContext context) throws StartException {
try {
PolicyConfigurationFactory pcf = getPolicyConfigurationFactory();
synchronized (pcf) {
// synchronize on the factory
policyConfiguration = pcf.getPolicyConfiguration(contextId, false);
if (metaData != null) {
createPermissions(metaData, policyConfiguration);
} else {
SecurityLogger.ROOT_LOGGER.debugf("Cannot create permissions with 'null' metaData for id=%s", contextId);
}
if (!standalone) {
PolicyConfiguration parent = parentPolicy.getValue();
if (parent != null) {
parent = pcf.getPolicyConfiguration(parent.getContextID(), false);
parent.linkConfiguration(policyConfiguration);
policyConfiguration.commit();
parent.commit();
} else {
SecurityLogger.ROOT_LOGGER.debugf("Could not retrieve parent policy for policy %s", contextId);
}
} else {
policyConfiguration.commit();
}
// Allow the policy to incorporate the policy configs
Policy.getPolicy().refresh();
}
} catch (Exception e) {
throw SecurityLogger.ROOT_LOGGER.unableToStartException("JaccService", e);
}
}
use of javax.security.jacc.PolicyConfigurationFactory in project tomee by apache.
the class JaccPermissionsBuilder method install.
public void install(final PolicyContext policyContext) throws OpenEJBException {
if (SystemInstance.get().hasProperty("openejb.geronimo")) {
return;
}
try {
final PolicyConfigurationFactory factory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
final PolicyConfiguration policy = factory.getPolicyConfiguration(policyContext.getContextID(), false);
policy.addToExcludedPolicy(policyContext.getExcludedPermissions());
policy.addToUncheckedPolicy(policyContext.getUncheckedPermissions());
for (final Map.Entry<String, PermissionCollection> entry : policyContext.getRolePermissions().entrySet()) {
policy.addToRole(entry.getKey(), entry.getValue());
}
policy.commit();
} catch (final ClassNotFoundException e) {
throw new OpenEJBException("PolicyConfigurationFactory class not found", e);
} catch (final PolicyContextException e) {
throw new OpenEJBException("JACC PolicyConfiguration failed: ContextId=" + policyContext.getContextID(), e);
}
}
use of javax.security.jacc.PolicyConfigurationFactory in project wildfly by wildfly.
the class JaccService method stop.
/** {@inheritDoc} */
@Override
public void stop(StopContext context) {
try {
PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
synchronized (pcf) {
// synchronize on the factory
policyConfiguration = pcf.getPolicyConfiguration(contextId, false);
policyConfiguration.delete();
}
} catch (Exception e) {
SecurityLogger.ROOT_LOGGER.errorDeletingJACCPolicy(e);
}
policyConfiguration = null;
}
Aggregations