Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 committed Aug 2, 2024
1 parent 630c371 commit c1cce1d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/databasepreservation/DBVTK.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public FilterRegistrationBean<OnOffFilter> casSingleSignOutFilter() {
FilterRegistrationBean<OnOffFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasSingleSignOutFilter");
registrationBean.addInitParameter("inner-filter-class", "org.jasig.cas.client.session.SingleSignOutFilter");
registrationBean.addInitParameter("inner-filter-class", "org.apereo.cas.client.session.SingleSignOutFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerUrlPrefix", "http://localhost:8888/cas");
registrationBean.addUrlPatterns("/*");
Expand All @@ -149,7 +149,7 @@ public FilterRegistrationBean<OnOffFilter> casValidationFilter() {
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasValidationFilter");
registrationBean.addInitParameter("inner-filter-class",
"org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter");
"org.apereo.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerUrlPrefix", "https://localhost:8443/cas");
registrationBean.addInitParameter("serverName", "https://localhost:8888");
Expand All @@ -168,7 +168,7 @@ public FilterRegistrationBean<OnOffFilter> casAuthenticationFilter() {
FilterRegistrationBean<OnOffFilter> registrationBean = new FilterRegistrationBean<>();
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasAuthenticationFilter");
registrationBean.addInitParameter("inner-filter-class", "org.jasig.cas.client.authentication.AuthenticationFilter");
registrationBean.addInitParameter("inner-filter-class", "org.apereo.cas.client.authentication.AuthenticationFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addInitParameter("casServerLoginUrl", "https://localhost:8443/cas/login");
registrationBean.addUrlPatterns("/login");
Expand All @@ -182,7 +182,7 @@ public FilterRegistrationBean<OnOffFilter> casRequestWrapperFilter() {
registrationBean.setFilter(new OnOffFilter());
registrationBean.setName("CasRequestWrapperFilter");
registrationBean.addInitParameter("inner-filter-class",
"org.jasig.cas.client.util.HttpServletRequestWrapperFilter");
"org.apereo.cas.client.util.HttpServletRequestWrapperFilter");
registrationBean.addInitParameter("config-prefix", "ui.filter.cas");
registrationBean.addUrlPatterns("/*");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.roda.core.data.exceptions.AlreadyExistsException;
import org.roda.core.data.exceptions.GenericException;
Expand Down Expand Up @@ -87,8 +90,12 @@ public ResponseEntity<Resource> getSIARDFile(String filename) {
java.nio.file.Path basePath = Paths.get(ViewerConfiguration.getInstance().getViewerConfigurationAsString("/",
ViewerConfiguration.PROPERTY_BASE_UPLOAD_PATH));
java.nio.file.Path siardPath = siardFilesPath.resolve(filename);
if (java.nio.file.Files.exists(siardPath) && !java.nio.file.Files.isDirectory(siardPath)
&& (ViewerConfiguration.checkPathIsWithin(siardPath, siardFilesPath)

if (java.nio.file.Files.isDirectory(siardPath)) {
siardPath = zipDirectory(siardPath);
}

if (java.nio.file.Files.exists(siardPath) && (ViewerConfiguration.checkPathIsWithin(siardPath, siardFilesPath)
|| ViewerConfiguration.checkPathIsWithin(siardPath, basePath))) {

InputStreamResource resource = new InputStreamResource(new FileInputStream(siardPath.toFile()));
Expand All @@ -101,12 +108,32 @@ public ResponseEntity<Resource> getSIARDFile(String filename) {
} catch (NotFoundException | FileNotFoundException e) {
state = LogEntryState.FAILURE;
throw new RESTException(e);
} catch (IOException e) {
throw new RESTException(e);
} finally {
// register action
controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_FILENAME_PARAM, filename);
}
}

private java.nio.file.Path zipDirectory(java.nio.file.Path dirPath) throws IOException {
java.nio.file.Path zipFilePath = dirPath.resolveSibling(dirPath.getFileName().toString() + ".zip");
try (FileOutputStream fos = new FileOutputStream(zipFilePath.toFile());
ZipOutputStream zos = new ZipOutputStream(fos)) {
java.nio.file.Files.walk(dirPath).filter(path -> !java.nio.file.Files.isDirectory(path)).forEach(path -> {
ZipEntry zipEntry = new ZipEntry(dirPath.relativize(path).toString());
try {
zos.putNextEntry(zipEntry);
java.nio.file.Files.copy(path, zos);
zos.closeEntry();
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
return zipFilePath;
}

@Override
public void deleteSiardFile(String filename) {
final ControllerAssistant controllerAssistant = new ControllerAssistant() {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ private void createdNestedDocument(ViewerRow row, String parentUUID, List<SolrIn
String key = cell.getKey();
if (columnsToDisplay.contains(key)) {
ViewerCell cellValue = cell.getValue();
cellValue.setMimeType(".tif");
fields.put(key, cellValue.getValue());
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.session.SingleSignOutFilter</param-value>
<param-value>org.apereo.cas.client.session.SingleSignOutFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand All @@ -100,7 +100,7 @@
</filter-mapping>
<listener>
<!-- Listener to clean sessions -->
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
<listener-class>org.apereo.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
</listener>

<!-- validation filter must appear before the authentication filter -->
Expand All @@ -109,7 +109,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter</param-value>
<param-value>org.apereo.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand Down Expand Up @@ -150,7 +150,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.authentication.AuthenticationFilter</param-value>
<param-value>org.apereo.cas.client.authentication.AuthenticationFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand All @@ -175,7 +175,7 @@
<filter-class>com.databasepreservation.common.filter.OnOffFilter</filter-class>
<init-param>
<param-name>inner-filter-class</param-name>
<param-value>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</param-value>
<param-value>org.apereo.cas.client.util.HttpServletRequestWrapperFilter</param-value>
</init-param>
<init-param>
<param-name>config-prefix</param-name>
Expand Down

0 comments on commit c1cce1d

Please sign in to comment.