Class SecureApi


  • public abstract class SecureApi
    extends Object
    The SecureApi class provides the base class from which all RESTful controllers that implement secure APIs should be derived.
    Author:
    Marcus Portmann
    • Constructor Detail

      • SecureApi

        public SecureApi​(org.springframework.context.ApplicationContext applicationContext)
        Constructs a new SecureApi.
        Parameters:
        applicationContext - the Spring application context
    • Method Detail

      • inDebugMode

        public boolean inDebugMode()
        Returns whether debugging is enabled for the Inception Framework.
        Returns:
        true if debugging is enabled for the Inception Framework or false otherwise
      • isSecurityDisabled

        public boolean isSecurityDisabled()
        Returns whether API security is disabled.
        Returns:
        true if API security is disabled or false otherwise
      • isSecurityEnabled

        public boolean isSecurityEnabled()
        Returns whether API security is enabled.
        Returns:
        true if API security is enabled or false otherwise
      • getLongValuesForAuthoritiesWithPrefix

        protected List<Long> getLongValuesForAuthoritiesWithPrefix​(org.springframework.security.core.Authentication authentication,
                                                                   String prefix)
        Returns the Long value portion of the authorities with the specified prefix.
        Parameters:
        authentication - the authenticated principal associated with the authenticated request
        prefix - the authority prefix
        Returns:
        the Long value portion of the authorities with the specified prefix
      • getUUIDValuesForAuthoritiesWithPrefix

        protected List<UUID> getUUIDValuesForAuthoritiesWithPrefix​(org.springframework.security.core.Authentication authentication,
                                                                   String prefix)
        Returns the UUID value portion of the authorities with the specified prefix.
        Parameters:
        authentication - the authenticated principal associated with the authenticated request
        prefix - the authority prefix
        Returns:
        the UUID value portion of the authorities with the specified prefix
      • getValueForAuthorityWithPrefix

        protected Optional<String> getValueForAuthorityWithPrefix​(org.springframework.security.core.Authentication authentication,
                                                                  String prefix)
        Returns the value portion of the authority with the specified prefix.
        Parameters:
        authentication - the authenticated principal associated with the authenticated request
        prefix - the authority prefix
        Returns:
        an Optional containing the value portion of the authority with the specified prefix or an empty Optional if the authority with the specified prefix could not be found
      • getValuesForAuthoritiesWithPrefix

        protected List<String> getValuesForAuthoritiesWithPrefix​(org.springframework.security.core.Authentication authentication,
                                                                 String prefix)
        Returns the value portion of the authorities with the specified prefix.
        Parameters:
        authentication - the authenticated principal associated with the authenticated request
        prefix - the authority prefix
        Returns:
        the value portion of the authorities with the specified prefix
      • hasAccessToFunction

        protected boolean hasAccessToFunction​(String functionCode)
        Confirm that the user associated with the authenticated request has access to the specified function.
        Parameters:
        functionCode - the code for the function
        Returns:
        true if the user associated with the authenticated request has access to the function identified by the specified function code or false otherwise
      • hasAccessToTenant

        protected boolean hasAccessToTenant​(UUID tenantId)
        Confirm that the user associated with the authenticated request has access to the tenant.
        Parameters:
        tenantId - the Universally Unique Identifier (UUID) for the tenant
        Returns:
        true if the user associated with the authenticated request has access to the tenant or false otherwise
      • hasAuthority

        protected boolean hasAuthority​(String authority)
        Confirm that the user associated with the authenticated request has the specified authority.
        Parameters:
        authority - the authority
        Returns:
        true if the user associated with the authenticated request has the specified authority or false otherwise
      • hasRole

        protected boolean hasRole​(String roleName)
        Confirm that the user associated with the authenticated request has the specified role.
        Parameters:
        roleName - the name of the role
        Returns:
        true if the user associated with the authenticated request has the specified role or false otherwise