HHH-14845 - Deprecate JACC support

This commit is contained in:
Steve Ebersole 2021-09-27 12:39:26 -05:00 committed by Sanne Grinovero
parent dc450d8bb3
commit 3570115635
17 changed files with 108 additions and 7 deletions

View File

@ -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<String, JaccPermissionDeclarations> 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(

View File

@ -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";
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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;

View File

@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction;
*
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
* @author Steve Ebersole
*
* @deprecated Support for JACC will be removed in 6.0
*/
@Deprecated
public class JaccPreDeleteEventListener extends AbstractJaccSecurableEventListener implements PreDeleteEventListener {
public JaccPreDeleteEventListener() {
}

View File

@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction;
*
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
* @author Steve Ebersole
*
* @deprecated Support for JACC will be removed in 6.0
*/
@Deprecated
public class JaccPreInsertEventListener extends AbstractJaccSecurableEventListener implements PreInsertEventListener {
public JaccPreInsertEventListener() {
}

View File

@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction;
*
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
* @author Steve Ebersole
*
* @deprecated Support for JACC will be removed in 6.0
*/
@Deprecated
public class JaccPreLoadEventListener extends AbstractJaccSecurableEventListener implements PreLoadEventListener {
public JaccPreLoadEventListener() {
}

View File

@ -15,7 +15,10 @@ import org.hibernate.secure.spi.PermissibleAction;
*
* @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
* @author Steve Ebersole
*
* @deprecated Support for JACC will be removed in 6.0
*/
@Deprecated
public class JaccPreUpdateEventListener extends AbstractJaccSecurableEventListener implements PreUpdateEventListener {
public JaccPreUpdateEventListener() {
}

View File

@ -11,6 +11,9 @@ package org.hibernate.secure.internal;
* {@link org.hibernate.secure.spi.JaccIntegrator} for details.
*
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
*
* @deprecated Support for JACC will be removed in 6.0
*/
@Deprecated
public interface JaccSecurityListener {
}

View File

@ -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 );

View File

@ -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;

View File

@ -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" );

View File

@ -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<GrantedPermission> permissionDeclarations;

View File

@ -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

View File

@ -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" ),

View File

@ -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();