gluu
公開メンバ関数 | 非公開メンバ関数 | 非公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.xdi.oxauth.model.registration.RegisterParamsValidator クラス
org.xdi.oxauth.model.registration.RegisterParamsValidator 連携図
Collaboration graph

公開メンバ関数

boolean validateParamsClientRegister (ApplicationType applicationType, SubjectType subjectType, List< String > redirectUris, String sectorIdentifierUrl)
 
boolean validateParamsClientRead (String clientId, String accessToken)
 
boolean validateRedirectUris (ApplicationType applicationType, SubjectType subjectType, List< String > redirectUris, String sectorIdentifierUrl)
 
void validateLogoutUri (List< String > logoutUris, List< String > redirectUris, ErrorResponseFactory errorResponseFactory)
 
void validateLogoutUri (String logoutUri, List< String > redirectUris, ErrorResponseFactory errorResponseFactory)
 

非公開メンバ関数

boolean checkWhiteListRedirectUris (List< String > redirectUris)
 
boolean checkBlackListRedirectUris (List< String > redirectUris)
 
void throwInvalidLogoutUri (ErrorResponseFactory errorResponseFactory) throws WebApplicationException
 
Set< String > collectUriHosts (List< String > uriList) throws URISyntaxException
 

非公開変数類

Logger log
 
AppConfiguration appConfiguration
 

静的非公開変数類

static final String HTTP = "http"
 
static final String HTTPS = "https"
 
static final String LOCALHOST = "localhost"
 
static final String LOOPBACK = "127.0.0.1"
 

詳解

Validates the parameters received for the register web service.

著者
Javier Rojas Blum
バージョン
April 19, 2017

関数詳解

◆ checkBlackListRedirectUris()

boolean org.xdi.oxauth.model.registration.RegisterParamsValidator.checkBlackListRedirectUris ( List< String >  redirectUris)
inlineprivate

None of the Redirect Uris must match to return true.

210  {
211  boolean valid = true;
212  List<String> blackList = appConfiguration.getClientBlackList();
213  URLPatternList urlPatternList = new URLPatternList(blackList);
214 
215  for (String redirectUri : redirectUris) {
216  valid &= !urlPatternList.isUrlListed(redirectUri);
217  }
218 
219  return valid;
220  }
List< String > getClientBlackList()
Definition: AppConfiguration.java:1257
AppConfiguration appConfiguration
Definition: RegisterParamsValidator.java:50

◆ checkWhiteListRedirectUris()

boolean org.xdi.oxauth.model.registration.RegisterParamsValidator.checkWhiteListRedirectUris ( List< String >  redirectUris)
inlineprivate

All the Redirect Uris must match to return true.

195  {
196  boolean valid = true;
197  List<String> whiteList = appConfiguration.getClientWhiteList();
198  URLPatternList urlPatternList = new URLPatternList(whiteList);
199 
200  for (String redirectUri : redirectUris) {
201  valid &= urlPatternList.isUrlListed(redirectUri);
202  }
203 
204  return valid;
205  }
AppConfiguration appConfiguration
Definition: RegisterParamsValidator.java:50
List< String > getClientWhiteList()
Definition: AppConfiguration.java:1249

◆ collectUriHosts()

Set<String> org.xdi.oxauth.model.registration.RegisterParamsValidator.collectUriHosts ( List< String >  uriList) throws URISyntaxException
inlineprivate
273  {
274  Set<String> hosts = new HashSet<String>();
275 
276  for (String redirectUri : uriList) {
277  URI uri = new URI(redirectUri);
278  hosts.add(uri.getHost());
279  }
280  return hosts;
281  }

◆ throwInvalidLogoutUri()

void org.xdi.oxauth.model.registration.RegisterParamsValidator.throwInvalidLogoutUri ( ErrorResponseFactory  errorResponseFactory) throws WebApplicationException
inlineprivate
264  {
265  throw new WebApplicationException(
266  Response.status(Response.Status.BAD_REQUEST.getStatusCode()).
267  entity(errorResponseFactory.getErrorAsJson(RegisterErrorResponseType.INVALID_LOGOUT_URI)).
268  cacheControl(ServerUtil.cacheControl(true, false)).
269  header("Pragma", "no-cache").
270  build());
271  }

◆ validateLogoutUri() [1/2]

void org.xdi.oxauth.model.registration.RegisterParamsValidator.validateLogoutUri ( List< String >  logoutUris,
List< String >  redirectUris,
ErrorResponseFactory  errorResponseFactory 
)
inline
222  {
223  if (logoutUris == null || logoutUris.isEmpty()) { // logout uri is optional so null or empty list is valid
224  return;
225  }
226  for (String logoutUri : logoutUris) {
227  validateLogoutUri(logoutUri, redirectUris, errorResponseFactory);
228  }
229  }
void validateLogoutUri(List< String > logoutUris, List< String > redirectUris, ErrorResponseFactory errorResponseFactory)
Definition: RegisterParamsValidator.java:222

◆ validateLogoutUri() [2/2]

void org.xdi.oxauth.model.registration.RegisterParamsValidator.validateLogoutUri ( String  logoutUri,
List< String >  redirectUris,
ErrorResponseFactory  errorResponseFactory 
)
inline
231  {
232  if (Util.isNullOrEmpty(logoutUri)) { // logout uri is optional so null or empty string is valid
233  return;
234  }
235 
236  // preconditions
237  if (redirectUris == null || redirectUris.isEmpty()) {
238  log.error("Preconditions of logout uri validation are failed.");
239  throwInvalidLogoutUri(errorResponseFactory);
240  return;
241  }
242 
243  try {
244  Set<String> redirectUriHosts = collectUriHosts(redirectUris);
245 
246  URI uri = new URI(logoutUri);
247 
248  if (!redirectUriHosts.contains(uri.getHost())) {
249  log.error("logout uri host is not within redirect_uris, logout_uri: {}, redirect_uris: {}", logoutUri, redirectUris);
250  throwInvalidLogoutUri(errorResponseFactory);
251  return;
252  }
253 
254  if (!HTTPS.equalsIgnoreCase(uri.getScheme())) {
255  log.error("logout uri schema is not https, logout_uri: {}", logoutUri);
256  throwInvalidLogoutUri(errorResponseFactory);
257  }
258  } catch (Exception e) {
259  log.error(e.getMessage(), e);
260  throwInvalidLogoutUri(errorResponseFactory);
261  }
262  }
void throwInvalidLogoutUri(ErrorResponseFactory errorResponseFactory)
Definition: RegisterParamsValidator.java:264
static final String HTTPS
Definition: RegisterParamsValidator.java:53
Logger log
Definition: RegisterParamsValidator.java:47
Set< String > collectUriHosts(List< String > uriList)
Definition: RegisterParamsValidator.java:273

◆ validateParamsClientRead()

boolean org.xdi.oxauth.model.registration.RegisterParamsValidator.validateParamsClientRead ( String  clientId,
String  accessToken 
)
inline

Validates the parameters for a client read request.

引数
clientIdUnique Client identifier.
accessTokenAccess Token obtained out of band to authorize the registrant.
戻り値
Whether the parameters of client read is valid or not.
86  {
87  return StringUtils.isNotBlank(clientId) && StringUtils.isNotBlank(accessToken);
88  }

◆ validateParamsClientRegister()

boolean org.xdi.oxauth.model.registration.RegisterParamsValidator.validateParamsClientRegister ( ApplicationType  applicationType,
SubjectType  subjectType,
List< String >  redirectUris,
String  sectorIdentifierUrl 
)
inline

Validates the parameters for a register request.

引数
applicationTypeThe Application Type: native or web.
subjectTypeThe subject_type requested for responses to this Client.
redirectUrisSpace-separated list of redirect URIs.
sectorIdentifierUrlA HTTPS scheme URL to be used in calculating Pseudonymous Identifiers by the OP. The URL contains a file with a single JSON array of redirect_uri values.
戻り値
Whether the parameters of client register is valid or not.
68  {
69  boolean valid = applicationType != null && redirectUris != null && !redirectUris.isEmpty();
70 
71  if (subjectType == null || !appConfiguration.getSubjectTypesSupported().contains(subjectType.toString())) {
72  log.debug("Parameter subject_type is not valid.");
73  valid = false;
74  }
75 
76  return valid;
77  }
AppConfiguration appConfiguration
Definition: RegisterParamsValidator.java:50
List< String > getSubjectTypesSupported()
Definition: AppConfiguration.java:557
Logger log
Definition: RegisterParamsValidator.java:47

◆ validateRedirectUris()

boolean org.xdi.oxauth.model.registration.RegisterParamsValidator.validateRedirectUris ( ApplicationType  applicationType,
SubjectType  subjectType,
List< String >  redirectUris,
String  sectorIdentifierUrl 
)
inline
引数
applicationTypeThe Application Type: native or web.
subjectTypeSubject Type requested for responses to this Client.
redirectUrisRedirection URI values used by the Client.
sectorIdentifierUrlA HTTPS scheme URL to be used in calculating Pseudonymous Identifiers by the OP. The URL contains a file with a single JSON array of redirect_uri values.
戻り値
Whether the Redirect URI parameters are valid or not.
99  {
100  boolean valid = true;
101  Set<String> redirectUriHosts = new HashSet<String>();
102 
103  try {
104  if (redirectUris != null && !redirectUris.isEmpty()) {
105  for (String redirectUri : redirectUris) {
106  if (redirectUri == null || redirectUri.contains("#")) {
107  valid = false;
108  } else {
109  URI uri = new URI(redirectUri);
110  redirectUriHosts.add(uri.getHost());
111  switch (applicationType) {
112  case WEB:
113  if (HTTP.equalsIgnoreCase(uri.getScheme())) {
114  if (!LOCALHOST.equalsIgnoreCase(uri.getHost()) && !LOOPBACK.equalsIgnoreCase(uri.getHost())) {
115  log.error("Invalid protocol for redirect_uri: " +
116  redirectUri +
117  " (only https protocol is allowed for application_type=web or localhost/127.0.0.1 for http)");
118  valid = false;
119  }
120  }
121  break;
122  case NATIVE:
123  // to conform "OAuth 2.0 for Native Apps" https://tools.ietf.org/html/draft-wdenniss-oauth-native-apps-00
124  // we allow registration with custom schema for native apps.
125 // if (!HTTP.equalsIgnoreCase(uri.getScheme())) {
126 // valid = false;
127 // } else if (!LOCALHOST.equalsIgnoreCase(uri.getHost())) {
128 // valid = false;
129 // }
130  break;
131  }
132  }
133  }
134  } else {
135  valid = false;
136  }
137  } catch (URISyntaxException e) {
138  valid = false;
139  }
140 
141  /*
142  * Providers that use pairwise sub (subject) values SHOULD utilize the sector_identifier_uri value
143  * provided in the Subject Identifier calculation for pairwise identifiers.
144  *
145  * If the Client has not provided a value for sector_identifier_uri in Dynamic Client Registration,
146  * the Sector Identifier used for pairwise identifier calculation is the host component of the
147  * registered redirect_uri.
148  *
149  * If there are multiple hostnames in the registered redirect_uris, the Client MUST register a
150  * sector_identifier_uri.
151  */
152  if (subjectType != null && subjectType.equals(SubjectType.PAIRWISE) && StringUtils.isBlank(sectorIdentifierUrl)) {
153  if (redirectUriHosts.size() > 1) {
154  valid = false;
155  }
156  }
157 
158  // Validate Sector Identifier URL
159  if (valid && StringUtils.isNotBlank(sectorIdentifierUrl)) {
160  try {
161  URI uri = new URI(sectorIdentifierUrl);
162  if (!HTTPS.equalsIgnoreCase(uri.getScheme())) {
163  valid = false;
164  }
165 
166  ClientRequest clientRequest = new ClientRequest(sectorIdentifierUrl);
167  clientRequest.setHttpMethod(HttpMethod.GET);
168 
169  ClientResponse<String> clientResponse = clientRequest.get(String.class);
170  int status = clientResponse.getStatus();
171 
172  if (status == 200) {
173  String entity = clientResponse.getEntity(String.class);
174 
175  JSONArray sectorIdentifierJsonArray = new JSONArray(entity);
176  valid = Util.asList(sectorIdentifierJsonArray).containsAll(redirectUris);
177  }
178  } catch (Exception e) {
179  log.trace(e.getMessage(), e);
180  valid = false;
181  }
182  }
183 
184  // Validate Redirect Uris checking the white list and black list
185  if (valid) {
186  valid = checkWhiteListRedirectUris(redirectUris) && checkBlackListRedirectUris(redirectUris);
187  }
188 
189  return valid;
190  }
boolean checkBlackListRedirectUris(List< String > redirectUris)
Definition: RegisterParamsValidator.java:210
static final String LOCALHOST
Definition: RegisterParamsValidator.java:54
boolean checkWhiteListRedirectUris(List< String > redirectUris)
Definition: RegisterParamsValidator.java:195
static final String HTTPS
Definition: RegisterParamsValidator.java:53
static final String LOOPBACK
Definition: RegisterParamsValidator.java:55
static final String HTTP
Definition: RegisterParamsValidator.java:52
Logger log
Definition: RegisterParamsValidator.java:47

メンバ詳解

◆ appConfiguration

AppConfiguration org.xdi.oxauth.model.registration.RegisterParamsValidator.appConfiguration
private

◆ HTTP

final String org.xdi.oxauth.model.registration.RegisterParamsValidator.HTTP = "http"
staticprivate

◆ HTTPS

final String org.xdi.oxauth.model.registration.RegisterParamsValidator.HTTPS = "https"
staticprivate

◆ LOCALHOST

final String org.xdi.oxauth.model.registration.RegisterParamsValidator.LOCALHOST = "localhost"
staticprivate

◆ log

Logger org.xdi.oxauth.model.registration.RegisterParamsValidator.log
private

◆ LOOPBACK

final String org.xdi.oxauth.model.registration.RegisterParamsValidator.LOOPBACK = "127.0.0.1"
staticprivate

このクラス詳解は次のファイルから抽出されました: