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

公開メンバ関数

Response createResource ( @HeaderParam("Authorization") String authorization, @ApiParam(value="Resource description", required=true) UmaResource resource)
 
Response updateResource (@HeaderParam("Authorization") String authorization, @PathParam("rsid") @ApiParam(value="Resource description ID", required=true) String rsid, @ApiParam(value="Resource description JSON object", required=true) UmaResource resource)
 
Response getResource ( @HeaderParam("Authorization") String authorization, @PathParam("rsid") @ApiParam(value="Resource description object ID", required=true) String rsid)
 
List< String > getResourceList ( @HeaderParam("Authorization") String authorization, @QueryParam("scope") @ApiParam(value="Scope uri", required=false) String scope)
 
Response deleteResource ( @HeaderParam("Authorization") String authorization, @PathParam("rsid") @ApiParam(value="Resource description ID", required=true) String rsid)
 
Response unsupportedHeadMethod ()
 
Response unsupportedOptionsMethod ()
 

静的公開変数類

static final int DEFAULT_RESOURCE_LIFETIME = 2592000
 

関数

private< T > T throwNotFoundException (String rsid)
 

非公開メンバ関数

Response putResourceImpl (Response.Status status, String authorization, String rsid, UmaResource resource) throws IOException
 
String addResource (String rsid, UmaResource resource, String userDn, String clientDn)
 
Date getExpirationDate (Calendar creationCalender)
 
String updateResource (String rsid, UmaResource resource)
 
int incrementRev (String rev)
 
Response throwUmaInternalErrorException ()
 

非公開変数類

Logger log
 
TokenService tokenService
 
UmaValidationService umaValidationService
 
UmaResourceService resourceService
 
ErrorResponseFactory errorResponseFactory
 
AuthorizationGrantList authorizationGrantList
 
UmaScopeService umaScopeService
 
AppConfiguration appConfiguration
 

静的非公開変数類

static final int NOT_ALLOWED_STATUS = 405
 

詳解

The API available at the resource registration endpoint enables the resource server to put resources under the protection of an authorization server on behalf of the resource owner and manage them over time. Protection of a resource at the authorization server begins on successful registration and ends on successful deregistration.

The resource server uses a RESTful API at the authorization server's resource registration endpoint to create, read, update, and delete resource descriptions, along with retrieving lists of such descriptions. The descriptions consist of JSON documents that are maintained as web resources at the authorization server. (Note carefully the similar but distinct senses in which the word "resource" is used in this section.)

著者
Yuriy Zabrovarnyy
Yuriy Movchan Date: 02/12/2015

関数詳解

◆ addResource()

String org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.addResource ( String  rsid,
UmaResource  resource,
String  userDn,
String  clientDn 
)
inlineprivate
334  {
335  log.debug("Adding new resource: '{}'", rsid);
336 
337  final String resourceDn = resourceService.getDnForResource(rsid);
338  final List<String> scopeDNs = umaScopeService.getScopeDNsByIdsAndAddToLdapIfNeeded(resource.getScopes());
339 
340  final Calendar calendar = Calendar.getInstance();
342 
343  ldapResource.setName(resource.getName());
344  ldapResource.setDescription(resource.getDescription());
345  ldapResource.setIconUri(resource.getIconUri());
346  ldapResource.setId(rsid);
347  ldapResource.setRev("1");
348  ldapResource.setCreator(userDn);
349  ldapResource.setDn(resourceDn);
350  ldapResource.setScopes(scopeDNs);
351  ldapResource.setScopeExpression(resource.getScopeExpression());
352  ldapResource.setClients(new ArrayList<String>(Collections.singletonList(clientDn)));
353  ldapResource.setType(resource.getType());
354  ldapResource.setCreationDate(calendar.getTime());
355  ldapResource.setExpirationDate(getExpirationDate(calendar));
356 
357  resourceService.addResource(ldapResource);
358 
359  return resourceDn;
360  }
UmaScopeService umaScopeService
Definition: UmaResourceRegistrationWS.java:99
Date getExpirationDate(Calendar creationCalender)
Definition: UmaResourceRegistrationWS.java:362
Definition: UmaPermission.java:7
Logger log
Definition: UmaResourceRegistrationWS.java:81
List< String > getScopeDNsByIdsAndAddToLdapIfNeeded(List< String > scopeIds)
Definition: UmaScopeService.java:102
Definition: ClaimTokenFormatType.java:1
void addResource(UmaResource resource)
Definition: UmaResourceService.java:78
void setName(String name)
Definition: UmaResource.java:138
UmaResourceService resourceService
Definition: UmaResourceRegistrationWS.java:90
String getDnForResource(String oxId)
Definition: UmaResourceService.java:229

◆ createResource()

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.createResource ( @HeaderParam("Authorization") String  authorization,
@ApiParam(value="Resource description", required=true) UmaResource  resource 
)
inline
116  {
117  try {
118  String id = UUID.randomUUID().toString();
119  log.trace("Try to create resource, id: {}", id);
120 
121  return putResourceImpl(Response.Status.CREATED, authorization, id, resource);
122  } catch (Exception ex) {
123  log.error("Exception during resource creation", ex);
124 
125  if (ex instanceof WebApplicationException) {
126  throw (WebApplicationException) ex;
127  }
128 
130  }
131  }
Logger log
Definition: UmaResourceRegistrationWS.java:81
Response throwUmaInternalErrorException()
Definition: UmaResourceRegistrationWS.java:410
Response putResourceImpl(Response.Status status, String authorization, String rsid, UmaResource resource)
Definition: UmaResourceRegistrationWS.java:305

◆ deleteResource()

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.deleteResource ( @HeaderParam("Authorization") String  authorization,
@PathParam("rsid") @ApiParam(value="Resource description ID", required=true) String  rsid 
)
inline
285  {
286  try {
287  log.debug("Deleting resource descriptions'");
288 
289  final AuthorizationGrant authorizationGrant = umaValidationService.assertHasProtectionScope(authorization);
290  umaValidationService.validateRestrictedByClient(authorizationGrant.getClientDn(), rsid);
291  resourceService.remove(rsid);
292 
293  return Response.status(Response.Status.NO_CONTENT).build();
294  } catch (Exception ex) {
295  log.error("Error on DELETE Resource - " + ex.getMessage(), ex);
296 
297  if (ex instanceof WebApplicationException) {
298  throw (WebApplicationException) ex;
299  }
300 
302  }
303  }
Logger log
Definition: UmaResourceRegistrationWS.java:81
Response throwUmaInternalErrorException()
Definition: UmaResourceRegistrationWS.java:410
void remove(UmaResource resource)
Definition: UmaResourceService.java:106
UmaValidationService umaValidationService
Definition: UmaResourceRegistrationWS.java:87
UmaResourceService resourceService
Definition: UmaResourceRegistrationWS.java:90
void validateRestrictedByClient(String patClientDn, String rsId)
Definition: UmaValidationService.java:479
AuthorizationGrant assertHasProtectionScope(String authorization)
Definition: UmaValidationService.java:123

◆ getExpirationDate()

Date org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.getExpirationDate ( Calendar  creationCalender)
inlineprivate
362  {
363  int lifetime = appConfiguration.getUmaResourceLifetime();
364  if (lifetime <= 0) {
365  lifetime = DEFAULT_RESOURCE_LIFETIME;
366  }
367  creationCalender.add(Calendar.SECOND, lifetime);
368  return creationCalender.getTime();
369  }
AppConfiguration appConfiguration
Definition: UmaResourceRegistrationWS.java:102
int getUmaResourceLifetime()
Definition: AppConfiguration.java:816
static final int DEFAULT_RESOURCE_LIFETIME
Definition: UmaResourceRegistrationWS.java:78

◆ getResource()

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.getResource ( @HeaderParam("Authorization") String  authorization,
@PathParam("rsid") @ApiParam(value="Resource description object ID", required=true) String  rsid 
)
inline
175  {
176  try {
177  final AuthorizationGrant authorizationGrant = umaValidationService.assertHasProtectionScope(authorization);
178  umaValidationService.validateRestrictedByClient(authorizationGrant.getClientDn(), rsid);
179  log.debug("Getting resource description: '{}'", rsid);
180 
182 
183  final UmaResourceWithId response = new UmaResourceWithId();
184 
185  response.setId(ldapResource.getId());
186  response.setName(ldapResource.getName());
187  response.setDescription(ldapResource.getDescription());
188  response.setIconUri(ldapResource.getIconUri());
189  response.setScopes(umaScopeService.getScopeIdsByDns(ldapResource.getScopes()));
190  response.setScopeExpression(ldapResource.getScopeExpression());
191  response.setType(ldapResource.getType());
192  response.setIat(ServerUtil.dateToSeconds(ldapResource.getCreationDate()));
193  response.setExp(ServerUtil.dateToSeconds(ldapResource.getExpirationDate()));
194 
195  final ResponseBuilder builder = Response.ok();
196  builder.entity(ServerUtil.asJson(response)); // convert manually to avoid possible conflicts between resteasy providers, e.g. jettison, jackson
197 
198  return builder.build();
199  } catch (Exception ex) {
200  log.error("Exception happened", ex);
201  if (ex instanceof WebApplicationException) {
202  throw (WebApplicationException) ex;
203  }
204 
206  return null;// redundant but required statement by java
207 
208  }
209  }
List< String > getScopeIdsByDns(List< String > scopeDns)
Definition: UmaScopeService.java:129
UmaScopeService umaScopeService
Definition: UmaResourceRegistrationWS.java:99
ErrorResponseFactory errorResponseFactory
Definition: UmaResourceRegistrationWS.java:93
Definition: UmaPermission.java:7
void throwUmaInternalErrorException()
Definition: ErrorResponseFactory.java:113
Logger log
Definition: UmaResourceRegistrationWS.java:81
Definition: ClaimTokenFormatType.java:1
UmaValidationService umaValidationService
Definition: UmaResourceRegistrationWS.java:87
UmaResourceService resourceService
Definition: UmaResourceRegistrationWS.java:90
void validateRestrictedByClient(String patClientDn, String rsId)
Definition: UmaValidationService.java:479
AuthorizationGrant assertHasProtectionScope(String authorization)
Definition: UmaValidationService.java:123
UmaResource getResourceById(String id)
Definition: UmaResourceService.java:180

◆ getResourceList()

List<String> org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.getResourceList ( @HeaderParam("Authorization") String  authorization,
@QueryParam("scope") @ApiParam(value="Scope uri", required=false) String  scope 
)
inline

Gets resource set lists. ATTENTION: "scope" is parameter added by gluu to have additional filtering. There is no such parameter in UMA specification.

引数
authorizationauthorization
scopescope of resource set for additional filtering, can blank string.
戻り値
resource set ids.
235  {
236  try {
237  log.trace("Getting list of resource descriptions.");
238 
239  final AuthorizationGrant authorizationGrant = umaValidationService.assertHasProtectionScope(authorization);
240  final String clientDn = authorizationGrant.getClientDn();
241 
242  final List<org.xdi.oxauth.model.uma.persistence.UmaResource> ldapResources = resourceService
244 
245  final List<String> result = new ArrayList<String>(ldapResources.size());
246  for (org.xdi.oxauth.model.uma.persistence.UmaResource ldapResource : ldapResources) {
247 
248  // if scope parameter is not null then filter by it, otherwise just add to result
249  if (StringUtils.isNotBlank(scope)) {
250  final List<String> scopeUrlsByDns = umaScopeService.getScopeIdsByDns(ldapResource.getScopes());
251  if (scopeUrlsByDns != null && scopeUrlsByDns.contains(scope)) {
252  result.add(ldapResource.getId());
253  }
254  } else {
255  result.add(ldapResource.getId());
256  }
257  }
258 
259  return result;
260 
261  } catch (Exception ex) {
262  log.error("Exception happened on getResourceList()", ex);
263  if (ex instanceof WebApplicationException) {
264  throw (WebApplicationException) ex;
265  }
266  }
267 
269  return Lists.newArrayList(); // redundant but required by java
270  }
List< String > getScopeIdsByDns(List< String > scopeDns)
Definition: UmaScopeService.java:129
UmaScopeService umaScopeService
Definition: UmaResourceRegistrationWS.java:99
ErrorResponseFactory errorResponseFactory
Definition: UmaResourceRegistrationWS.java:93
Definition: UmaPermission.java:7
String getClientDn()
Definition: AbstractAuthorizationGrant.java:354
void throwUmaInternalErrorException()
Definition: ErrorResponseFactory.java:113
Logger log
Definition: UmaResourceRegistrationWS.java:81
Definition: ClaimTokenFormatType.java:1
UmaValidationService umaValidationService
Definition: UmaResourceRegistrationWS.java:87
UmaResourceService resourceService
Definition: UmaResourceRegistrationWS.java:90
List< UmaResource > getResourcesByAssociatedClient(String associatedClientDn)
Definition: UmaResourceService.java:130
AuthorizationGrant assertHasProtectionScope(String authorization)
Definition: UmaValidationService.java:123

◆ incrementRev()

int org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.incrementRev ( String  rev)
inlineprivate
395  {
396  try {
397  return Integer.parseInt(rev) + 1;
398  } catch (Exception e) {
399  log.error(e.getMessage(), e);
400  }
401  return 1; // fallback
402  }
Logger log
Definition: UmaResourceRegistrationWS.java:81

◆ putResourceImpl()

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.putResourceImpl ( Response.Status  status,
String  authorization,
String  rsid,
UmaResource  resource 
) throws IOException
inlineprivate
305  {
306  log.trace("putResourceImpl, rsid: {}, status:", rsid, status.name());
307 
308  AuthorizationGrant authorizationGrant = umaValidationService.assertHasProtectionScope(authorization);
310 
311  String userDn = authorizationGrant.getUserDn();
312  String clientDn = authorizationGrant.getClientDn();
313 
314  final String resourceDn;
315 
316  if (status == Response.Status.CREATED) {
317  resourceDn = addResource(rsid, resource, userDn, clientDn);
318  } else {
320  resourceDn = updateResource(rsid, resource);
321  }
322 
323  // Load resource description
324  org.xdi.oxauth.model.uma.persistence.UmaResource ldapUpdatedResource = resourceService.getResourceByDn(resourceDn);
325 
326  UmaResourceResponse response = new UmaResourceResponse();
327  response.setId(ldapUpdatedResource.getId());
328 
329  return Response.status(status).
330  entity(ServerUtil.asJson(response)).
331  build();
332  }
void validateResource(org.xdi.oxauth.model.uma.UmaResource resource)
Definition: UmaValidationService.java:489
Definition: UmaPermission.java:7
UmaResource getResourceByDn(String dn)
Definition: UmaResourceService.java:218
Logger log
Definition: UmaResourceRegistrationWS.java:81
Response updateResource(@HeaderParam("Authorization") String authorization, @PathParam("rsid") @ApiParam(value="Resource description ID", required=true) String rsid, @ApiParam(value="Resource description JSON object", required=true) UmaResource resource)
Definition: UmaResourceRegistrationWS.java:142
Definition: ClaimTokenFormatType.java:1
UmaValidationService umaValidationService
Definition: UmaResourceRegistrationWS.java:87
UmaResourceService resourceService
Definition: UmaResourceRegistrationWS.java:90
String addResource(String rsid, UmaResource resource, String userDn, String clientDn)
Definition: UmaResourceRegistrationWS.java:334
void validateRestrictedByClient(String patClientDn, String rsId)
Definition: UmaValidationService.java:479
AuthorizationGrant assertHasProtectionScope(String authorization)
Definition: UmaValidationService.java:123

◆ throwNotFoundException()

private<T> T org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.throwNotFoundException ( String  rsid)
inlinepackage
404  {
405  log.error("Specified resource set description doesn't exist, id: " + rsid);
407  return null;
408  }
void throwUmaNotFoundException()
Definition: ErrorResponseFactory.java:109
ErrorResponseFactory errorResponseFactory
Definition: UmaResourceRegistrationWS.java:93
Logger log
Definition: UmaResourceRegistrationWS.java:81

◆ throwUmaInternalErrorException()

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.throwUmaInternalErrorException ( )
inlineprivate
410  {
412  return null;
413  }
ErrorResponseFactory errorResponseFactory
Definition: UmaResourceRegistrationWS.java:93
void throwUmaInternalErrorException()
Definition: ErrorResponseFactory.java:113

◆ unsupportedHeadMethod()

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.unsupportedHeadMethod ( )
inline
417  {
418  log.error("HEAD method is not allowed");
419  throw new WebApplicationException(Response.status(NOT_ALLOWED_STATUS).entity("HEAD Method Not Allowed").build());
420  }
static final int NOT_ALLOWED_STATUS
Definition: UmaResourceRegistrationWS.java:76
Logger log
Definition: UmaResourceRegistrationWS.java:81

◆ unsupportedOptionsMethod()

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.unsupportedOptionsMethod ( )
inline
424  {
425  log.error("OPTIONS method is not allowed");
426  throw new WebApplicationException(Response.status(NOT_ALLOWED_STATUS).entity("OPTIONS Method Not Allowed").build());
427  }
static final int NOT_ALLOWED_STATUS
Definition: UmaResourceRegistrationWS.java:76
Logger log
Definition: UmaResourceRegistrationWS.java:81

◆ updateResource() [1/2]

Response org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.updateResource ( @HeaderParam("Authorization") String  authorization,
@PathParam("rsid") @ApiParam(value="Resource description ID", required=true) String  rsid,
@ApiParam(value="Resource description JSON object", required=true) UmaResource  resource 
)
inline
147  {
148  try {
149  return putResourceImpl(Response.Status.OK, authorization, rsid, resource);
150  } catch (Exception ex) {
151  log.error("Exception during resource update, rsId: " + rsid + ", message: " + ex.getMessage(), ex);
152 
153  if (ex instanceof WebApplicationException) {
154  throw (WebApplicationException) ex;
155  }
156 
158  }
159  }
Logger log
Definition: UmaResourceRegistrationWS.java:81
Response throwUmaInternalErrorException()
Definition: UmaResourceRegistrationWS.java:410
Response putResourceImpl(Response.Status status, String authorization, String rsid, UmaResource resource)
Definition: UmaResourceRegistrationWS.java:305

◆ updateResource() [2/2]

String org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.updateResource ( String  rsid,
UmaResource  resource 
)
inlineprivate
371  {
372  log.debug("Updating resource description: '{}'.", rsid);
373 
375  if (ldapResource == null) {
376  return throwNotFoundException(rsid);
377  }
378 
379  ldapResource.setName(resource.getName());
380  ldapResource.setDescription(resource.getDescription());
381  ldapResource.setIconUri(resource.getIconUri());
382  ldapResource.setScopes(umaScopeService.getScopeDNsByIdsAndAddToLdapIfNeeded(resource.getScopes()));
383  ldapResource.setScopeExpression(resource.getScopeExpression());
384  ldapResource.setRev(String.valueOf(incrementRev(ldapResource.getRev())));
385  ldapResource.setType(resource.getType());
386  if (resource.getExp() != null && resource.getExp() > 0) {
387  ldapResource.setExpirationDate(new Date(resource.getExp() * 1000));
388  }
389 
390  resourceService.updateResource(ldapResource);
391 
392  return ldapResource.getDn();
393  }
void updateResource(UmaResource resource)
Definition: UmaResourceService.java:96
UmaScopeService umaScopeService
Definition: UmaResourceRegistrationWS.java:99
Definition: UmaPermission.java:7
Logger log
Definition: UmaResourceRegistrationWS.java:81
List< String > getScopeDNsByIdsAndAddToLdapIfNeeded(List< String > scopeIds)
Definition: UmaScopeService.java:102
Definition: ClaimTokenFormatType.java:1
private< T > T throwNotFoundException(String rsid)
Definition: UmaResourceRegistrationWS.java:404
UmaResourceService resourceService
Definition: UmaResourceRegistrationWS.java:90
int incrementRev(String rev)
Definition: UmaResourceRegistrationWS.java:395
UmaResource getResourceById(String id)
Definition: UmaResourceService.java:180

メンバ詳解

◆ appConfiguration

AppConfiguration org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.appConfiguration
private

◆ authorizationGrantList

AuthorizationGrantList org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.authorizationGrantList
private

◆ DEFAULT_RESOURCE_LIFETIME

final int org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.DEFAULT_RESOURCE_LIFETIME = 2592000
static

◆ errorResponseFactory

ErrorResponseFactory org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.errorResponseFactory
private

◆ log

Logger org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.log
private

◆ NOT_ALLOWED_STATUS

final int org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.NOT_ALLOWED_STATUS = 405
staticprivate

◆ resourceService

UmaResourceService org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.resourceService
private

◆ tokenService

TokenService org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.tokenService
private

◆ umaScopeService

UmaScopeService org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.umaScopeService
private

◆ umaValidationService

UmaValidationService org.xdi.oxauth.uma.ws.rs.UmaResourceRegistrationWS.umaValidationService
private

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