Commit 05dd4037 authored by cdanger's avatar cdanger

Merge branch 'release/10.2.0'

parents 2de06aa3 4b4b1753
......@@ -4,6 +4,11 @@ All notable changes to this project are documented in this file following the [K
Issues reported on [GitHub](https://github.com/authzforce/core/issues) are referenced in the form of `[GH-N]`, where N is the issue number. Issues reported on [OW2](https://jira.ow2.org/browse/AUTHZFORCE/) are mentioned in the form of `[OW2-N]`, where N is the issue number.
## 10.2.0
### Added
- Support for PDP configuration files located inside JARs (`jar` URLs)
## 10.1.0
### Changed
- Parent project version: 7.0.0 -> 7.1.0
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
<relativePath>..</relativePath>
</parent>
<artifactId>authzforce-ce-core-pdp-cli</artifactId>
......@@ -30,12 +30,12 @@
<dependency>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core-pdp-engine</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
</dependency>
<dependency>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core-pdp-io-xacml-json</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
......@@ -46,7 +46,7 @@
<dependency>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core-pdp-testutils</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
<relativePath>..</relativePath>
</parent>
<artifactId>authzforce-ce-core-pdp-engine</artifactId>
......
......@@ -25,6 +25,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigInteger;
import java.net.URL;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
......@@ -35,6 +36,7 @@ import java.util.Optional;
import java.util.Set;
import javax.xml.bind.JAXBException;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import org.ow2.authzforce.core.pdp.api.CloseableDesignatedAttributeProvider;
......@@ -459,6 +461,24 @@ public final class PdpEngineConfiguration
}
private static PdpEngineConfiguration getInstance(final Source confXmlSrc, final PdpModelHandler modelHandler, final EnvironmentProperties envProps) throws IOException, IllegalArgumentException
{
assert confXmlSrc != null && modelHandler != null;
// configuration file exists
final Pdp pdpJaxbConf;
try
{
pdpJaxbConf = modelHandler.unmarshal(confXmlSrc, Pdp.class);
}
catch (final JAXBException e)
{
throw new IllegalArgumentException("Invalid PDP configuration file", e);
}
return new PdpEngineConfiguration(pdpJaxbConf, envProps);
}
/**
* Create PDP instance
* <p>
......@@ -483,30 +503,20 @@ public final class PdpEngineConfiguration
// no property replacement of PARENT_DIR
throw new IllegalArgumentException("Invalid configuration file location: No file exists at: " + confFile);
}
// configuration file exists
if (modelHandler == null)
{
throw NULL_PDP_MODEL_HANDLER_ARGUMENT_EXCEPTION;
}
// configuration file exists
final Pdp pdpJaxbConf;
try
{
pdpJaxbConf = modelHandler.unmarshal(new StreamSource(confFile), Pdp.class);
}
catch (final JAXBException e)
{
throw new IllegalArgumentException("Invalid PDP configuration file", e);
}
// Set property PARENT_DIR in environment properties for future
// replacement in configuration strings by PDP extensions using file
// paths
/*
* Set property PARENT_DIR in environment properties for future replacement in configuration strings by PDP extensions using file paths
*/
final String propVal = confFile.getParentFile().toURI().toString();
LOGGER.debug("Property {} = {}", EnvironmentPropertyName.PARENT_DIR, propVal);
final EnvironmentProperties envProps = new DefaultEnvironmentProperties(Collections.singletonMap(EnvironmentPropertyName.PARENT_DIR, propVal));
return new PdpEngineConfiguration(pdpJaxbConf, envProps);
return getInstance(new StreamSource(confFile), modelHandler, envProps);
}
/**
......@@ -529,17 +539,46 @@ public final class PdpEngineConfiguration
*/
public static PdpEngineConfiguration getInstance(final String confLocation, final PdpModelHandler modelHandler) throws IOException, IllegalArgumentException
{
File confFile = null;
if (modelHandler == null)
{
throw NULL_PDP_MODEL_HANDLER_ARGUMENT_EXCEPTION;
}
try
{
final File confFile = ResourceUtils.getFile(confLocation);
return getInstance(confFile, modelHandler);
}
catch (final FileNotFoundException e)
{
if (LOGGER.isInfoEnabled())
{
LOGGER.info(
"Could not resolve input PDP configuration location to a file in the file system ({}). Trying to resolve as generic URL instead (but PARENT_DIR property will remain undefined).",
e.getMessage());
}
}
/*
* Not a file in the file system, e.g. maybe a file resource inside a JAR/ZIP
*/
final URL confUrl;
try
{
confFile = ResourceUtils.getFile(confLocation);
confUrl = ResourceUtils.getURL(confLocation);
}
catch (final FileNotFoundException e)
{
throw new IllegalArgumentException("Invalid PDP configuration location: " + confLocation, e);
throw new IllegalArgumentException("Invalid PDP configuration location (neither a file in the file system nor a valid URL): " + confLocation, e);
}
return getInstance(confFile, modelHandler);
/*
* Leave PARENT_DIR environment property undefined since we cannot get the file's parent directory
*/
LOGGER.debug("Property {} = <undefined>", EnvironmentPropertyName.PARENT_DIR);
final EnvironmentProperties envProps = new DefaultEnvironmentProperties(Collections.emptyMap());
return getInstance(new StreamSource(confUrl.toExternalForm()), modelHandler, envProps);
}
/**
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
<relativePath>..</relativePath>
</parent>
<artifactId>authzforce-ce-core-pdp-io-xacml-json</artifactId>
......@@ -42,7 +42,7 @@
<dependency>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core-pdp-testutils</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -3,7 +3,7 @@
<parent>
<groupId>org.ow2.authzforce</groupId>
<artifactId>authzforce-ce-core</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
<relativePath>..</relativePath>
</parent>
<artifactId>authzforce-ce-core-pdp-testutils</artifactId>
......@@ -23,7 +23,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${artifactId.prefix}-core-pdp-engine</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
......
......@@ -6,7 +6,7 @@
<version>7.1.0</version>
</parent>
<artifactId>authzforce-ce-core</artifactId>
<version>10.1.0</version>
<version>10.2.0</version>
<packaging>pom</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>AuthzForce - XACML-compliant Core PDP Engine and associated test modules</description>
......
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