Commit 0df9094c authored by Andrey Lugovskiy's avatar Andrey Lugovskiy Committed by Matija Obreza

Enabled ACL support on RepositoryFile

parent 72794bf5
......@@ -119,6 +119,12 @@
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
......@@ -163,8 +169,8 @@
</dependency>
<dependency>
<groupId>org.genesys-pgr</groupId>
<artifactId>application-blocks-core</artifactId>
<version>1.4-SNAPSHOT</version>
<artifactId>application-blocks-security</artifactId>
<version>${application.blocks.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
......
......@@ -38,15 +38,14 @@ import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.model.AuditedVersionedModelWithoutId;
import org.genesys.blocks.model.Copyable;
import org.genesys.blocks.model.EntityId;
import org.genesys.blocks.model.InMemoryIdGenerator;
import org.genesys.blocks.security.model.AclAwareModel;
import org.genesys.filerepository.metadata.BaseMetadata;
import org.genesys.filerepository.service.BytesStorageService;
import org.hibernate.annotations.Type;
// TODO: Auto-generated Javadoc
/**
* The Class RepositoryFile.
* The RepositoryFile.
*/
@Entity
@Table(name = "repositoryfile",
......@@ -55,7 +54,7 @@ import org.hibernate.annotations.Type;
// unique
, uniqueConstraints = { @UniqueConstraint(columnNames = { "path", "originalFilename" }) })
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class RepositoryFile extends AuditedVersionedModelWithoutId implements EntityId, BaseMetadata, Copyable<RepositoryFile> {
public class RepositoryFile extends AuditedVersionedModelWithoutId implements AclAwareModel, BaseMetadata, Copyable<RepositoryFile> {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -4816923593950502695L;
......
......@@ -29,6 +29,8 @@ import org.genesys.filerepository.metadata.ImageMetadata;
import org.genesys.filerepository.model.RepositoryFile;
import org.genesys.filerepository.model.RepositoryImage;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
// TODO: Auto-generated Javadoc
/**
......@@ -50,8 +52,9 @@ public interface RepositoryService {
* exception
* @throws IOException when things go wrong on bytes storage level
*/
RepositoryFile addFile(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryFile metaData) throws InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException;
@PreAuthorize("isAuthenticated()")
RepositoryFile addFile(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryFile metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException, IOException;
/**
* Add a new image to the file repository.
......@@ -67,8 +70,9 @@ public interface RepositoryService {
* exception
* @throws IOException when things go wrong on bytes storage level
*/
RepositoryImage addImage(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryImage metaData) throws InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException;
@PreAuthorize("isAuthenticated()")
RepositoryImage addImage(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryImage metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException, IOException;
/**
* Get repository file by its UUID.
......@@ -78,6 +82,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException when file is not available in the
* repository
*/
@PostAuthorize("hasRole('ADMINISTRATOR') or hasPermission(returnObject, 'read')")
RepositoryFile getFile(UUID fileUuid) throws NoSuchRepositoryFileException;
/**
......@@ -88,6 +93,7 @@ public interface RepositoryService {
* @return the file
* @throws NoSuchRepositoryFileException the no such repository file exception
*/
@PostAuthorize("hasRole('ADMINISTRATOR') or hasPermission(returnObject, 'read')")
RepositoryFile getFile(String path, String filename) throws NoSuchRepositoryFileException;
/**
......@@ -107,6 +113,7 @@ public interface RepositoryService {
* @return the file bytes
* @throws IOException Signals that an I/O exception has occurred.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#repositoryFile, 'read')")
byte[] getFileBytes(RepositoryFile repositoryFile) throws IOException;
/**
......@@ -124,7 +131,7 @@ public interface RepositoryService {
* @return the files
*/
Stream<RepositoryFile> streamFiles(String repositoryPath);
/**
* Update file metadata. The update is based on the record UUID.
*
......@@ -135,6 +142,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException when file is not available in the
* repository
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#fileData, 'write')")
<T extends RepositoryFile> T updateMetadata(UUID uuid, T fileData) throws NoSuchRepositoryFileException;
/**
......@@ -147,6 +155,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#fileData, 'write')")
RepositoryFile updateBytes(RepositoryFile fileData, String contentType, byte[] bytes) throws NoSuchRepositoryFileException, IOException;
/**
......@@ -160,6 +169,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#imageData, 'write')")
RepositoryImage updateImageBytes(RepositoryImage imageData, String contentType, byte[] bytes) throws NoSuchRepositoryFileException, IOException;
/**
......@@ -171,6 +181,7 @@ public interface RepositoryService {
* repository
* @throws IOException Signals that an I/O exception has occurred.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#repositoryFile, 'delete')")
RepositoryFile removeFile(RepositoryFile repositoryFile) throws NoSuchRepositoryFileException, IOException;
/**
......@@ -182,6 +193,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws InvalidRepositoryPathException when the new path is invalid
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#repositoryFile, 'write')")
RepositoryFile moveFile(RepositoryFile repositoryFile, String newPath) throws NoSuchRepositoryFileException, InvalidRepositoryPathException;
/**
......@@ -194,6 +206,7 @@ public interface RepositoryService {
* @throws InvalidRepositoryFileDataException the invalid repository file data
* exception
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#repositoryFile, 'write')")
RepositoryFile moveAndRenameFile(RepositoryFile repositoryFile, String fullPath) throws InvalidRepositoryPathException, InvalidRepositoryFileDataException;
/**
......@@ -234,6 +247,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException when file is not available in the
* repository
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#imageData, 'write')")
RepositoryImage updateImageMetadata(UUID uuid, RepositoryImage imageData) throws NoSuchRepositoryFileException;
/**
......@@ -245,6 +259,7 @@ public interface RepositoryService {
* repository
* @throws IOException Signals that an I/O exception has occurred.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#repositoryImage, 'delete')")
RepositoryImage removeImage(RepositoryImage repositoryImage) throws NoSuchRepositoryFileException, IOException;
/**
......
......@@ -78,7 +78,7 @@
<jdk.source>1.8</jdk.source>
<show.deprecations>false</show.deprecations>
<application.blocks.version>1.1-SNAPSHOT</application.blocks.version>
<application.blocks.version>1.4-SNAPSHOT</application.blocks.version>
<maven-gpg-plugin.version>1.5</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
......@@ -87,6 +87,7 @@
<org.hamcrest.version>1.3</org.hamcrest.version>
<commons.io.version>2.4</commons.io.version>
<spring.version>4.3.2.RELEASE</spring.version>
<spring.security.version>4.1.3.RELEASE</spring.security.version>
<spring.data.version>1.10.4.RELEASE</spring.data.version>
<querydsl.version>4.1.4</querydsl.version>
<hibernate.version>4.3.11.Final</hibernate.version>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment