Documentation

Property implements ArrayCopyable, Arrayable, Jsonable Uses ArrayTrait, JsonTrait

A property associated with an access token and/or an authorization code.

Some Authlete APIs accept a properties request parameter. The value of the parameter is an array of \Authlete\Dto\Property.

Interfaces, Classes and Traits

ArrayCopyable
Interface to declare instances can be converted into/from arrays.
Arrayable
Interface to declare that instances can be converted into an array.
Jsonable
Interface to declare that instances can be converted into JSON strings.

Table of Contents

__construct()  : mixed
Constructor.
copyFromArray()  : mixed
Copy the content of the given array into this object.
copyToArray()  : mixed
Copy the content of this object into the given array.
fromArray()  : static
Convert an array into an instance of this class.
fromJson()  : static
Convert a JSON string into an instance of this class.
getKey()  : string
Get the name of this property.
getValue()  : string
Get the value of this property.
isHidden()  : bool
Get the flag which indicates whether this property is hidden from the client application or not.
setHidden()  : Property
Set the flag which indicates whether this property is hidden from the client application or not.
setKey()  : Property
Set the name of this property.
setValue()  : Property
Set the value of this property.
toArray()  : array<string|int, mixed>
Convert this object into an array.
toJson()  : string
Convert this object into a JSON string.

Methods

__construct()

Constructor.

public __construct([string $key = null ][, string $value = null ][, bool $hidden = false ]) : mixed
Parameters
$key : string = null

The name of this property.

$value : string = null

The value of this property.

$hidden : bool = false

true to mark this property as hidden. Read the description of setHidden($hidden) for details.

Return values
mixed

copyFromArray()

Copy the content of the given array into this object.

public copyFromArray(array<string|int, mixed> &$array) : mixed
Parameters
$array : array<string|int, mixed>
Return values
mixed

copyToArray()

Copy the content of this object into the given array.

public copyToArray(array<string|int, mixed> &$array) : mixed
Parameters
$array : array<string|int, mixed>
Return values
mixed

fromArray()

Convert an array into an instance of this class.

public static fromArray([array<string|int, mixed> $array = null ]) : static

This static function returns a new instance of this class. If $array is null, null is returned.

Parameters
$array : array<string|int, mixed> = null

An array

Return values
static

An instance of this class.

fromJson()

Convert a JSON string into an instance of this class.

public static fromJson(string $json) : static

This static function returns a new instance of this class. If $json is null or the type of $json is not string, null is returned.

Parameters
$json : string

A JSON string.

Return values
static

An instance of this class.

getKey()

Get the name of this property.

public getKey() : string
Return values
string

The name of this property.

getValue()

Get the value of this property.

public getValue() : string
Return values
string

The value of this property.

isHidden()

Get the flag which indicates whether this property is hidden from the client application or not.

public isHidden() : bool
Return values
bool

true if this property is hidden from the client application.

setHidden()

Set the flag which indicates whether this property is hidden from the client application or not.

public setHidden(bool $hidden) : Property

If a property is not hidden, information about the property will be sent back to the client application with an access token. For example, if you set the properties request prameter as follows when you call Authlete's /api/auth/token API,

"properties": [
  {
    "key":    "example_parameter",
    "value":  "example_value",
    "hidden": false
  }
]

The value of the responseContent response parameter in the response from the API will contain the pair of example_parameter and example_value like 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/introspection API (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 response from Authlete's /api/auth/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
}
Parameters
$hidden : bool

true to hide this property from the client application

Return values
Property

$this property.

setKey()

Set the name of this property.

public setKey(string $key) : Property
Parameters
$key : string

The name of this property.

Return values
Property

$this object.

setValue()

Set the value of this property.

public setValue(string $value) : Property
Parameters
$value : string

The value of this property.

Return values
Property

$this object.

toArray()

Convert this object into an array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array.

toJson()

Convert this object into a JSON string.

public toJson(int $options) : string
Parameters
$options : int

Options passed to json_encode(). This parameter is optional and its default value is 0.

Return values
string

A JSON string.

Search results