forked from stevenmaguire/oauth2-keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeycloakResourceOwner.php
95 lines (84 loc) · 1.97 KB
/
KeycloakResourceOwner.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Stevenmaguire\OAuth2\Client\Provider;
use League\OAuth2\Client\Provider\ResourceOwnerInterface;
class KeycloakResourceOwner implements ResourceOwnerInterface
{
/**
* Raw response
*
* @var array
*/
protected $response;
/**
* Creates new resource owner.
*
* @param array $response
*/
public function __construct(array $response = array())
{
$this->response = $response;
}
/**
* Get resource owner id
*
* @return string|null
*/
public function getId()
{
return \array_key_exists('sub', $this->response) ? $this->response['sub'] : null;
}
/**
* Get resource owner email
*
* @return string|null
*/
public function getEmail()
{
return \array_key_exists('email', $this->response) ? $this->response['email'] : null;
}
/**
* Get resource owner name
*
* @return string|null
*/
public function getName()
{
return \array_key_exists('name', $this->response) ? $this->response['name'] : null;
}
/**
* Get resource owner username
*
* @return string|null
*/
public function getUsername()
{
return \array_key_exists('preferred_username', $this->response) ? $this->response['preferred_username'] : null;
}
/**
* Get resource owner first name
*
* @return string|null
*/
public function getFirstName()
{
return \array_key_exists('given_name', $this->response) ? $this->response['given_name'] : null;
}
/**
* Get resource owner last name
*
* @return string|null
*/
public function getLastName()
{
return \array_key_exists('family_name', $this->response) ? $this->response['family_name'] : null;
}
/**
* Return all of the owner details available as an array.
*
* @return array
*/
public function toArray()
{
return $this->response;
}
}