We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Steps to reproduce overview:
Reproducing test:
import org.junit.Test; import org.xacml4j.v30.Effect; import org.xacml4j.v30.marshal.jaxb.Xacml30PolicyMarshaller; import org.xacml4j.v30.pdp.Apply; import org.xacml4j.v30.pdp.Policy; import org.xacml4j.v30.pdp.Rule; import org.xacml4j.v30.policy.combine.DenyOverridesRuleCombiningAlgorithm; import org.xacml4j.v30.spi.function.FunctionProvider; import org.xacml4j.v30.spi.function.FunctionProviderBuilder; import org.xacml4j.v30.types.IntegerExp; import org.xacml4j.v30.types.StringExp; import java.io.IOException; import java.io.StringWriter; import java.io.Writer; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsNull.notNullValue; public class MarshalAttributeValueTest { private final static FunctionProvider Funcs = FunctionProviderBuilder.builder() .defaultFunctions() .build(); // // This test fails with error "unable to marshal type "java.lang.Long" as an element because it is missing an @XmlRootElement annotation" // @Test public void marshalIntegerAttributeValue() throws IOException { // arrange Rule rule = Rule.builder("rule", Effect.DENY) .condition( Apply.builder(Funcs.getFunction("urn:oasis:names:tc:xacml:1.0:function:integer-equal")) .param(IntegerExp.of(0)) .param(IntegerExp.of(1)) .build() ) .build(); Policy policy = Policy.builder("policy") .combiningAlgorithm(new DenyOverridesRuleCombiningAlgorithm()) .rule(rule) .build(); // act Writer writer = new StringWriter(); new Xacml30PolicyMarshaller().marshal(policy, writer); String xml = writer.toString(); // assert assertThat(xml, notNullValue()); } // // ...but this one is ok. // @Test public void marshalStringAttributeValue() throws IOException { // arrange Rule rule = Rule.builder("rule", Effect.DENY) .condition( Apply.builder(Funcs.getFunction("urn:oasis:names:tc:xacml:1.0:function:string-equal")) .param(StringExp.of("a")) .param(StringExp.of("b")) .build() ) .build(); Policy policy = Policy.builder("policy") .combiningAlgorithm(new DenyOverridesRuleCombiningAlgorithm()) .rule(rule) .build(); // act Writer writer = new StringWriter(); new Xacml30PolicyMarshaller().marshal(policy, writer); String xml = writer.toString(); // assert assertThat(xml, notNullValue()); } }
The text was updated successfully, but these errors were encountered:
I'm using version 1.3.2 from https://jcenter.bintray.com
Sorry, something went wrong.
I suppose the problem in ExpressionTypeBuilder:
ATTRIBUTE(AttributeExp.class){ @Override public JAXBElement<?> from(Expression e){ Preconditions.checkArgument(e instanceof AttributeExp); AttributeExp v = (AttributeExp)e; AttributeValueType exp = factory.createAttributeValueType(); exp.setDataType(v.getType().getDataTypeId()); exp.getContent().add(v.getValue()); return factory.createAttributeValue(exp); } }
it adds attribute value to content as is, but really should use TypeToXacml30 to convert value to string representation.
Thank you for a detailed report!
No branches or pull requests
Steps to reproduce overview:
Reproducing test:
The text was updated successfully, but these errors were encountered: