From e97e7585c3c0f39ae10329f144b2e07169243be3 Mon Sep 17 00:00:00 2001 From: "lucio.lelii" Date: Thu, 8 Sep 2016 10:54:49 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-library@131212 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../library/AuthorizedTasks.java | 6 ++--- .../provider/AuthorizationProvider.java | 14 ++++++----- .../authorization/library/utils/Caller.java | 25 +++++++++++++++++++ 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 src/main/java/org/gcube/common/authorization/library/utils/Caller.java diff --git a/src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java b/src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java index dba88b8..7f21c3c 100644 --- a/src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java +++ b/src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java @@ -3,8 +3,8 @@ package org.gcube.common.authorization.library; import java.util.concurrent.Callable; import org.gcube.common.authorization.library.provider.AuthorizationProvider; -import org.gcube.common.authorization.library.provider.ClientInfo; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.authorization.library.utils.Caller; public class AuthorizedTasks { @@ -17,7 +17,7 @@ public class AuthorizedTasks { static public Callable bind(final Callable task) { - final ClientInfo userCall = AuthorizationProvider.instance.get(); + final Caller userCall = AuthorizationProvider.instance.get(); final String token = SecurityTokenProvider.instance.get(); @@ -47,7 +47,7 @@ public class AuthorizedTasks { static public Runnable bind(final Runnable task) { - final ClientInfo userCall = AuthorizationProvider.instance.get(); + final Caller userCall = AuthorizationProvider.instance.get(); final String token = SecurityTokenProvider.instance.get(); diff --git a/src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java b/src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java index 06bdb94..7433280 100644 --- a/src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java +++ b/src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java @@ -1,14 +1,16 @@ package org.gcube.common.authorization.library.provider; +import org.gcube.common.authorization.library.utils.Caller; + public class AuthorizationProvider { public static AuthorizationProvider instance = new AuthorizationProvider(); // Thread local variable containing each thread's ID - private static final InheritableThreadLocal threadAuth = - new InheritableThreadLocal() { + private static final InheritableThreadLocal threadAuth = + new InheritableThreadLocal() { - @Override protected UserInfo initialValue() { + @Override protected Caller initialValue() { return null; } @@ -16,12 +18,12 @@ public class AuthorizationProvider { private AuthorizationProvider(){} - public ClientInfo get(){ - ClientInfo info = threadAuth.get(); + public Caller get(){ + Caller info = threadAuth.get(); return info; } - public void set(ClientInfo info){ + public void set(Caller info){ threadAuth.set(info); } diff --git a/src/main/java/org/gcube/common/authorization/library/utils/Caller.java b/src/main/java/org/gcube/common/authorization/library/utils/Caller.java new file mode 100644 index 0000000..8d0016b --- /dev/null +++ b/src/main/java/org/gcube/common/authorization/library/utils/Caller.java @@ -0,0 +1,25 @@ +package org.gcube.common.authorization.library.utils; + +import org.gcube.common.authorization.library.provider.ClientInfo; + +public class Caller { + + private ClientInfo client; + private String qualifier; + + public Caller(ClientInfo client, String qualifier) { + super(); + this.client = client; + this.qualifier = qualifier; + } + + public ClientInfo getClient() { + return client; + } + + public String getTokenQualifier() { + return qualifier; + } + + +}