Package com.nimbusds.oauth2.sdk
Class ResourceOwnerPasswordCredentialsGrant
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.AuthorizationGrant
-
- com.nimbusds.oauth2.sdk.ResourceOwnerPasswordCredentialsGrant
-
@Immutable public class ResourceOwnerPasswordCredentialsGrant extends AuthorizationGrant
Resource owner password credentials grant. Used in access token requests with the resource owner's username and password.Related specifications:
- OAuth 2.0 (RFC 6749), section 4.3.2.
-
-
Field Summary
Fields Modifier and Type Field Description static GrantType
GRANT_TYPE
The grant type.
-
Constructor Summary
Constructors Constructor Description ResourceOwnerPasswordCredentialsGrant(String username, Secret password)
Creates a new resource owner password credentials grant.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Secret
getPassword()
Gets the resource owner's password.String
getUsername()
Gets the resource owner's username.int
hashCode()
static ResourceOwnerPasswordCredentialsGrant
parse(Map<String,List<String>> params)
Parses a resource owner password credentials grant from the specified request body parameters.Map<String,List<String>>
toParameters()
Returns the request body parameters for the authorisation grant.-
Methods inherited from class com.nimbusds.oauth2.sdk.AuthorizationGrant
getType
-
-
-
-
Field Detail
-
GRANT_TYPE
public static final GrantType GRANT_TYPE
The grant type.
-
-
Constructor Detail
-
ResourceOwnerPasswordCredentialsGrant
public ResourceOwnerPasswordCredentialsGrant(String username, Secret password)
Creates a new resource owner password credentials grant.- Parameters:
username
- The resource owner's username. Must not benull
.password
- The resource owner's password. Must not benull
.
-
-
Method Detail
-
getUsername
public String getUsername()
Gets the resource owner's username.- Returns:
- The username.
-
getPassword
public Secret getPassword()
Gets the resource owner's password.- Returns:
- The password.
-
toParameters
public Map<String,List<String>> toParameters()
Description copied from class:AuthorizationGrant
Returns the request body parameters for the authorisation grant.- Specified by:
toParameters
in classAuthorizationGrant
- Returns:
- The parameters.
-
parse
public static ResourceOwnerPasswordCredentialsGrant parse(Map<String,List<String>> params) throws ParseException
Parses a resource owner password credentials grant from the specified request body parameters.Example:
grant_type=password username=johndoe password=A3ddj3w
- Parameters:
params
- The parameters.- Returns:
- The resource owner password credentials grant.
- Throws:
ParseException
- If parsing failed.
-
-