Package org.astrogrid.samp.web
Class ClientAuthorizers
java.lang.Object
org.astrogrid.samp.web.ClientAuthorizers
Utility class containing ClientAuthorizer implementations.
- Since:
- 2 Feb 2011
- Author:
- Mark Taylor
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClientAuthorizer
Authorizer which always denies access, with INFO logging either way.static final ClientAuthorizer
Authorizer which always permits access, with WARNING logging either way. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClientAuthorizer
createFixedClientAuthorizer
(boolean policy) Returns a new authorizer instance which always produces the same authorization status.static ClientAuthorizer
createLoggingClientAuthorizer
(ClientAuthorizer auth, Level acceptLevel, Level refuseLevel) Returns a new authorizer instance based on an existing one which logs authorization results through the logging system.static String
getAppName
(Map securityMap) Returns the mandatory application name entry from the security map supplied explicitly by clients wishing to register.
-
Field Details
-
FALSE
Authorizer which always denies access, with INFO logging either way. -
TRUE
Authorizer which always permits access, with WARNING logging either way.
-
-
Method Details
-
createFixedClientAuthorizer
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, Level acceptLevel, Level refuseLevel) Returns a new authorizer instance based on an existing one which logs authorization results through the logging system.- Parameters:
auth
- base authorizeracceptLevel
- logging level at which auth acceptances are loggedrefuseLevel
- logging level at which auth refusals are logged- Returns:
- new authorizer
-
getAppName
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
-