Lucio Lelii 2017-12-15 15:49:39 +00:00
parent 24a3a8889d
commit 4142d7a590
3 changed files with 6 additions and 2 deletions

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.data.analysis.tabulardata</groupId> <groupId>org.gcube.data.analysis.tabulardata</groupId>
<artifactId>tabular-data-manager</artifactId> <artifactId>tabular-data-manager</artifactId>
<version>1.8.1-SNAPSHOT</version> <version>1.8.2-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<repositories> <repositories>
<repository> <repository>

View File

@ -62,6 +62,9 @@ public class HistoryManagerImpl implements HistoryManager{
tabularResource = getUserAuthorizedObject(tabularResourceId, StorableTabularResource.class, entityManager); tabularResource = getUserAuthorizedObject(tabularResourceId, StorableTabularResource.class, entityManager);
}catch(NoSuchObjectException e){ }catch(NoSuchObjectException e){
throw new NoSuchTabularResourceException(tabularResourceId); throw new NoSuchTabularResourceException(tabularResourceId);
}catch (InternalSecurityException e) {
logger.error("error on authorization",e);
throw e;
}finally{ }finally{
if (entityManager!=null && entityManager.isOpen()) if (entityManager!=null && entityManager.isOpen())
entityManager.close(); entityManager.close();

View File

@ -107,10 +107,11 @@ public class Util {
public static <T, R extends Identifiable> R getUserAuthorizedObject( public static <T, R extends Identifiable> R getUserAuthorizedObject(
T id, Class<R> objectClass, EntityManager entityManager) throws NoSuchObjectException, InternalSecurityException{ T id, Class<R> objectClass, EntityManager entityManager) throws NoSuchObjectException, InternalSecurityException{
String caller = AuthorizationProvider.instance.get().getClient().getId(); String caller = AuthorizationProvider.instance.get().getClient().getId();
String scope = ScopeProvider.instance.get();
R sTr = entityManager.find(objectClass, id); R sTr = entityManager.find(objectClass, id);
if (sTr==null || !sTr.getScopes().contains(ScopeProvider.instance.get())) throw new NoSuchObjectException(); if (sTr==null || !sTr.getScopes().contains(ScopeProvider.instance.get())) throw new NoSuchObjectException();
if (!sTr.getOwner().equals(caller) && !sTr.getSharedWith().contains(String.format("u(%s)", caller)) && if (!sTr.getOwner().equals(caller) && !sTr.getSharedWith().contains(String.format("u(%s)", caller)) &&
!sTr.getSharedWith().contains(String.format("g(%s)", caller))) !sTr.getSharedWith().contains(String.format("g(%s)", scope)))
throw new InternalSecurityException(caller+" is not authorized to use "+objectClass.getName()+" with id "+id.toString()); throw new InternalSecurityException(caller+" is not authorized to use "+objectClass.getName()+" with id "+id.toString());
return sTr; return sTr;
} }