2017-06-19 18:34:44 +02:00
|
|
|
package org.gcube.dataanalysis.dataminer.poolmanager.util;
|
|
|
|
|
|
|
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
|
|
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
|
|
|
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
|
|
|
|
|
|
|
|
|
|
|
public class CheckPermission {
|
|
|
|
|
|
|
|
public CheckPermission() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean apply(String VREToken, String vre) throws ObjectNotFound, Exception {
|
|
|
|
|
|
|
|
AuthorizationEntry entry = authorizationService().get(VREToken);
|
|
|
|
if (entry.getContext().equals(vre)) {
|
2017-07-24 12:32:18 +02:00
|
|
|
System.out.println("Authorization OK!");
|
2017-06-19 18:34:44 +02:00
|
|
|
return true;
|
|
|
|
}
|
2017-07-24 12:32:18 +02:00
|
|
|
System.out.println("Not a valid token recognized for the VRE: "+vre);
|
2017-06-19 18:34:44 +02:00
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|