Package com.nimbusds.oauth2.sdk.device
Class DeviceAuthorizationSuccessResponse
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.device.DeviceAuthorizationResponse
-
- com.nimbusds.oauth2.sdk.device.DeviceAuthorizationSuccessResponse
-
- All Implemented Interfaces:
Message
,Response
,SuccessResponse
@Immutable public class DeviceAuthorizationSuccessResponse extends DeviceAuthorizationResponse implements SuccessResponse
A device authorization response from the device authorization endpoint.Example HTTP response:
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Cache-Control: no-store Pragma: no-cache { "device_code" : "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS", "user_code" : "WDJB-MJHT", "verification_uri" : "https://example.com/device", "verification_uri_complete" : "https://example.com/device?user_code=WDJB-MJHT", "expires_in" : 1800, "interval" : 5 }
Related specifications:
- OAuth 2.0 Device Authorization Grant (RFC 8628), section 3.2.
-
-
Constructor Summary
Constructors Constructor Description DeviceAuthorizationSuccessResponse(DeviceCode deviceCode, UserCode userCode, URI verificationURI, long lifetime)
Creates a new device authorization success response.DeviceAuthorizationSuccessResponse(DeviceCode deviceCode, UserCode userCode, URI verificationURI, URI verificationURIComplete, long lifetime, long interval, Map<String,Object> customParams)
Creates a new device authorization success response.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Map<String,Object>
getCustomParameters()
Returns the custom parameters.DeviceCode
getDeviceCode()
Returns the device verification code.long
getInterval()
Returns the minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.long
getLifetime()
Returns the lifetime in seconds of the "device_code" and "user_code".static Set<String>
getRegisteredParameterNames()
Returns the registered (standard) OAuth 2.0 device authorization response parameter names.UserCode
getUserCode()
Returns the end-user verification code.URI
getVerificationUri()
Deprecated.URI
getVerificationURI()
Returns the end-user verification URI on the authorization server.URI
getVerificationUriComplete()
Deprecated.URI
getVerificationURIComplete()
Returns the end-user verification URI that includes the user_code.boolean
indicatesSuccess()
Checks if the response indicates success.static DeviceAuthorizationSuccessResponse
parse(HTTPResponse httpResponse)
Parses an device authorization response from the specified HTTP response.static DeviceAuthorizationSuccessResponse
parse(net.minidev.json.JSONObject jsonObject)
Parses an device authorization response from the specified JSON object.HTTPResponse
toHTTPResponse()
Returns the matching HTTP response.net.minidev.json.JSONObject
toJSONObject()
Returns a JSON object representation of this device authorization response.-
Methods inherited from class com.nimbusds.oauth2.sdk.device.DeviceAuthorizationResponse
toErrorResponse, toSuccessResponse
-
-
-
-
Constructor Detail
-
DeviceAuthorizationSuccessResponse
public DeviceAuthorizationSuccessResponse(DeviceCode deviceCode, UserCode userCode, URI verificationURI, long lifetime)
Creates a new device authorization success response.- Parameters:
deviceCode
- The device verification code. Must not benull
.userCode
- The user verification code. Must not benull
.verificationURI
- The end-user verification URI on the authorization server. Must not benull
.lifetime
- The lifetime in seconds of the "device_code" and "user_code".
-
DeviceAuthorizationSuccessResponse
public DeviceAuthorizationSuccessResponse(DeviceCode deviceCode, UserCode userCode, URI verificationURI, URI verificationURIComplete, long lifetime, long interval, Map<String,Object> customParams)
Creates a new device authorization success response.- Parameters:
deviceCode
- The device verification code. Must not benull
.userCode
- The user verification code. Must not benull
.verificationURI
- The end-user verification URI on the authorization server. Must not benull
.verificationURIComplete
- The end-user verification URI on the authorization server that includes the user_code. Can benull
.lifetime
- The lifetime in seconds of the "device_code" and "user_code". Must be greater than0
.interval
- The minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.customParams
- Optional custom parameters,null
if none.
-
-
Method Detail
-
getRegisteredParameterNames
public static Set<String> getRegisteredParameterNames()
Returns the registered (standard) OAuth 2.0 device authorization response parameter names.- Returns:
- The registered OAuth 2.0 device authorization response parameter names, as a unmodifiable set.
-
indicatesSuccess
public boolean indicatesSuccess()
Description copied from interface:Response
Checks if the response indicates success.- Specified by:
indicatesSuccess
in interfaceResponse
- Returns:
true
if the response indicates success, elsefalse
.
-
getDeviceCode
public DeviceCode getDeviceCode()
Returns the device verification code.- Returns:
- The device verification code.
-
getUserCode
public UserCode getUserCode()
Returns the end-user verification code.- Returns:
- The end-user verification code.
-
getVerificationURI
public URI getVerificationURI()
Returns the end-user verification URI on the authorization server.- Returns:
- The end-user verification URI on the authorization server.
-
getVerificationUri
@Deprecated public URI getVerificationUri()
Deprecated.- See Also:
getVerificationURI()
-
getVerificationURIComplete
public URI getVerificationURIComplete()
Returns the end-user verification URI that includes the user_code.- Returns:
- The end-user verification URI that includes the user_code,
or
null
if not specified.
-
getVerificationUriComplete
@Deprecated public URI getVerificationUriComplete()
Deprecated.- See Also:
getVerificationURIComplete()
-
getLifetime
public long getLifetime()
Returns the lifetime in seconds of the "device_code" and "user_code".- Returns:
- The lifetime in seconds of the "device_code" and "user_code".
-
getInterval
public long getInterval()
Returns the minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.- Returns:
- The minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.
-
getCustomParameters
public Map<String,Object> getCustomParameters()
Returns the custom parameters.- Returns:
- The custom parameters, as a unmodifiable map, empty map if none.
-
toJSONObject
public net.minidev.json.JSONObject toJSONObject()
Returns a JSON object representation of this device authorization response.Example JSON object:
{ "device_code" : "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS", "user_code" : "WDJB-MJHT", "verification_uri" : "https://example.com/device", "verification_uri_complete" : "https://example.com/device?user_code=WDJB-MJHT", "expires_in" : 1800, "interval" : 5 }
- Returns:
- The JSON object.
-
toHTTPResponse
public HTTPResponse toHTTPResponse()
Description copied from interface:Response
Returns the matching HTTP response.- Specified by:
toHTTPResponse
in interfaceResponse
- Returns:
- The HTTP response.
-
parse
public static DeviceAuthorizationSuccessResponse parse(net.minidev.json.JSONObject jsonObject) throws ParseException
Parses an device authorization response from the specified JSON object.- Parameters:
jsonObject
- The JSON object to parse. Must not benull
.- Returns:
- The device authorization response.
- Throws:
ParseException
- If the JSON object couldn't be parsed to a device authorization response.
-
parse
public static DeviceAuthorizationSuccessResponse parse(HTTPResponse httpResponse) throws ParseException
Parses an device authorization response from the specified HTTP response.- Parameters:
httpResponse
- The HTTP response. Must not benull
.- Returns:
- The device authorization response.
- Throws:
ParseException
- If the HTTP response couldn't be parsed to a device authorization response.
-
-