ca.gc.aafc.dina.security.GroupAuthorizationService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dina-base-api Show documentation
Show all versions of dina-base-api Show documentation
Base DINA API package for Java built on SpringBoot and Crnk
package ca.gc.aafc.dina.security;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import ca.gc.aafc.dina.security.spring.DinaPermissionEvaluator;
import ca.gc.aafc.dina.security.spring.MethodSecurityConfig;
/**
* Authorization service using spring security. Service is only available on
* keycloak.enabled = true. Use Optional injection when using this service.
*/
@Service
@ConditionalOnProperty(value = "keycloak.enabled", havingValue = "true")
public class GroupAuthorizationService implements DinaAuthorizationService {
/**
* Proxy Method to invoke security authorization, Delegates to
* {@link DinaPermissionEvaluator#hasGroupPermission(DinaAuthenticatedUser, Object)}.
* This method itself does nothing, spring proxies must be called from a
* seperate bean. @PreAuthorize is only enabled with keycloak, see
* {@link MethodSecurityConfig}. This method will not validate if keycloak is
* disabled.
*
* @param entity
*/
@Override
@PreAuthorize("hasGroupPermission(@currentUser, #entity)")
public void authorizeCreate(Object entity) {
}
/**
* Proxy Method to invoke security authorization, Delegates to
* {@link DinaPermissionEvaluator#hasGroupPermission(DinaAuthenticatedUser, Object)}.
* This method itself does nothing, spring proxies must be called from a
* seperate bean. @PreAuthorize is only enabled with keycloak, see
* {@link MethodSecurityConfig}. This method will not validate if keycloak is
* disabled.
*
* @param entity
*/
@Override
@PreAuthorize("hasGroupPermission(@currentUser, #entity)")
public void authorizeUpdate(Object entity) {
}
/**
* Proxy Method to invoke security authorization, Delegates to
* {@link DinaPermissionEvaluator#hasGroupPermission(DinaAuthenticatedUser, Object)}.
* This method itself does nothing, spring proxies must be called from a
* seperate bean. @PreAuthorize is only enabled with keycloak, see
* {@link MethodSecurityConfig}. This method will not validate if keycloak is
* disabled.
*
* @param entity
*/
@Override
@PreAuthorize("hasGroupPermission(@currentUser, #entity)")
public void authorizeDelete(Object entity) {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy