Authorization Client Library

From Gcube Wiki
Revision as of 17:39, 10 May 2016 by Lucio.lelii (Talk | contribs) (maven dependency)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Authorization Client library helps clients to generate and resolve gCube Token and also to add/remove Policies for service/user/role access.


maven dependency

The required dependency to be added to the pom is:

  <dependency>
   <groupId>org.gcube.common</groupId>
   <artifactId>authorization-client</artifactId>
   <version>2.0.0-SNAPSHOT</version>
  </dependency>


Examples

Generate a token

The following example will show how to generate a token for a user in a context.

import static org.gcube.common.authorization.client.Constants.authorizationService;
 
...
authorizationService().generateToken(new UserInfo({userName}, Arrays.asList("role1", "role2")), "context");
...

Resolve token

The following example will show how to resolve a token.

import static org.gcube.common.authorization.client.Constants.authorizationService;
 
...
AuthorizationEntry entry = authorizationService().get("token");
 
//retrieve the info of the token owner
entry.getClientInfo();
 
//retrieve the context of the token owner
entry.getContext();
 
...