Skip to content

Commit

Permalink
HHH-14845 - Deprecate JACC support
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole authored and Sanne committed Sep 28, 2021
1 parent 05c51e5 commit d856944
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 7 deletions.
Expand Up @@ -24,6 +24,7 @@
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;

Expand Down Expand Up @@ -59,10 +60,18 @@ public Map getConfigurationValues() {
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 );
}
Expand Down Expand Up @@ -102,11 +111,11 @@ public static LoadedConfig consume(JaxbCfgHibernateConfiguration jaxbCfg) {
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(
Expand Down
Expand Up @@ -2054,10 +2054,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
Expand Down Expand Up @@ -2461,4 +2457,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";
}
Expand Up @@ -47,8 +47,11 @@ public 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;
}
Expand Down Expand Up @@ -88,12 +91,20 @@ public EventSource getSource() {
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;
}
Expand Down
Expand Up @@ -258,4 +258,19 @@ void connectionProviderClassDeprecated(
"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();
}
Expand Up @@ -16,7 +16,10 @@
* 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;

Expand Down
Expand Up @@ -15,7 +15,10 @@
*
* @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() {
}
Expand Down
Expand Up @@ -15,7 +15,10 @@
*
* @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() {
}
Expand Down
Expand Up @@ -15,7 +15,10 @@
*
* @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() {
}
Expand Down
Expand Up @@ -15,7 +15,10 @@
*
* @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() {
}
Expand Down
Expand Up @@ -11,6 +11,9 @@
* {@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 {
}
Expand Up @@ -34,7 +34,10 @@

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

Expand Down
Expand Up @@ -10,7 +10,10 @@
* 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;
Expand Down
Expand Up @@ -17,6 +17,7 @@
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;
Expand All @@ -32,7 +33,10 @@
* 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 );

Expand Down Expand Up @@ -81,6 +85,12 @@ private void doIntegration(
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" );
Expand Down
Expand Up @@ -12,7 +12,10 @@

/**
* @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;
Expand Down
Expand Up @@ -12,7 +12,10 @@
* 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
Expand Down
Expand Up @@ -8,7 +8,10 @@

/**
* @author Steve Ebersole
*
* @deprecated Support for JACC will be removed in 6.0
*/
@Deprecated
public enum PermissibleAction {
INSERT( "insert" ),
UPDATE( "update" ),
Expand Down
Expand Up @@ -10,7 +10,10 @@

/**
* @author Steve Ebersole
*
* @deprecated Support for JACC will be removed in 6.0
*/
@Deprecated
public interface PermissionCheckEntityInformation {
public Object getEntity();
public String getEntityName();
Expand Down

0 comments on commit d856944

Please sign in to comment.