Class Property
- java.lang.Object
-
- com.authlete.common.dto.Property
-
- All Implemented Interfaces:
Serializable
public class Property extends Object implements Serializable
Property that consists of a string key and a string value.This class is used mainly to represent an extra property that is associated with an access token. Some Authlete APIs (such as
/api/auth/tokenAPI) accept an array of properties viapropertiesrequest parameter and associate the properties with an access token.- Since:
- 1.32
- Author:
- Takahiko Kawasaki
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Property()Constructor with anullkey and anullvalue.Property(String key, String value)Constructor with a pair of key and value.Property(String key, String value, boolean hidden)Constructor with a pair of key and value, and a flag to mark this property as hidden or not.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetKey()Get the key.StringgetValue()Get the value.booleanisHidden()Check if this property is hidden from client applications.PropertysetHidden(boolean hidden)Set this property hidden from or visible to client applications.PropertysetKey(String key)Set the key.PropertysetValue(String value)Set the value.StringtoString()Get the string representation of this property in the format of"{key}={value}".
-
-
-
Constructor Detail
-
Property
public Property()
Constructor with anullkey and anullvalue.
-
Property
public Property(String key, String value)
Constructor with a pair of key and value. This is an alias ofthis(key, value, false).- Parameters:
key-value-
-
Property
public Property(String key, String value, boolean hidden)
Constructor with a pair of key and value, and a flag to mark this property as hidden or not.- Parameters:
key-value-hidden-trueto mark this property as hidden. See the JavaDoc ofisHidden()for details.- Since:
- 1.33
-
-
Method Detail
-
getKey
public String getKey()
Get the key.- Returns:
- Key
-
getValue
public String getValue()
Get the value.- Returns:
- Value
-
setValue
public Property setValue(String value)
Set the value.- Parameters:
value- Value- Returns:
thisobject.
-
isHidden
public boolean isHidden()
Check if this property is hidden from client applications.If a property is not hidden, the property will come along with an access token. For example, if you set the
propertiesrequest parameter as follows when you call Authlete's/api/auth/tokenAPI,"properties": [ { "key":"example_parameter", "value":"example_value", "hidden":false } ]The value of
responseContentin the response from the API will contain the pair ofexample_parameterandexample_valuelike below,"responseContent": "{\"access_token\":\"(abbrev)\",\"example_parameter\":\"example_value\",...}"and this will result in that the client application will receive a JSON which contains the pair like the following.
{ "access_token":"(abbrev)", "example_parameter":"example_value", ... }On the other hand, if you mark a property as hidden like below,
"properties": [ { "key":"hidden_parameter", "value":"hidden_value", "hidden":true } ]the client application will never see the property in any response from your authorization server. However, of course, the property is still associated with the access token and it can be confirmed by calling Authlete's
/api/auth/introspectionAPI (which is an API to get information about an access token). A response from the API contains all properties associated with the given access token regardless of whether they are hidden or visible. The following is an example from Authlete's introspection API.{ "type":"introspectionResponse", "resultCode":"A056001", "resultMessage":"[A056001] The access token is valid.", "action":"OK", "clientId":5008706718, "existent":true, "expiresAt":1463310477000, "properties":[ { "hidden":false, "key":"example_parameter", "value":"example_value" }, { "hidden":true, "key":"hidden_parameter", "value":"hidden_value" } ], "refreshable":true, "responseContent":"Bearer error=\"invalid_request\"", "subject":"user123", "sufficient":true, "usable":true }- Returns:
trueif this property is hidden from client applications.falseif this property is visible to client applications.- Since:
- 1.33
-
setHidden
public Property setHidden(boolean hidden)
Set this property hidden from or visible to client applications. See the JavaDoc ofisHidden()method for the difference between hidden and visible.- Parameters:
hidden-trueto hide this property from client applications.falseto make this property visible to client applications.- Returns:
thisobject.- Since:
- 1.33
-
-