Package org.forgerock.openig.uma
Class UmaSharingService
- java.lang.Object
-
- org.forgerock.openig.uma.UmaSharingService
-
public class UmaSharingService extends Object
AnUmaSharingServiceprovides core UMA features to OpenIG when acting as an UMA Resource Server.It is linked to a single UMA Authorization Server and needs to be pre-registered as an OAuth 2.0 client on that AS.
It is also the place where protected application knowledge is described: each item of the
resourcesarray describe a resource set (that can be composed of multiple endpoints) that share the same set of scopes.Each resource contains a
patternused to define which one of them to use when aShareis created. A resource also contains a list ofactionsthat defines the set of scopes to require when a requesting party request comes in.Along with the{ "name": "UmaService", "type": "UmaService", "config": { "protectionApiHandler": "HttpsClient", "authorizationServerUri": "https://openam.example.com:8443/openam", "clientId": "uma", "clientSecret": "welcome", "resources": [ { "pattern": "/guillaume/.*", "actions" : [ { "scopes" : [ "http://api.example.com/operations#read" ], "condition" : "${request.method == 'GET'}" }, { "scopes" : [ "http://api.example.com/operations#delete" ], "condition" : "${request.method == 'DELETE'}" } ] } ] } }UmaService, a REST endpoint is deployed in OpenIG's API namespace: /openig/api/system/objects/../objects/[name-of-the-uma-service-object]/share. The dotted segment depends on your deployment (like which RouterHandler hosts the route that in turns contains this object).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUmaSharingService.HeapletCreates and initializes an UMA service in a heap environment.
-
Constructor Summary
Constructors Constructor Description UmaSharingService(org.forgerock.http.Handler protectionApiHandler, List<org.forgerock.openig.uma.ShareTemplate> templates, URI authorizationServer, String clientId, String clientSecret)Constructs an UmaSharingService bound to the givenauthorizationServerand dedicated to protect resource sets described by the giventemplates.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.forgerock.util.promise.Promise<org.forgerock.openig.uma.Share,UmaException>createShare(org.forgerock.services.context.Context context, String resourcePath, String pat)Creates a Share that will be used to protect the givenresourcePath.org.forgerock.openig.uma.SharefindShare(org.forgerock.http.protocol.Request request)Find aShare.URIgetAuthorizationServer()Returns the UMA authorization server base Uri.StringgetClientId()Returns the client identifier used to identify this RS as an OAuth 2.0 client.StringgetClientSecret()Returns the client secret.URIgetIntrospectionEndpoint()Returns the OAuth 2.0 Introspection endpoint Uri.org.forgerock.openig.uma.SharegetShare(String id)Returns theSharewith the givenid.URIgetTicketEndpoint()Returns the UMA Permission Request endpoint Uri.Set<org.forgerock.openig.uma.Share>listShares()Returns a copy of the list of currently managed shares.org.forgerock.openig.uma.ShareremoveShare(String shareId)Removes the previously created Share from the registered shares.
-
-
-
Constructor Detail
-
UmaSharingService
public UmaSharingService(org.forgerock.http.Handler protectionApiHandler, List<org.forgerock.openig.uma.ShareTemplate> templates, URI authorizationServer, String clientId, String clientSecret) throws URISyntaxExceptionConstructs an UmaSharingService bound to the givenauthorizationServerand dedicated to protect resource sets described by the giventemplates.- Parameters:
protectionApiHandler- used to call the resource set endpointtemplates- list of resource descriptionsauthorizationServer- Bound UMA Authorization ServerclientId- OAuth 2.0 Client identifierclientSecret- OAuth 2.0 Client secret- Throws:
URISyntaxException- when the authorization server URI cannot be "normalized" (trailing '/' append if required)
-
-
Method Detail
-
createShare
public org.forgerock.util.promise.Promise<org.forgerock.openig.uma.Share,UmaException> createShare(org.forgerock.services.context.Context context, String resourcePath, String pat)
Creates a Share that will be used to protect the givenresourcePath.- Parameters:
context- Context chain used to keep a relationship between requests (tracking)resourcePath- resource to be protectedpat- Protection Api Token (PAT)- Returns:
- the created
Shareasynchronously - See Also:
- Resource Set Registration
-
findShare
public org.forgerock.openig.uma.Share findShare(org.forgerock.http.protocol.Request request) throws UmaExceptionFind aShare.- Parameters:
request- the incoming requesting party request- Returns:
- a
Shareto be used to protect the resource access - Throws:
UmaException- when noSharecan handle the request.
-
removeShare
public org.forgerock.openig.uma.Share removeShare(String shareId)
Removes the previously created Share from the registered shares. In effect, the resources is no more shared/protected- Parameters:
shareId- share identifier- Returns:
- the removed Share instance if found,
nullotherwise.
-
listShares
public Set<org.forgerock.openig.uma.Share> listShares()
Returns a copy of the list of currently managed shares.- Returns:
- a copy of the list of currently managed shares.
-
getAuthorizationServer
public URI getAuthorizationServer()
Returns the UMA authorization server base Uri.- Returns:
- the UMA authorization server base Uri.
-
getTicketEndpoint
public URI getTicketEndpoint()
Returns the UMA Permission Request endpoint Uri.- Returns:
- the UMA Permission Request endpoint Uri.
-
getIntrospectionEndpoint
public URI getIntrospectionEndpoint()
Returns the OAuth 2.0 Introspection endpoint Uri.- Returns:
- the OAuth 2.0 Introspection endpoint Uri.
-
getShare
public org.forgerock.openig.uma.Share getShare(String id)
Returns theSharewith the givenid.- Parameters:
id- Share identifier- Returns:
- the
Sharewith the givenid(ornullif none was found).
-
getClientId
public String getClientId()
Returns the client identifier used to identify this RS as an OAuth 2.0 client.- Returns:
- the client identifier used to identify this RS as an OAuth 2.0 client.
-
getClientSecret
public String getClientSecret()
Returns the client secret.- Returns:
- the client secret.
-
-