Class OAuthManager
java.lang.Object
energy.eddie.regionconnector.nl.mijn.aansluiting.oauth.OAuthManager
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOAuthManager(MijnAansluitingConfiguration configuration, PrivateKey privateKey, com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata providerMetadata, com.nimbusds.jwt.proc.JWTProcessor<com.nimbusds.jose.proc.SecurityContext> jwtProcessor, OAuthTokenRepository repository, NlPermissionRequestRepository permissionRequestRepository) -
Method Summary
Modifier and TypeMethodDescriptionaccessTokenAndSingleSyncUrl(String permissionId) Returns a valid access token and the endpoint to request the data fromcreateAuthorizationUrl(String verificationCode) Creates an authorization URL.processCallback(URI callbackUri, String permissionId) Validates the callback uri parameters, in case they are not valid an exception is thrown.
-
Field Details
-
CLIENT_ID
- See Also:
-
-
Constructor Details
-
OAuthManager
public OAuthManager(MijnAansluitingConfiguration configuration, PrivateKey privateKey, com.nimbusds.openid.connect.sdk.op.OIDCProviderMetadata providerMetadata, com.nimbusds.jwt.proc.JWTProcessor<com.nimbusds.jose.proc.SecurityContext> jwtProcessor, OAuthTokenRepository repository, NlPermissionRequestRepository permissionRequestRepository)
-
-
Method Details
-
createAuthorizationUrl
Creates an authorization URL.- Parameters:
verificationCode- the house number or verification code- Returns:
- a redirect URI
-
processCallback
public String processCallback(URI callbackUri, String permissionId) throws com.nimbusds.oauth2.sdk.ParseException, OAuthException, PermissionNotFoundException, IllegalTokenException, JWTSignatureCreationException, UserDeniedAuthorizationException, InvalidValidationAddressException, OAuthUnavailableException Validates the callback uri parameters, in case they are not valid an exception is thrown. If the callback uri is valid the access and/or refresh tokens are requested from the authorization server. These are persisted to the database on success.- Parameters:
callbackUri- the original callback URI containing all query parameters provided by the authorization server.permissionId- the permission ID of the permission request associated with this callback.- Returns:
- the permissionId on success
- Throws:
com.nimbusds.oauth2.sdk.ParseException- when the callback URI could not be parsedOAuthException- when an unexpected exception is thrown during processing the callbackPermissionNotFoundException- when the permission request the callback references does not existIllegalTokenException- when the token response from the authorization server could not be parsedJWTSignatureCreationException- when the private key JWZ could not be createdUserDeniedAuthorizationException- when the final customer did not accept the permission requestInvalidValidationAddressException- when the final customer provided an invalid address to validate the permission request with the permission administratorOAuthUnavailableException- when the authorization server is not available
-
accessTokenAndSingleSyncUrl
public AccessTokenAndSingleSyncUrl accessTokenAndSingleSyncUrl(String permissionId) throws OAuthException, JWTSignatureCreationException, IllegalTokenException, NoRefreshTokenException, OAuthUnavailableException Returns a valid access token and the endpoint to request the data from- Parameters:
permissionId- the permission ID associated with the tokens- Returns:
- an access token and the endpoint to request data from
- Throws:
OAuthException- a general exception in case of an unexpected errorJWTSignatureCreationException- when the private key JWT could not be createdIllegalTokenException- when the token response could not be parsedNoRefreshTokenException- when the permission request does not contain a refresh token and the access token cannot be refreshedOAuthUnavailableException- when the OAuth server is not available
-