From 3570115635d1fa1d54870a234b94bed133a25580 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 27 Sep 2021 12:39:26 -0500 Subject: [PATCH] HHH-14845 - Deprecate JACC support --- .../boot/cfgxml/spi/LoadedConfig.java | 15 +++++++++--- .../org/hibernate/cfg/AvailableSettings.java | 19 +++++++++++---- .../AbstractPreDatabaseOperationEvent.java | 11 +++++++++ .../internal/log/DeprecationLogger.java | 24 +++++++++++++++++++ .../AbstractJaccSecurableEventListener.java | 3 +++ .../internal/JaccPreDeleteEventListener.java | 3 +++ .../internal/JaccPreInsertEventListener.java | 3 +++ .../internal/JaccPreLoadEventListener.java | 3 +++ .../internal/JaccPreUpdateEventListener.java | 3 +++ .../secure/internal/JaccSecurityListener.java | 3 +++ .../internal/StandardJaccServiceImpl.java | 3 +++ .../secure/spi/GrantedPermission.java | 3 +++ .../hibernate/secure/spi/JaccIntegrator.java | 10 ++++++++ .../spi/JaccPermissionDeclarations.java | 3 +++ .../org/hibernate/secure/spi/JaccService.java | 3 +++ .../secure/spi/PermissibleAction.java | 3 +++ .../spi/PermissionCheckEntityInformation.java | 3 +++ 17 files changed, 108 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java index 156f334d09..f941719981 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/cfgxml/spi/LoadedConfig.java @@ -24,6 +24,7 @@ import org.hibernate.boot.jaxb.cfg.spi.JaxbCfgEventListenerType; import org.hibernate.boot.jaxb.cfg.spi.JaxbCfgHibernateConfiguration; import org.hibernate.boot.jaxb.cfg.spi.JaxbCfgMappingReferenceType; import org.hibernate.event.spi.EventType; +import org.hibernate.internal.log.DeprecationLogger; import org.hibernate.secure.spi.GrantedPermission; import org.hibernate.secure.spi.JaccPermissionDeclarations; @@ -59,10 +60,18 @@ public class LoadedConfig { return configurationValues; } + /** + * @deprecated Support for JACC will be removed in 6.0 + */ + @Deprecated public Map getJaccPermissionsByContextId() { return jaccPermissionsByContextId; } + /** + * @deprecated Support for JACC will be removed in 6.0 + */ + @Deprecated public JaccPermissionDeclarations getJaccPermissions(String jaccContextId) { return jaccPermissionsByContextId.get( jaccContextId ); } @@ -102,11 +111,11 @@ public class LoadedConfig { cfg.addCacheRegionDefinition( parseCacheRegionDefinition( cacheDeclaration ) ); } - if ( jaxbCfg.getSecurity() != null ) { + if ( jaxbCfg.getSecurity() != null && ! jaxbCfg.getSecurity().getGrant().isEmpty() ) { + DeprecationLogger.DEPRECATION_LOGGER.deprecatedJaccCfgXmlSettings(); for ( JaxbCfgHibernateConfiguration.JaxbCfgSecurity.JaxbCfgGrant grant : jaxbCfg.getSecurity().getGrant() ) { final JaccPermissionDeclarations jaccPermissions = cfg.getOrCreateJaccPermissions( - jaxbCfg.getSecurity() - .getContext() + jaxbCfg.getSecurity().getContext() ); jaccPermissions.addPermissionDeclaration( new GrantedPermission( diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java index 91e1f663ff..aa8b6d9787 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java @@ -1692,10 +1692,6 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings { */ String JTA_TRACK_BY_THREAD = "hibernate.jta.track_by_thread"; - String JACC_CONTEXT_ID = "hibernate.jacc_context_id"; - String JACC_PREFIX = "hibernate.jacc"; - String JACC_ENABLED = "hibernate.jacc.enabled"; - /** * If enabled, allows schema update and validation to support synonyms. Due * to the possibility that this would return duplicate tables (especially in @@ -2098,4 +2094,19 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings { */ String OMIT_JOIN_OF_SUPERCLASS_TABLES = "hibernate.query.omit_join_of_superclass_tables"; + /** + * @deprecated Support for JACC will be removed in 6.0 + */ + @Deprecated + String JACC_CONTEXT_ID = "hibernate.jacc_context_id"; + /** + * @deprecated Support for JACC will be removed in 6.0 + */ + @Deprecated + String JACC_PREFIX = "hibernate.jacc"; + /** + * @deprecated Support for JACC will be removed in 6.0 + */ + @Deprecated + String JACC_ENABLED = "hibernate.jacc.enabled"; } diff --git a/hibernate-core/src/main/java/org/hibernate/event/spi/AbstractPreDatabaseOperationEvent.java b/hibernate-core/src/main/java/org/hibernate/event/spi/AbstractPreDatabaseOperationEvent.java index 8d31f09d5a..bd58a1aa31 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/spi/AbstractPreDatabaseOperationEvent.java +++ b/hibernate-core/src/main/java/org/hibernate/event/spi/AbstractPreDatabaseOperationEvent.java @@ -47,8 +47,11 @@ public abstract class AbstractPreDatabaseOperationEvent * Retrieves the entity involved in the database operation. * * @return The entity. + * + * @deprecated Support for JACC will be removed in 6.0 */ @Override + @Deprecated public Object getEntity() { return entity; } @@ -88,12 +91,20 @@ public abstract class AbstractPreDatabaseOperationEvent return getSession(); } + /** + * @deprecated Support for JACC will be removed in 6.0 + */ @Override + @Deprecated public String getEntityName() { return persister.getEntityName(); } + /** + * @deprecated Support for JACC will be removed in 6.0 + */ @Override + @Deprecated public Serializable getIdentifier() { return id; } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java index 455b09d244..7db821e942 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/log/DeprecationLogger.java @@ -249,4 +249,28 @@ public interface DeprecationLogger extends BasicLogger { "5.3 in upgrading. It will be removed in a later version." ) void logUseOfDeprecatedZeroBasedJdbcStyleParams(); + + @LogMessage(level = WARN) + @Message( + id = 90000025, + value = "Encountered multiple component mappings for the same java class [%s] with different property mappings. " + + "This is deprecated and will be removed in a future version. Every property mapping combination should have its own java class" + ) + void deprecatedComponentMapping(String name); + + @LogMessage(level = WARN) + @Message( + id = 90000026, + value = "JACC integration was enabled. Support for JACC integration will be removed in version 6.0. Use of" + + "`%s`, `%s` or `%s` settings is discouraged" + ) + void deprecatedJaccUsage(String jaccEnabled, String jaccContextId, String jaccPrefix); + + @LogMessage(level = WARN) + @Message( + id = 90000027, + value = "JACC settings encountered in hibernate `cfg.xml` file. JACC integration is deprecated and will be removed in version 6.0" + ) + void deprecatedJaccCfgXmlSettings(); + } diff --git a/hibernate-core/src/main/java/org/hibernate/secure/internal/AbstractJaccSecurableEventListener.java b/hibernate-core/src/main/java/org/hibernate/secure/internal/AbstractJaccSecurableEventListener.java index e21d3a2df7..95c172d0ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/internal/AbstractJaccSecurableEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/internal/AbstractJaccSecurableEventListener.java @@ -16,7 +16,10 @@ import org.hibernate.secure.spi.PermissionCheckEntityInformation; * Base class for JACC-securable event listeners * * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public abstract class AbstractJaccSecurableEventListener implements JaccSecurityListener { private JaccService jaccService; diff --git a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreDeleteEventListener.java b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreDeleteEventListener.java index 41fea76132..ebec862449 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreDeleteEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreDeleteEventListener.java @@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction; * * @author Kabir Khan * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class JaccPreDeleteEventListener extends AbstractJaccSecurableEventListener implements PreDeleteEventListener { public JaccPreDeleteEventListener() { } diff --git a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreInsertEventListener.java b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreInsertEventListener.java index c9ff548d5a..6836c0ed26 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreInsertEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreInsertEventListener.java @@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction; * * @author Kabir Khan * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class JaccPreInsertEventListener extends AbstractJaccSecurableEventListener implements PreInsertEventListener { public JaccPreInsertEventListener() { } diff --git a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreLoadEventListener.java b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreLoadEventListener.java index 7f3dc7b4ba..51d531ed0a 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreLoadEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreLoadEventListener.java @@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction; * * @author Kabir Khan * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class JaccPreLoadEventListener extends AbstractJaccSecurableEventListener implements PreLoadEventListener { public JaccPreLoadEventListener() { } diff --git a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreUpdateEventListener.java b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreUpdateEventListener.java index fa5a0abfbb..7ced461c75 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreUpdateEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccPreUpdateEventListener.java @@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction; * * @author Kabir Khan * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class JaccPreUpdateEventListener extends AbstractJaccSecurableEventListener implements PreUpdateEventListener { public JaccPreUpdateEventListener() { } diff --git a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccSecurityListener.java b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccSecurityListener.java index 3828a80858..6fc8a71769 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccSecurityListener.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/internal/JaccSecurityListener.java @@ -11,6 +11,9 @@ package org.hibernate.secure.internal; * {@link org.hibernate.secure.spi.JaccIntegrator} for details. * * @author Kabir Khan + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public interface JaccSecurityListener { } diff --git a/hibernate-core/src/main/java/org/hibernate/secure/internal/StandardJaccServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/secure/internal/StandardJaccServiceImpl.java index 959314938a..bf0c1fedbd 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/internal/StandardJaccServiceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/internal/StandardJaccServiceImpl.java @@ -34,7 +34,10 @@ import org.jboss.logging.Logger; /** * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class StandardJaccServiceImpl implements JaccService, Configurable { private static final Logger log = Logger.getLogger( StandardJaccServiceImpl.class ); diff --git a/hibernate-core/src/main/java/org/hibernate/secure/spi/GrantedPermission.java b/hibernate-core/src/main/java/org/hibernate/secure/spi/GrantedPermission.java index 92d7fe458e..17b71ebb2d 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/spi/GrantedPermission.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/spi/GrantedPermission.java @@ -10,7 +10,10 @@ package org.hibernate.secure.spi; * Describes a Hibernate (persistence) permission. * * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class GrantedPermission { private final String role; private final String entityName; diff --git a/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccIntegrator.java b/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccIntegrator.java index 36f61ce2b8..0779e7fc11 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccIntegrator.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccIntegrator.java @@ -17,6 +17,7 @@ import org.hibernate.event.service.spi.DuplicationStrategy; import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.event.spi.EventType; import org.hibernate.integrator.spi.ServiceContributingIntegrator; +import org.hibernate.internal.log.DeprecationLogger; import org.hibernate.secure.internal.DisabledJaccServiceImpl; import org.hibernate.secure.internal.JaccPreDeleteEventListener; import org.hibernate.secure.internal.JaccPreInsertEventListener; @@ -32,7 +33,10 @@ import org.jboss.logging.Logger; * Integrator for setting up JACC integration * * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class JaccIntegrator implements ServiceContributingIntegrator { private static final Logger log = Logger.getLogger( JaccIntegrator.class ); @@ -81,6 +85,12 @@ public class JaccIntegrator implements ServiceContributingIntegrator { return; } + DeprecationLogger.DEPRECATION_LOGGER.deprecatedJaccUsage( + AvailableSettings.JACC_ENABLED, + AvailableSettings.JACC_CONTEXT_ID, + AvailableSettings.JACC_PREFIX + ); + final String contextId = (String) properties.get( AvailableSettings.JACC_CONTEXT_ID ); if ( contextId == null ) { throw new IntegrationException( "JACC context id must be specified" ); diff --git a/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccPermissionDeclarations.java b/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccPermissionDeclarations.java index 9fbaeff2dd..53441bfe8e 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccPermissionDeclarations.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccPermissionDeclarations.java @@ -12,7 +12,10 @@ import java.util.List; /** * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public class JaccPermissionDeclarations { private final String contextId; private List permissionDeclarations; diff --git a/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccService.java b/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccService.java index 2b784c6eb2..50d70a810f 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccService.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/spi/JaccService.java @@ -12,7 +12,10 @@ import org.hibernate.service.Service; * Service describing Hibernate integration with JACC for security service. * * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public interface JaccService extends Service { /** * Obtain the JACC context-id in effect for this service. {@code null} indicates no diff --git a/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissibleAction.java b/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissibleAction.java index 761eaa169e..c5c2963d2c 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissibleAction.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissibleAction.java @@ -8,7 +8,10 @@ package org.hibernate.secure.spi; /** * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public enum PermissibleAction { INSERT( "insert" ), UPDATE( "update" ), diff --git a/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissionCheckEntityInformation.java b/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissionCheckEntityInformation.java index 7aa7c6ad41..acc038901c 100644 --- a/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissionCheckEntityInformation.java +++ b/hibernate-core/src/main/java/org/hibernate/secure/spi/PermissionCheckEntityInformation.java @@ -10,7 +10,10 @@ import java.io.Serializable; /** * @author Steve Ebersole + * + * @deprecated Support for JACC will be removed in 6.0 */ +@Deprecated public interface PermissionCheckEntityInformation { public Object getEntity(); public String getEntityName();