Package de.esoco.lib.net
Schnittstelle ExternalServiceAccess
public interface ExternalServiceAccess
An interface that defines the methods needed to access external services that
are secured by an authorization method (typically the OAuth protocol).
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungauthorizeExternalServiceAccess
(ExternalServiceDefinition serviceDefinition, AuthorizationCallback callback, boolean forceAuth, Object... accessScopes) Performs an authorization of the access to an external service.createExternalServiceRequest
(ExternalServiceDefinition serviceDefinition, ExternalService.AccessType accessType, String requestUrl) Creates a request to an external service.void
revokeExternalServiceAccess
(ExternalServiceDefinition serviceDefinition) Revokes any previously authorized access to an external service.
-
Methodendetails
-
authorizeExternalServiceAccess
String authorizeExternalServiceAccess(ExternalServiceDefinition serviceDefinition, AuthorizationCallback callback, boolean forceAuth, Object... accessScopes) throws Exception Performs an authorization of the access to an external service. The invocation of this method can have two possible results. The first is a URL that needs to be visited by the user to confirm the authorization request before the access to the service will be granted. This is typically the case for services using an OAuth protocol. After the confirmation has succeeded the remote server will callback this service with the authorization request and the given callback object will be notified of the granted access code.The second possibility is that the access had previously been granted already and is still valid or could be refreshed and therefore the callback object will be invoked immediately. In that case the return value will be NULL.
Some external services (e.g. Google) provide access to multiple functionalities that must be named when requesting access to the service. This can be done with the access scopes parameter. The scope objects should have a string representation that can be interpreted by the corresponding service implementation.
- Parameter:
serviceDefinition
- The definition of the service to authorizecallback
- The callback to be notified of successful authorizationforceAuth
- TRUE to force the authorization even if cached authorization tokens or similar existaccessScopes
- The optional access scopes- Gibt zurück:
- A verification URL or NULL if no verification is necessary
- Löst aus:
Exception
- If the authorization fails
-
createExternalServiceRequest
ExternalServiceRequest createExternalServiceRequest(ExternalServiceDefinition serviceDefinition, ExternalService.AccessType accessType, String requestUrl) throws Exception Creates a request to an external service. The access to the external service must have been authorized previously by a call to the methodauthorizeExternalServiceAccess(ExternalServiceDefinition, AuthorizationCallback, boolean, Object...)
.- Parameter:
serviceDefinition
- The type of service to create the request foraccessType
- The service access typerequestUrl
- The URL of the service request- Gibt zurück:
- The service request instance
- Löst aus:
Exception
- If creating the request fails
-
revokeExternalServiceAccess
Revokes any previously authorized access to an external service. This is typically handled by removing all internal references and authorization tokens to the external service for the current user from the system.- Parameter:
serviceDefinition
- The definition of the service to revoke the access to- Löst aus:
Exception
- In the case of unrecoverable errors
-