use of org.hibernate.secure.internal.JaccPreLoadEventListener in project hibernate-orm by hibernate.
the class JaccIntegrator method doIntegration.
private void doIntegration(Map properties, JaccPermissionDeclarations permissionDeclarations, SessionFactoryServiceRegistry serviceRegistry) {
boolean isSecurityEnabled = properties.containsKey(AvailableSettings.JACC_ENABLED);
if (!isSecurityEnabled) {
log.debug("Skipping JACC integration as it was not enabled");
return;
}
final String contextId = (String) properties.get(AvailableSettings.JACC_CONTEXT_ID);
if (contextId == null) {
throw new IntegrationException("JACC context id must be specified");
}
final JaccService jaccService = serviceRegistry.getService(JaccService.class);
if (jaccService == null) {
throw new IntegrationException("JaccService was not set up");
}
if (permissionDeclarations != null) {
for (GrantedPermission declaration : permissionDeclarations.getPermissionDeclarations()) {
jaccService.addPermission(declaration);
}
}
final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
eventListenerRegistry.addDuplicationStrategy(DUPLICATION_STRATEGY);
eventListenerRegistry.prependListeners(EventType.PRE_DELETE, new JaccPreDeleteEventListener());
eventListenerRegistry.prependListeners(EventType.PRE_INSERT, new JaccPreInsertEventListener());
eventListenerRegistry.prependListeners(EventType.PRE_UPDATE, new JaccPreUpdateEventListener());
eventListenerRegistry.prependListeners(EventType.PRE_LOAD, new JaccPreLoadEventListener());
}
use of org.hibernate.secure.internal.JaccPreLoadEventListener in project hibernate-orm by hibernate.
the class JaccEventListenerIntegrator method integrate.
@Override
@SuppressWarnings({ "unchecked" })
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
boolean isSecurityEnabled = configuration.getProperties().containsKey(AvailableSettings.JACC_ENABLED);
if (!isSecurityEnabled) {
return;
}
final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
eventListenerRegistry.addDuplicationStrategy(JACC_DUPLICATION_STRATEGY);
final String jaccContextId = configuration.getProperty(Environment.JACC_CONTEXTID);
eventListenerRegistry.prependListeners(EventType.PRE_DELETE, new JACCPreDeleteEventListener(jaccContextId));
eventListenerRegistry.prependListeners(EventType.PRE_INSERT, new JACCPreInsertEventListener(jaccContextId));
eventListenerRegistry.prependListeners(EventType.PRE_UPDATE, new JACCPreUpdateEventListener(jaccContextId));
eventListenerRegistry.prependListeners(EventType.PRE_LOAD, new JACCPreLoadEventListener(jaccContextId));
}
Aggregations