git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-library@131212 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
39089fb2ae
commit
e97e7585c3
|
@ -3,8 +3,8 @@ package org.gcube.common.authorization.library;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
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.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.authorization.library.utils.Caller;
|
||||||
|
|
||||||
|
|
||||||
public class AuthorizedTasks {
|
public class AuthorizedTasks {
|
||||||
|
@ -17,7 +17,7 @@ public class AuthorizedTasks {
|
||||||
static public <V> Callable<V> bind(final Callable<V> task) {
|
static public <V> Callable<V> bind(final Callable<V> task) {
|
||||||
|
|
||||||
|
|
||||||
final ClientInfo userCall = AuthorizationProvider.instance.get();
|
final Caller userCall = AuthorizationProvider.instance.get();
|
||||||
|
|
||||||
final String token = SecurityTokenProvider.instance.get();
|
final String token = SecurityTokenProvider.instance.get();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class AuthorizedTasks {
|
||||||
static public <V> Runnable bind(final Runnable task) {
|
static public <V> Runnable bind(final Runnable task) {
|
||||||
|
|
||||||
|
|
||||||
final ClientInfo userCall = AuthorizationProvider.instance.get();
|
final Caller userCall = AuthorizationProvider.instance.get();
|
||||||
|
|
||||||
final String token = SecurityTokenProvider.instance.get();
|
final String token = SecurityTokenProvider.instance.get();
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
package org.gcube.common.authorization.library.provider;
|
package org.gcube.common.authorization.library.provider;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.utils.Caller;
|
||||||
|
|
||||||
public class AuthorizationProvider {
|
public class AuthorizationProvider {
|
||||||
|
|
||||||
public static AuthorizationProvider instance = new AuthorizationProvider();
|
public static AuthorizationProvider instance = new AuthorizationProvider();
|
||||||
|
|
||||||
// Thread local variable containing each thread's ID
|
// Thread local variable containing each thread's ID
|
||||||
private static final InheritableThreadLocal<ClientInfo> threadAuth =
|
private static final InheritableThreadLocal<Caller> threadAuth =
|
||||||
new InheritableThreadLocal<ClientInfo>() {
|
new InheritableThreadLocal<Caller>() {
|
||||||
|
|
||||||
@Override protected UserInfo initialValue() {
|
@Override protected Caller initialValue() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,12 +18,12 @@ public class AuthorizationProvider {
|
||||||
|
|
||||||
private AuthorizationProvider(){}
|
private AuthorizationProvider(){}
|
||||||
|
|
||||||
public ClientInfo get(){
|
public Caller get(){
|
||||||
ClientInfo info = threadAuth.get();
|
Caller info = threadAuth.get();
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(ClientInfo info){
|
public void set(Caller info){
|
||||||
threadAuth.set(info);
|
threadAuth.set(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue