From aaaafe2f79c5efc00a0556cfbb63f38fe544cb8e Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Mon, 23 Feb 2009 14:40:17 +0000
Subject: [PATCH] LMS-761 Authorization annotations added to IETLLIMSService.
 IETLIMSService regression test added

SVN: 9928
---
 .../generic/shared/IETLLIMSService.java       | 12 +++-
 .../shared/IETLLIMSService.java.expected      | 63 +++++++++++++++++++
 .../shared/ServerInterfaceRegressionTest.java |  7 +++
 3 files changed, 79 insertions(+), 3 deletions(-)
 create mode 100644 openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java
index 58642d65c99..798f47a5afa 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java
@@ -20,8 +20,10 @@ import org.springframework.transaction.annotation.Transactional;
 
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
 import ch.systemsx.cisd.openbis.generic.shared.authorization.ISessionProvider;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.AuthorizationGuard;
 import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RoleSet;
 import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.SampleOwnerIdentifierPredicate;
 import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalData;
@@ -40,6 +42,7 @@ public interface IETLLIMSService extends IWebService, IDataStoreInfoProvider, IS
      * Returns the home database instance.
      */
     @Transactional(readOnly = true)
+    @RolesAllowed(RoleSet.ETL_SERVER)
     public DatabaseInstancePE getHomeDatabaseInstance();
 
     /**
@@ -52,6 +55,7 @@ public interface IETLLIMSService extends IWebService, IDataStoreInfoProvider, IS
     @Transactional(readOnly = true)
     @RolesAllowed(RoleSet.ETL_SERVER)
     public ExperimentPE tryToGetBaseExperiment(final String sessionToken,
+            @AuthorizationGuard(guardClass = SampleOwnerIdentifierPredicate.class)
             final SampleIdentifier sampleIdentifier) throws UserFailureException;
 
     /**
@@ -66,6 +70,7 @@ public interface IETLLIMSService extends IWebService, IDataStoreInfoProvider, IS
     @Transactional(readOnly = true)
     @RolesAllowed(RoleSet.ETL_SERVER)
     public SamplePropertyPE[] tryToGetPropertiesOfTopSampleRegisteredFor(final String sessionToken,
+            @AuthorizationGuard(guardClass = SampleOwnerIdentifierPredicate.class)
             final SampleIdentifier sampleIdentifier) throws UserFailureException;
 
     /**
@@ -82,9 +87,10 @@ public interface IETLLIMSService extends IWebService, IDataStoreInfoProvider, IS
      */
     @Transactional
     @RolesAllowed(RoleSet.ETL_SERVER)
-    public void registerDataSet(final String sessionToken, final SampleIdentifier sampleIdentifier,
-            final String procedureTypeCode, final ExternalData externalData)
-            throws UserFailureException;
+    public void registerDataSet(final String sessionToken,
+            @AuthorizationGuard(guardClass = SampleOwnerIdentifierPredicate.class)
+            final SampleIdentifier sampleIdentifier, final String procedureTypeCode,
+            final ExternalData externalData) throws UserFailureException;
 
     /**
      * Creates and returns a unique code for a new data set.
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected
new file mode 100644
index 00000000000..e7d329ef989
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2007 ETH Zuerich, CISD
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package ch.systemsx.cisd.openbis.generic.shared;
+
+import org.springframework.transaction.annotation.Transactional;
+
+import ch.systemsx.cisd.common.exceptions.UserFailureException;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.ISessionProvider;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.AuthorizationGuard;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RoleSet;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.RolesAllowed;
+import ch.systemsx.cisd.openbis.generic.shared.authorization.predicate.SampleOwnerIdentifierPredicate;
+import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalData;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePropertyPE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier;
+
+public interface IETLLIMSService extends IWebService, IDataStoreInfoProvider, ISessionProvider
+{
+    
+    @Transactional(readOnly = true)
+    @RolesAllowed(RoleSet.ETL_SERVER)
+    public DatabaseInstancePE getHomeDatabaseInstance();
+
+    @Transactional(readOnly = true)
+    @RolesAllowed(RoleSet.ETL_SERVER)
+    public ExperimentPE tryToGetBaseExperiment(final String sessionToken,
+            @AuthorizationGuard(guardClass = SampleOwnerIdentifierPredicate.class)
+            final SampleIdentifier sampleIdentifier) throws UserFailureException;
+
+    @Transactional(readOnly = true)
+    @RolesAllowed(RoleSet.ETL_SERVER)
+    public SamplePropertyPE[] tryToGetPropertiesOfTopSampleRegisteredFor(final String sessionToken,
+            @AuthorizationGuard(guardClass = SampleOwnerIdentifierPredicate.class)
+            final SampleIdentifier sampleIdentifier) throws UserFailureException;
+
+    @Transactional
+    @RolesAllowed(RoleSet.ETL_SERVER)
+    public void registerDataSet(final String sessionToken,
+            @AuthorizationGuard(guardClass = SampleOwnerIdentifierPredicate.class)
+            final SampleIdentifier sampleIdentifier, final String procedureTypeCode,
+            final ExternalData externalData) throws UserFailureException;
+
+    @Transactional
+    @RolesAllowed(RoleSet.ETL_SERVER)
+    public String createDataSetCode(final String sessionToken) throws UserFailureException;
+
+}
\ No newline at end of file
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ServerInterfaceRegressionTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ServerInterfaceRegressionTest.java
index 75e27b43735..b742f286d5f 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ServerInterfaceRegressionTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/ServerInterfaceRegressionTest.java
@@ -37,4 +37,11 @@ public class ServerInterfaceRegressionTest extends RegressionTestCase
         assertMandatoryMethodAnnotations(IPluginCommonServer.class);
         assertNormalizedSourceFilesAreEqual(IPluginCommonServer.class);
     }
+    
+    @Test
+    public void testIETLLIMSService()
+    {
+        assertMandatoryMethodAnnotations(IETLLIMSService.class);
+        assertNormalizedSourceFilesAreEqual(IETLLIMSService.class);
+    }
 }
-- 
GitLab