Class ClientAuthorizers


  • public class ClientAuthorizers
    extends java.lang.Object
    Utility class containing ClientAuthorizer implementations.
    Since:
    2 Feb 2011
    Author:
    Mark Taylor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static ClientAuthorizer FALSE
      Authorizer which always denies access, with INFO logging either way.
      static ClientAuthorizer TRUE
      Authorizer which always permits access, with WARNING logging either way.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ClientAuthorizer createFixedClientAuthorizer​(boolean policy)
      Returns a new authorizer instance which always produces the same authorization status.
      static ClientAuthorizer createLoggingClientAuthorizer​(ClientAuthorizer auth, java.util.logging.Level acceptLevel, java.util.logging.Level refuseLevel)
      Returns a new authorizer instance based on an existing one which logs authorization results through the logging system.
      static java.lang.String getAppName​(java.util.Map securityMap)
      Returns the mandatory application name entry from the security map supplied explicitly by clients wishing to register.
      • Methods inherited from class java.lang.Object

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

      • FALSE

        public static final ClientAuthorizer FALSE
        Authorizer which always denies access, with INFO logging either way.
      • TRUE

        public static final ClientAuthorizer TRUE
        Authorizer which always permits access, with WARNING logging either way.
    • Method Detail

      • createFixedClientAuthorizer

        public static ClientAuthorizer createFixedClientAuthorizer​(boolean policy)
        Returns a new authorizer instance which always produces the same authorization status.
        Parameters:
        policy - true for accept, false for deny
        Returns:
        new authorizer
      • createLoggingClientAuthorizer

        public static ClientAuthorizer createLoggingClientAuthorizer​(ClientAuthorizer auth,
                                                                     java.util.logging.Level acceptLevel,
                                                                     java.util.logging.Level refuseLevel)
        Returns a new authorizer instance based on an existing one which logs authorization results through the logging system.
        Parameters:
        auth - base authorizer
        acceptLevel - logging level at which auth acceptances are logged
        refuseLevel - logging level at which auth refusals are logged
        Returns:
        new authorizer
      • getAppName

        public static java.lang.String getAppName​(java.util.Map securityMap)
                                           throws SampException
        Returns the mandatory application name entry from the security map supplied explicitly by clients wishing to register. The relevant key is "samp.name" (Metadata.NAME_KEY). If it's not present and correct, a SampException is thrown indicating that registration is rejected.
        Parameters:
        securityMap - map supplied by client
        Returns:
        value of samp.name key, not null
        Throws:
        SampException - if name not present