com.sap.cloud.yaas.servicesdk.authorization.AccessTokenScopeException 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 fails, because the acquired token does not satisfy the requested
* OAuth 2.0 scope.
*
* @see http://tools.ietf.org/html/rfc6749#section-5.1
*/
public class AccessTokenScopeException extends AccessTokenRequestException
{
private static final long serialVersionUID = 3881976186046093411L;
private final AccessToken downScopedAccessToken;
/**
* Creates a new instance using given requested scope and received token.
*
* @param scope the scope that was originally requested
* @param token the down-scoped access token that was actually received (but whose scope does not satisfy the
* requested {@code scope})
*/
public AccessTokenScopeException(final AuthorizationScope scope, final AccessToken token)
{
this(scope, token, null);
}
/**
* Creates a new instance using given requested scope, received token, and a cause.
*
* @param scope the scope that was originally requested
* @param token the down-scoped access token that was actually received (but whose scope does not satisfy the
* requested {@code scope})
* @param cause root cause
*/
public AccessTokenScopeException(final AuthorizationScope scope, final AccessToken token, final Throwable cause)
{
super("Granted " + AuthorizationScope.fromAccessToken(token) + " does not satisfy requested scope.", scope, cause);
this.downScopedAccessToken = token;
}
public AccessToken getDownScopedAccessToken()
{
return downScopedAccessToken;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy