Class SecurityHelper


  • final class SecurityHelper
    extends java.lang.Object
    Utility methods for security Entity Data Filtering.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Set<java.lang.String> roles  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SecurityHelper()
      Prevent instantiation.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static java.util.Set<java.lang.String> getFilteringScopes​(java.lang.annotation.Annotation[] annotations)
      Get entity-filtering scopes of security annotations present among given annotations.
      (package private) static java.util.Set<java.lang.String> getFilteringScopes​(javax.ws.rs.core.SecurityContext securityContext, java.lang.annotation.Annotation[] annotations)
      Get entity-filtering scopes of security annotations present among given annotations with respect to given SecurityContext.
      (package private) static java.util.Set<java.lang.String> getProcessedRoles()
      Get authorization roles that has been derived from examining entity classes.
      (package private) static java.lang.String getRolesAllowedScope​(java.lang.String role)
      Get entity-filtering scope for RolesAlloweds role.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • roles

        private static final java.util.Set<java.lang.String> roles
    • Constructor Detail

      • SecurityHelper

        private SecurityHelper()
        Prevent instantiation.
    • Method Detail

      • getFilteringScopes

        static java.util.Set<java.lang.String> getFilteringScopes​(java.lang.annotation.Annotation[] annotations)
        Get entity-filtering scopes of security annotations present among given annotations.

        A scope look like:

        • <fully qualified annotation class name>, or
        • <fully qualified annotation class name>_<role>

        Parameters:
        annotations - a list of annotations (doesn't need to contain only security annotations)
        Returns:
        a set of entity-filtering scopes.
      • getFilteringScopes

        static java.util.Set<java.lang.String> getFilteringScopes​(javax.ws.rs.core.SecurityContext securityContext,
                                                                  java.lang.annotation.Annotation[] annotations)
        Get entity-filtering scopes of security annotations present among given annotations with respect to given SecurityContext. Resulting set contains only scopes that pass the security context check.

        A scope look like:

        • <fully qualified annotation class name>, or
        • <fully qualified annotation class name>_<role>

        Parameters:
        securityContext - security context to check whether a user is in specified logical role.
        annotations - a list of annotations (doesn't need to contain only security annotations)
        Returns:
        a set of entity-filtering scopes.
      • getRolesAllowedScope

        static java.lang.String getRolesAllowedScope​(java.lang.String role)
        Get entity-filtering scope for RolesAlloweds role.
        Parameters:
        role - role to retrieve entity-filtering scope for.
        Returns:
        entity-filtering scope.
      • getProcessedRoles

        static java.util.Set<java.lang.String> getProcessedRoles()
        Get authorization roles that has been derived from examining entity classes.
        Returns:
        already processed authorization roles.