Class OAuth2AuthorizationConsent
java.lang.Object
org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationConsent
- All Implemented Interfaces:
Serializable
A representation of an OAuth 2.0 "consent" to an Authorization request, which holds
state related to the set of
authorities
granted to a
client
by the resource
owner
.
When authorizing access for a given client, the resource owner may only grant a subset
of the authorities the client requested. The typical use-case is the
authorization_code
flow, in which the client requests a set of scope
s.
The resource owner then selects which scopes they grant to the client.
- Since:
- 0.1.2
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
from
(OAuth2AuthorizationConsent authorizationConsent) Returns a newOAuth2AuthorizationConsent.Builder
, initialized with the values from the providedOAuth2AuthorizationConsent
.Set<org.springframework.security.core.GrantedAuthority>
Returns theauthorities
granted to the client by the principal.Returns thePrincipal
name of the resource owner (or client).Returns the identifier for theregistered client
.Convenience method for obtaining thescope
s granted to the client by the principal, extracted from theauthorities
.int
hashCode()
Returns a newOAuth2AuthorizationConsent.Builder
, initialized with the givenregisteredClientId
andPrincipal
name.
-
Method Details
-
getRegisteredClientId
Returns the identifier for theregistered client
.- Returns:
- the
RegisteredClient.getId()
-
getPrincipalName
Returns thePrincipal
name of the resource owner (or client).- Returns:
- the
Principal
name of the resource owner (or client)
-
getAuthorities
Returns theauthorities
granted to the client by the principal.- Returns:
- the
authorities
granted to the client by the principal.
-
getScopes
Convenience method for obtaining thescope
s granted to the client by the principal, extracted from theauthorities
.- Returns:
- the
scope
s granted to the client by the principal.
-
equals
-
hashCode
public int hashCode() -
from
public static OAuth2AuthorizationConsent.Builder from(OAuth2AuthorizationConsent authorizationConsent) Returns a newOAuth2AuthorizationConsent.Builder
, initialized with the values from the providedOAuth2AuthorizationConsent
.- Parameters:
authorizationConsent
- theOAuth2AuthorizationConsent
used for initializing theOAuth2AuthorizationConsent.Builder
- Returns:
- the
OAuth2AuthorizationConsent.Builder
-
withId
public static OAuth2AuthorizationConsent.Builder withId(@NonNull String registeredClientId, @NonNull String principalName) Returns a newOAuth2AuthorizationConsent.Builder
, initialized with the givenregisteredClientId
andPrincipal
name.- Parameters:
registeredClientId
- theRegisteredClient.getId()
principalName
- thePrincipal
name- Returns:
- the
OAuth2AuthorizationConsent.Builder
-