git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/authorization-common-client@177199 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ecd3b1535c
commit
2bf6b03a8a
|
@ -22,7 +22,11 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -3,7 +3,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<version>2.0.2-SNAPSHOT</version>
|
||||
<version>2.0.3-SNAPSHOT</version>
|
||||
<name>authorization service client library</name>
|
||||
|
||||
<parent>
|
||||
|
|
|
@ -515,9 +515,11 @@ public class DefaultAuthorizationProxy implements AuthorizationProxy {
|
|||
|
||||
@Override
|
||||
public AuthorizationEndpoint getEndpoint(int infrastructureHash) {
|
||||
if (!endpoints.getEndpoints().containsKey(infrastructureHash))
|
||||
for (String infra: endpoints.getEndpoints().keySet()) {
|
||||
if (Utils.getInfrastructureHashfromContext(infra)==infrastructureHash)
|
||||
return endpoints.getEndpoints().get(infra);
|
||||
}
|
||||
throw new RuntimeException("Authorization Endpoint not found for the required infrastructure");
|
||||
return endpoints.getEndpoints().get(infrastructureHash);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,10 +12,15 @@ public class Utils {
|
|||
private static final String REAL_TOKEN_REGEXPR ="([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(-[0-9]+)?";
|
||||
|
||||
|
||||
|
||||
protected static int getInfrastructureHashfromContext(String context) {
|
||||
try{
|
||||
String infrastructure = context.split("/")[1];
|
||||
return infrastructure.hashCode();
|
||||
String infrastructure = context;
|
||||
if (context.startsWith("/"))
|
||||
infrastructure = context.substring(1);
|
||||
|
||||
int hashcode= infrastructure.hashCode();
|
||||
return Math.abs(hashcode);
|
||||
}catch(Exception e){
|
||||
throw new RuntimeException("invalid context");
|
||||
}
|
||||
|
|
|
@ -29,8 +29,13 @@ public class CallTest {
|
|||
|
||||
@Test
|
||||
public void resolveNodeToken() throws Exception{
|
||||
System.out.println(resolveToken("d29fdd99-0e88-4f13-ae33-f52258e9f578-843339462")); //81caac0f-8a0d-4923-9312-7ff0eb3f2d5e|98187548"));
|
||||
System.out.println(resolveToken("d29fdd99-0e88-4f13-ae33-f52258e9f578-843339462").getClientInfo());
|
||||
System.out.println(resolveToken("7f106b0f-e444-41a7-b101-4583ae8da3f8-980114272")); //81caac0f-8a0d-4923-9312-7ff0eb3f2d5e|98187548"));
|
||||
System.out.println(resolveToken("7f106b0f-e444-41a7-b101-4583ae8da3f8-980114272").getClientInfo().getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void haspred4s() {
|
||||
System.out.println("pred4s".hashCode() & 0xfffffff);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -45,8 +50,8 @@ public class CallTest {
|
|||
|
||||
@Test
|
||||
public void requestExternalServiceToken() throws Exception {
|
||||
SecurityTokenProvider.instance.set(requestTestToken("/gcube/devsec/NextNext"));
|
||||
System.out.println(authorizationService().generateExternalServiceToken("org.gcube.datacatalogue.GRSFNotifier"));
|
||||
SecurityTokenProvider.instance.set(requestTestToken("/gcube"));
|
||||
System.out.println(authorizationService().generateExternalServiceToken("URIResolver"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -83,7 +88,7 @@ public class CallTest {
|
|||
|
||||
@Test
|
||||
public void generateToken() throws Exception{
|
||||
System.out.println(authorizationService().generateUserToken(new UserInfo("yankarlos.panikos", new ArrayList<String>()), "/gcube/devNext/NextNext"));
|
||||
System.out.println(authorizationService().generateUserToken(new UserInfo("guest", new ArrayList<String>()), "/pred4s"));
|
||||
}
|
||||
@Test(expected=RuntimeException.class)
|
||||
public void createKeyWithError() throws Exception {
|
||||
|
@ -117,17 +122,17 @@ public class CallTest {
|
|||
|
||||
public String _requestNodeToken() throws Exception {
|
||||
SecurityTokenProvider.instance.set(requestTestToken("/gcube"));
|
||||
String token = authorizationService().requestActivation(new ContainerInfo("workspace-repository1-d.d4science.org",80), "/gcube");
|
||||
String token = authorizationService().requestActivation(new ContainerInfo("workspace-repository1-d.d4science.org",80), "/gcube/devsec");
|
||||
return token;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createTestToken() throws Exception {
|
||||
System.out.println(requestTestToken("/gcube/devsec/devVRE"));
|
||||
System.out.println(requestTestToken("/pred4s"));
|
||||
}
|
||||
|
||||
private String requestTestToken(String context) throws Exception{
|
||||
return authorizationService().generateUserToken(new UserInfo("giancarlo.panichi", new ArrayList<String>()), context);
|
||||
return authorizationService().generateUserToken(new UserInfo("lucio.lelii", new ArrayList<String>()), context);
|
||||
}
|
||||
|
||||
private AuthorizationEntry resolveToken(String token) throws Exception{
|
||||
|
|
Loading…
Reference in New Issue