com.sap.cloud.yaas.servicesdk.authorization.AccessTokenRequestException Maven / Gradle / Ivy
/*
* © 2016 SAP SE or an SAP affiliate company.
* All rights reserved.
* Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and
* notices.
*/
package com.sap.cloud.yaas.servicesdk.authorization;
/**
* Thrown when an Access Token Request to an OAuth 2.0 Authorization Server fails.
*
* Note, that this kind of exception is usually due to an implementation flaw or mis-configuration of the client that
* tries to request the {@link AccessToken}. It may also be caused by problems with the backing
* Authorization Server, or with the underlying infrastructure. In any case, if the client itself cannot
* recover from this exception, it should report it as an internal problem. (E.g., when the client is a web-service
* itself, it should respond to the current HTTP request with an response status from the 500 family should be used.)
*/
public class AccessTokenRequestException extends RuntimeException
{
private static final long serialVersionUID = 8180623329531286974L;
private final AuthorizationScope requestedScope;
/**
* Creates a new instance using given message and requested scope.
*
* @param message detail message
* @param scope the scope that was requested
*/
public AccessTokenRequestException(final String message, final AuthorizationScope scope)
{
this(message, scope, null);
}
/**
* Creates a new instance using given message, requested scope, and a cause.
*
* @param message detail message
* @param scope the scope that was requested
* @param cause root cause
*/
public AccessTokenRequestException(final String message, final AuthorizationScope scope, final Throwable cause)
{
super("Requesting an access token for " + scope + " failed: " + message, cause);
this.requestedScope = scope;
}
public AuthorizationScope getRequestedScope()
{
return requestedScope;
}
}