Commit 087eb495 authored by Cyril Dangerville's avatar Cyril Dangerville

- Deleting ConfigurationStore, replaced by PdpConfigurationManager

- Upgraded test config.xml with new new PDP schema
- Upgrading to SNAPSHOT versions in POM
- Switching logging framework to log4j
- Updated license headers because we changed year to 2015
- Updated XML catalog to make it work with SchemaHandler to load PDP
config
parent a07d4265
......@@ -4,11 +4,11 @@
<parent>
<groupId>com.thalesgroup.authzforce</groupId>
<artifactId>authzforce-parent</artifactId>
<version>3.0.2</version>
<version>3.0.3-SNAPSHOT</version>
</parent>
<groupId>com.thalesgroup.authzforce.core</groupId>
<artifactId>authzforce-core</artifactId>
<version>FIWARE4.1</version>
<version>FIWARE4.2-SNAPSHOT</version>
<name>AuthZForce :: Core :: XACML Core Implementation</name>
<organization>
<name>Thales Services SAS</name>
......@@ -17,9 +17,14 @@
<inceptionYear>2011</inceptionYear>
<dependencies>
<dependency>
<!-- Used only to do Strings.join() in StandardFactory's init debug messages -->
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
......
This diff is collapsed.
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
......@@ -39,11 +39,8 @@ import java.net.URI;
import java.util.Collections;
import java.util.List;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.ExpressionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.w3c.dom.Node;
import com.sun.xacml.EvaluationCtx;
......@@ -127,6 +124,7 @@ public class VariableReference extends VariableReferenceType implements Evaluata
* @param metaData the meta-data associated with the containing policy
* @param manager the <code>VariableManager</code> used to connect this
* reference to its definition
* @return variable reference
*
* @throws ParsingException if the VariableReferenceType is invalid
*/
......@@ -150,7 +148,8 @@ public class VariableReference extends VariableReferenceType implements Evaluata
*
* @return the reference's identifier
*/
public String getVariableId() {
@Override
public String getVariableId() {
return variableId;
}
......@@ -183,7 +182,8 @@ public class VariableReference extends VariableReferenceType implements Evaluata
*
* @return the result of evaluation
*/
public EvaluationResult evaluate(EvaluationCtx context) {
@Override
public EvaluationResult evaluate(EvaluationCtx context) {
Expression xpr = (Expression)getReferencedDefinition().getExpression().getValue();
// Note that it's technically possible for this expression to
......@@ -192,7 +192,7 @@ public class VariableReference extends VariableReferenceType implements Evaluata
// it makes no sense, however, it's unlcear exactly what the
// error should be, so raising the ClassCastException here seems
// as good an approach as any for now...
return ((Expression)xpr).evaluate(context);
return xpr.evaluate(context);
}
/**
......@@ -209,10 +209,10 @@ public class VariableReference extends VariableReferenceType implements Evaluata
// been parsed yet
if (definition != null) {
return ((Expression)definition.getExpression().getValue()).getType();
} else {
if (manager != null)
return manager.getVariableType(variableId);
}
if (manager != null)
return manager.getVariableType(variableId);
throw new ProcessingException("couldn't resolve the type");
}
......@@ -228,10 +228,10 @@ public class VariableReference extends VariableReferenceType implements Evaluata
// see comment in getType()
if (definition != null) {
return ((Expression)getReferencedDefinition().getExpression().getValue()).returnsBag();
} else {
if (manager != null)
return manager.returnsBag(variableId);
}
if (manager != null)
return manager.returnsBag(variableId);
throw new ProcessingException("couldn't resolve the return type");
}
......@@ -246,7 +246,8 @@ public class VariableReference extends VariableReferenceType implements Evaluata
*
* @throws ProcessingException if the return type couldn't be resolved
*/
public boolean evaluatesToBag() {
@Override
public boolean evaluatesToBag() {
return returnsBag();
}
......@@ -259,7 +260,8 @@ public class VariableReference extends VariableReferenceType implements Evaluata
*
* @return an empty <code>List</code>
*/
public List getChildren() {
@Override
public List getChildren() {
return Collections.EMPTY_LIST;
}
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS - All rights reserved.
* Copyright (C) 2011-2015 Thales Services SAS - All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......@@ -100,8 +100,25 @@ public class PdpConfigurationManager
private final FunctionFactoryProxy defaultFunctionFactoryProxy;
/**
* Load PDP configuration handler. Parameters here are locations to XSD files. Locations can be
* any resource string supported by Spring ResourceLoader. More info:
* Load PDP configuration handler.
*
* @param confLocation
* PDP configuration XML file, compliant with the PDP XML schema (pdp.xsd)
*
* @throws IOException
* I/O error reading from confLocation
* @throws JAXBException
* Error unmarshalling to Pdps instance from confLocation
*
*/
public PdpConfigurationManager(String confLocation) throws IOException, JAXBException
{
this(confLocation, null, null);
}
/**
* Load PDP configuration handler. Locations here can be any resource string supported by Spring
* ResourceLoader. More info:
* http://docs.spring.io/spring/docs/current/spring-framework-reference/html/resources.html
*
* For example: classpath:com/myapp/aaa.xsd, file:///data/bbb.xsd, http://myserver/ccc.xsd...
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......@@ -67,6 +67,11 @@ public class PdpModelHandler
*/
public final static String CORE_XSD_LOCATION = "classpath:pdp.xsd";
/**
* Default location of XML catalog to resolve imported XML schemas in {@value PdpModelHandler#CORE_XSD_LOCATION}
*/
public final static String DEFAULT_CATALOG_LOCATION = "classpath:catalog.xml";
private final static String[] XACML_3_0_SCHEMA_LOCATIONS = {"classpath:xml.xsd", "classpath:xacml-core-v3-schema-wd-17.xsd"};
/**
......@@ -295,7 +300,16 @@ public class PdpModelHandler
}
// Load schema for validating XML configurations
confSchema = SchemaHandler.createSchema(schemaLocations, catalogLocation);
final String schemaHandlerCatalogLocation;
if(catalogLocation == null) {
LOGGER.info("No XML catalog location specified for PDP schema handler, using default: {}", DEFAULT_CATALOG_LOCATION);
schemaHandlerCatalogLocation = DEFAULT_CATALOG_LOCATION;
} else {
LOGGER.info("XML catalog location specified for PDP schema handler: {}", catalogLocation);
schemaHandlerCatalogLocation = catalogLocation;
}
confSchema = SchemaHandler.createSchema(schemaLocations, schemaHandlerCatalogLocation);
}
/**
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......@@ -83,7 +83,7 @@ public class SchemaHandler
return schema;
}
public static Schema createSchema(List<String> locations, String catalogLocation)
public static Schema createSchema(List<String> locations, final String catalogLocation)
{
final SchemaFactory factory = SchemaFactory.newInstance(Constants.URI_2001_SCHEMA_XSD);
......@@ -175,7 +175,9 @@ public class SchemaHandler
}
} catch (Exception ex)
{
// ignore
final String errMsg = String.format("Unable to resolve schema-required entity with XML catalog ('%s'): type=%s, namespaceURI=%s, publicId=%s, systemId=%, baseURI=%s", catalogLocation, type, namespaceURI, publicId, systemId, baseURI);
LOGGER.error(errMsg, ex);
throw new RuntimeException(errMsg, ex);
}
return null;
}
......
/**
* Copyright (C) 2011-2014 Thales Services SAS.
* Copyright (C) 2011-2015 Thales Services SAS.
*
* This file is part of AuthZForce.
*
......
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<public publicId="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" uri="classpath:xacml-core-v3-schema-wd-17.xsd" />
<system systemId="http://www.w3.org/2001/xml.xsd" uri="classpath:xml.xsd" />
<!-- For Maven JAXB plugin -->
<public publicId="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" uri="classpath:xacml-core-v3-schema-wd-17.xsd" />
<public publicId="http://thalesgroup.com/authz/model/ext/3.0" uri="classpath:authz-ext-base.xsd" />
<!-- For AuthZForce SchemaHandler (more precisely: imported CXF OASISCatalogManager) -->
<uri name="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" uri="classpath:xacml-core-v3-schema-wd-17.xsd"/>
<uri name="http://thalesgroup.com/authz/model/ext/3.0" uri="classpath:authz-ext-base.xsd"/>
</catalog>
\ No newline at end of file
......@@ -3,7 +3,7 @@
targetNamespace="http://thalesgroup.com/authzforce/pdp/model/2014/12"
xmlns:tns="http://thalesgroup.com/authzforce/pdp/model/2014/12"
elementFormDefault="qualified" xmlns:authz-ext="http://thalesgroup.com/authz/model/ext/3.0">
<import namespace="http://thalesgroup.com/authz/model/ext/3.0"></import>
<import namespace="http://thalesgroup.com/authz/model/ext/3.0" />
<annotation>
<documentation xml:lang="en">
Data model of AuthZForce PDP configuration
......
......@@ -2,7 +2,6 @@ package com.thalesgroup.authzforce.pdp.core.test.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;
import java.net.URL;
......@@ -13,6 +12,7 @@ import java.util.Properties;
import java.util.Set;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.parsers.DocumentBuilder;
......@@ -30,7 +30,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import com.sun.xacml.BasicEvaluationCtx;
import com.sun.xacml.ConfigurationStore;
import com.sun.xacml.EvaluationCtx;
import com.sun.xacml.PDP;
import com.sun.xacml.PDPConfig;
......@@ -41,6 +40,7 @@ import com.sun.xacml.ctx.Result;
import com.sun.xacml.finder.PolicyFinder;
import com.sun.xacml.finder.PolicyFinderModule;
import com.sun.xacml.support.finder.StaticPolicyFinderModule;
import com.thalesgroup.authzforce.core.PdpConfigurationManager;
import com.thalesgroup.authzforce.core.PdpModelHandler;
public class TestUtils
......@@ -327,17 +327,32 @@ public class TestUtils
*/
public static PDP getPDPNewInstance(String rootDir, String versionDir, Set<String> policyfilenames) {
Properties properties = new Properties();
ConfigurationStore testConfigurationStore = null;
// ConfigurationStore testConfigurationStore = null;
try {
properties.load(new FileInputStream(new File("src/test/resources", "authzforce.test.properties")));
PropertyConfigurator.configure(properties.getProperty("logProperties"));
File configFile = new File(properties.getProperty("configFile"));
testConfigurationStore = new ConfigurationStore(configFile, null, null);
} catch (ParsingException | IOException e) {
// File configFile = new File(properties.getProperty("configFile"));
// testConfigurationStore = new ConfigurationStore(configFile, null, null);
} catch (/*ParsingException |*/ IOException e) {
throw new RuntimeException(e);
}
//PropertyConfigurator.configure(properties.getProperty("logProperties"));
final String confLocation = properties.getProperty("configFile");
final PdpConfigurationManager testConfMgr;
try
{
testConfMgr = new PdpConfigurationManager(confLocation);
} catch (IOException e)
{
throw new RuntimeException("Error parsing PDP configuration from location: " + confLocation, e);
} catch (JAXBException e)
{
throw new RuntimeException("Error parsing PDP configuration from location: " + confLocation, e);
}
PolicyFinder policyFinder = new PolicyFinder();
List<String> policyLocations = new ArrayList<>();
......@@ -366,13 +381,8 @@ public class TestUtils
PDP authzforce = PDP.getInstance();
PDPConfig pdpConfig = authzforce.getPDPConfig();
try {
pdpConfig = new PDPConfig(testConfigurationStore.getDefaultPDPConfig().getAttributeFinder(), policyFinder,
testConfigurationStore.getDefaultPDPConfig().getResourceFinder(), null);
} catch (UnknownIdentifierException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
pdpConfig = new PDPConfig(testConfMgr.getDefaultPDPConfig().getAttributeFinder(), policyFinder,
testConfMgr.getDefaultPDPConfig().getResourceFinder(), null);
return new PDP(pdpConfig);
}
......
logProperties: src/test/resources/logback.xml
configFile: src/test/resources/config.xml
\ No newline at end of file
# Logback is using classpath:logback.xml by default
#logProperties: classpath:logback.xml
# PDP configuration file (any Spring resource location allowed)
configFile: classpath:config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://theresis.thalesgroup.com/shared/schema/config/pdp"
<pdps xmlns="http://thalesgroup.com/authzforce/pdp/model/2014/12"
defaultAttributeFactory="attr" defaultCombiningAlgFactory="comb" defaultFunctionFactory="func"
defaultPDP="AuthZForce-REST" xmlns:config="http://theresis.thalesgroup.com/shared/schema/config/pdp"
defaultPDP="TestPDP"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<pdp name="AuthZForce-REST">
<attributeFinderModule class="com.sun.xacml.finder.impl.SelectorModule" />
<attributeFinderModule class="com.sun.xacml.finder.impl.CurrentEnvModule" />
<!-- <resourceFinderModule class="com.sun.xacml.finder.impl.MultipleResourceFinder" /> -->
<pdp name="TestPDP">
<attributeFinder xsi:type="CurrentDateTimeFinder" />
<attributeFinder xsi:type="AttributeSelectorXPathFinder" />
</pdp>
<attributeFactory name="attr" useStandardDatatypes="true" />
<combiningAlgFactory name="comb" useStandardAlgorithms="true" />
<functionFactory name="func" useStandardFunctions="true">
<!-- <condition> <function class="TimeInRangeFunction"/> </condition> -->
</functionFactory>
</config>
\ No newline at end of file
<functionFactory name="func" useStandardFunctions="true" />
</pdps>
\ No newline at end of file
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