-
-
Notifications
You must be signed in to change notification settings - Fork 188
/
TokenInterface.php
159 lines (139 loc) · 4.86 KB
/
TokenInterface.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
namespace Neos\Flow\Security\Authentication;
/*
* This file is part of the Neos.Flow package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Security\Account;
/**
* Contract for an authentication token.
*
*/
interface TokenInterface
{
/**
* This is the default state. The token is not authenticated and holds no credentials, that could be used for authentication.
*/
const NO_CREDENTIALS_GIVEN = 1;
/**
* It was tried to authenticate the token, but the credentials were wrong.
*/
const WRONG_CREDENTIALS = 2;
/**
* The token has been successfully authenticated.
*/
const AUTHENTICATION_SUCCESSFUL = 3;
/**
* This indicates, that the token received credentials, but has not been authenticated yet.
*/
const AUTHENTICATION_NEEDED = 4;
/**
* Returns the name of the authentication provider responsible for this token
*
* @return string The authentication provider name
*/
public function getAuthenticationProviderName();
/**
* Sets the name of the authentication provider responsible for this token
*
* @param string $authenticationProviderName The authentication provider name
* @return void
*/
public function setAuthenticationProviderName($authenticationProviderName);
/**
* Returns true if this token is currently authenticated
*
* @return boolean true if this this token is currently authenticated
*/
public function isAuthenticated();
/**
* Sets the authentication status. Usually called by the responsible AuthenticationManagerInterface
*
* @param integer $authenticationStatus One of NO_CREDENTIALS_GIVEN, WRONG_CREDENTIALS, AUTHENTICATION_SUCCESSFUL
* @return void
*/
public function setAuthenticationStatus($authenticationStatus);
/**
* Returns the current authentication status
*
* @return integer One of NO_CREDENTIALS_GIVEN, WRONG_CREDENTIALS, AUTHENTICATION_SUCCESSFUL, REAUTHENTICATION_NEEDED
*/
public function getAuthenticationStatus();
/**
* Sets the authentication entry point
*
* @param EntryPointInterface $entryPoint The authentication entry point
* @return void
*/
public function setAuthenticationEntryPoint(EntryPointInterface $entryPoint);
/**
* Returns the configured authentication entry point, NULL if none is available
*
* @return EntryPointInterface The configured authentication entry point, NULL if none is available
*/
public function getAuthenticationEntryPoint();
/**
* Returns true if \Neos\Flow\Security\RequestPattern were set
*
* @return boolean True if a \Neos\Flow\Security\RequestPatternInterface was set
*/
public function hasRequestPatterns();
/**
* Sets request patterns
*
* @param array $requestPatterns Array of \Neos\Flow\Security\RequestPatternInterface to be set
* @return void
* @see hasRequestPattern()
*/
public function setRequestPatterns(array $requestPatterns);
/**
* Returns an array of set \Neos\Flow\Security\RequestPatternInterface, NULL if none was set
*
* @return array Array of set request patterns
* @see hasRequestPattern()
*/
public function getRequestPatterns();
/**
* Updates the authentication credentials, the authentication manager needs to authenticate this token.
* This could be a username/password from a login controller.
* This method is called while initializing the security context. By returning true you
* make sure that the authentication manager will (re-)authenticate the tokens with the current credentials.
* Note: You should not persist the credentials!
*
* @param ActionRequest $actionRequest The current request instance
* @return void
*/
public function updateCredentials(ActionRequest $actionRequest);
/**
* Returns the credentials of this token. The type depends on the provider
* of the token.
*
* @return mixed $credentials The needed credentials to authenticate this token
*/
public function getCredentials();
/**
* Returns the account if one is authenticated, NULL otherwise.
*
* @return Account An account object
*/
public function getAccount();
/**
* Set the (authenticated) account
*
* @param Account $account An account object
* @return void
*/
public function setAccount(Account $account = null);
/**
* Returns a string representation of the token for logging purposes.
*
* @return string A string representation of the token
*/
public function __toString();
}