Search in sources :

Example 1 with JaccService

use of org.hibernate.secure.spi.JaccService in project hibernate-orm by hibernate.

the class SessionFactoryImpl method applyCfgXmlValues.

private void applyCfgXmlValues(LoadedConfig aggregatedConfig, SessionFactoryServiceRegistry serviceRegistry) {
    final JaccService jaccService = serviceRegistry.getService(JaccService.class);
    if (jaccService.getContextId() != null) {
        final JaccPermissionDeclarations permissions = aggregatedConfig.getJaccPermissions(jaccService.getContextId());
        if (permissions != null) {
            for (GrantedPermission grantedPermission : permissions.getPermissionDeclarations()) {
                jaccService.addPermission(grantedPermission);
            }
        }
    }
    if (aggregatedConfig.getEventListenerMap() != null) {
        final ClassLoaderService cls = serviceRegistry.getService(ClassLoaderService.class);
        final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService(EventListenerRegistry.class);
        for (Map.Entry<EventType, Set<String>> entry : aggregatedConfig.getEventListenerMap().entrySet()) {
            final EventListenerGroup group = eventListenerRegistry.getEventListenerGroup(entry.getKey());
            for (String listenerClassName : entry.getValue()) {
                try {
                    group.appendListener(cls.classForName(listenerClassName).newInstance());
                } catch (Exception e) {
                    throw new ConfigurationException("Unable to instantiate event listener class : " + listenerClassName, e);
                }
            }
        }
    }
}
Also used : Set(java.util.Set) EventListenerGroup(org.hibernate.event.service.spi.EventListenerGroup) EventType(org.hibernate.event.spi.EventType) JaccService(org.hibernate.secure.spi.JaccService) GrantedPermission(org.hibernate.secure.spi.GrantedPermission) InvalidObjectException(java.io.InvalidObjectException) HibernateException(org.hibernate.HibernateException) SQLException(java.sql.SQLException) ConfigurationException(org.hibernate.internal.util.config.ConfigurationException) IOException(java.io.IOException) PersistenceException(javax.persistence.PersistenceException) MappingException(org.hibernate.MappingException) EventListenerRegistry(org.hibernate.event.service.spi.EventListenerRegistry) JaccPermissionDeclarations(org.hibernate.secure.spi.JaccPermissionDeclarations) ConfigurationException(org.hibernate.internal.util.config.ConfigurationException) Map(java.util.Map) HashMap(java.util.HashMap) ClassLoaderService(org.hibernate.boot.registry.classloading.spi.ClassLoaderService)

Aggregations

IOException (java.io.IOException)1 InvalidObjectException (java.io.InvalidObjectException)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 PersistenceException (javax.persistence.PersistenceException)1 HibernateException (org.hibernate.HibernateException)1 MappingException (org.hibernate.MappingException)1 ClassLoaderService (org.hibernate.boot.registry.classloading.spi.ClassLoaderService)1 EventListenerGroup (org.hibernate.event.service.spi.EventListenerGroup)1 EventListenerRegistry (org.hibernate.event.service.spi.EventListenerRegistry)1 EventType (org.hibernate.event.spi.EventType)1 ConfigurationException (org.hibernate.internal.util.config.ConfigurationException)1 GrantedPermission (org.hibernate.secure.spi.GrantedPermission)1 JaccPermissionDeclarations (org.hibernate.secure.spi.JaccPermissionDeclarations)1 JaccService (org.hibernate.secure.spi.JaccService)1