Class AuthorizationHandler
- java.lang.Object
-
- org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
-
- org.openstreetmap.josm.io.remotecontrol.handler.AuthorizationHandler
-
public class AuthorizationHandler extends RequestHandler
Handle authorization requests (mostly OAuth)- Since:
- 18650
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AuthorizationHandler.AuthorizationConsumer
The actual authorization consumer/handlerstatic class
AuthorizationHandler.ResponseRecord
A basic record for changing responses-
Nested classes/interfaces inherited from class org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
RequestHandler.PermissionCache, RequestHandler.RawURLParseRequestHandler, RequestHandler.RequestHandlerBadRequestException, RequestHandler.RequestHandlerErrorException, RequestHandler.RequestHandlerException, RequestHandler.RequestHandlerForbiddenException, RequestHandler.RequestHandlerOsmApiException
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.String,AuthorizationHandler.AuthorizationConsumer>
AUTHORIZATION_CONSUMERS
static java.lang.String
command
The remote control commandprivate AuthorizationHandler.AuthorizationConsumer
consumer
private static BooleanProperty
PROPERTY
-
Fields inherited from class org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
args, content, contentType, GLOBAL_CONFIRMATION, LOAD_IN_NEW_LAYER, myCommand, OSM_DOWNLOAD_TIMEOUT, PERMISSIONS, request, sender, SPLITTER_COMMA, SPLITTER_SEMIC
-
-
Constructor Summary
Constructors Constructor Description AuthorizationHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
addAuthorizationConsumer(java.lang.String state, AuthorizationHandler.AuthorizationConsumer consumer)
Add an authorization consumer.java.lang.String[]
getMandatoryParams()
Returns the mandatory parameters.java.lang.String
getPermissionMessage()
Get a specific message to ask the user for permission for the operation requested via remote control.PermissionPrefWithDefault
getPermissionPref()
Get a PermissionPref object containing the name of a special permission preference to individually allow the requested operation and an error message to be displayed when a disabled operation is requested.BooleanProperty
getPermissionPreference()
protected void
handleRequest()
Handle a specific command sent as remote control.protected void
validateRequest()
Validates the request before attempting to perform it.-
Methods inherited from class org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler
checkMandatoryParams, checkPermission, getCommand, getContent, getContentType, getDownloadParams, getOptionalParams, getRequestParameter, getUsage, getUsageExamples, getUsageExamples, handle, parseArgs, setCommand, setSender, setUrl, splitArg, validateDownloadParams
-
-
-
-
Field Detail
-
command
public static final java.lang.String command
The remote control command- See Also:
- Constant Field Values
-
PROPERTY
private static final BooleanProperty PROPERTY
-
AUTHORIZATION_CONSUMERS
private static final java.util.Map<java.lang.String,AuthorizationHandler.AuthorizationConsumer> AUTHORIZATION_CONSUMERS
-
consumer
private AuthorizationHandler.AuthorizationConsumer consumer
-
-
Constructor Detail
-
AuthorizationHandler
public AuthorizationHandler()
-
-
Method Detail
-
addAuthorizationConsumer
public static void addAuthorizationConsumer(java.lang.String state, AuthorizationHandler.AuthorizationConsumer consumer)
Add an authorization consumer.- Parameters:
state
- The unique state for each request (for OAuth, this would be thestate
parameter)consumer
- The consumer of the response
-
validateRequest
protected void validateRequest() throws RequestHandler.RequestHandlerBadRequestException
Description copied from class:RequestHandler
Validates the request before attempting to perform it.- Specified by:
validateRequest
in classRequestHandler
- Throws:
RequestHandler.RequestHandlerBadRequestException
- if request is invalid
-
handleRequest
protected void handleRequest() throws RequestHandler.RequestHandlerErrorException, RequestHandler.RequestHandlerBadRequestException
Description copied from class:RequestHandler
Handle a specific command sent as remote control. Any time-consuming operation must be performed asynchronously to avoid delaying the HTTP response.This method of the subclass will do the real work.
- Specified by:
handleRequest
in classRequestHandler
- Throws:
RequestHandler.RequestHandlerErrorException
- if an error occurs while processing requestRequestHandler.RequestHandlerBadRequestException
- if request is invalid
-
getPermissionMessage
public java.lang.String getPermissionMessage()
Description copied from class:RequestHandler
Get a specific message to ask the user for permission for the operation requested via remote control.This message will be displayed to the user if the preference remotecontrol.always-confirm is true.
- Specified by:
getPermissionMessage
in classRequestHandler
- Returns:
- the message
-
getPermissionPref
public PermissionPrefWithDefault getPermissionPref()
Description copied from class:RequestHandler
Get a PermissionPref object containing the name of a special permission preference to individually allow the requested operation and an error message to be displayed when a disabled operation is requested.Default is not to check any special preference. Override this in a subclass to define permission preference and error message.
- Specified by:
getPermissionPref
in classRequestHandler
- Returns:
- the preference name and error message or null
-
getPermissionPreference
public BooleanProperty getPermissionPreference()
-
getMandatoryParams
public java.lang.String[] getMandatoryParams()
Description copied from class:RequestHandler
Returns the mandatory parameters. Both used to enforce their presence at runtime and for documentation.- Specified by:
getMandatoryParams
in classRequestHandler
- Returns:
- the mandatory parameters
-
-