[java-opensaml] branch master updated: Add Assertion validation support for ProxyRestriction conditions.
Brent Putman
putmanb at georgetown.edu
Fri Nov 22 18:26:09 EST 2019
This is an automated email from the git hooks/post-receive script.
putmanb pushed a commit to branch master
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=cc43d3ae5bb965247a2343d5767878b491ab780b
The following commit(s) were added to refs/heads/master by this push:
new cc43d3a Add Assertion validation support for ProxyRestriction conditions.
cc43d3a is described below
commit cc43d3ae5bb965247a2343d5767878b491ab780b
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Fri Nov 22 18:26:06 2019 -0500
Add Assertion validation support for ProxyRestriction conditions.
This condition is a 'condition of use' and doesn't affect validity,
but need this no-op ConditionValidator impl to handle the condition.
---
.../impl/ProxyRestrictionConditionValidator.java | 77 ++++++++++++++++++++++
.../ProxyRestrictionConditionValidatorTest.java | 63 ++++++++++++++++++
2 files changed, 140 insertions(+)
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/assertion/impl/ProxyRestrictionConditionValidator.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/assertion/impl/ProxyRestrictionConditionValidator.java
new file mode 100644
index 0000000..804d464
--- /dev/null
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/assertion/impl/ProxyRestrictionConditionValidator.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opensaml.saml.saml2.assertion.impl;
+
+import java.util.Objects;
+
+import javax.annotation.Nonnull;
+import javax.annotation.concurrent.ThreadSafe;
+import javax.xml.namespace.QName;
+
+import org.opensaml.saml.common.assertion.AssertionValidationException;
+import org.opensaml.saml.common.assertion.ValidationContext;
+import org.opensaml.saml.common.assertion.ValidationResult;
+import org.opensaml.saml.saml2.assertion.ConditionValidator;
+import org.opensaml.saml.saml2.core.Assertion;
+import org.opensaml.saml.saml2.core.Condition;
+import org.opensaml.saml.saml2.core.ProxyRestriction;
+
+
+/**
+ * {@link ConditionValidator} implementation for <code>ProxyRestriction</code> style conditions.
+ *
+ * <p>
+ * Note, as proxy restriction conditions do not place any conditions on the use of an assertion this condition
+ * always evaluates as valid with the assumption that further processing of this information will be done later
+ * by the invoker of the validation process.
+ * </p>
+ *
+ * <p>
+ * Supports the following {@link ValidationContext} static parameters:
+ * <ul>
+ * None.
+ * </ul>
+ * </p>
+ *
+ * <p>
+ * Supports the following {@link ValidationContext} dynamic parameters:
+ * <ul>
+ * None.
+ * </ul>
+ * </p>
+ */
+ at ThreadSafe
+public class ProxyRestrictionConditionValidator implements ConditionValidator {
+
+ /** {@inheritDoc} */
+ @Nonnull public QName getServicedCondition() {
+ return ProxyRestriction.DEFAULT_ELEMENT_NAME;
+ }
+
+ /** {@inheritDoc} */
+ @Nonnull public ValidationResult validate(@Nonnull final Condition condition, @Nonnull final Assertion assertion,
+ @Nonnull final ValidationContext context) throws AssertionValidationException {
+
+ if ((condition instanceof ProxyRestriction)
+ || Objects.equals(condition.getElementQName(), ProxyRestriction.DEFAULT_ELEMENT_NAME)) {
+ // Proxy restriction information is a 'condition of use' type condition so we always return valid.
+ return ValidationResult.VALID;
+ }
+ return ValidationResult.INDETERMINATE;
+ }
+}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/assertion/impl/ProxyRestrictionConditionValidatorTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/assertion/impl/ProxyRestrictionConditionValidatorTest.java
new file mode 100644
index 0000000..0c1d358
--- /dev/null
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/assertion/impl/ProxyRestrictionConditionValidatorTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the University Corporation for Advanced Internet Development,
+ * Inc. (UCAID) under one or more contributor license agreements. See the
+ * NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The UCAID licenses this file to You under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opensaml.saml.saml2.assertion.impl;
+
+import org.opensaml.saml.common.assertion.AssertionValidationException;
+import org.opensaml.saml.common.assertion.ValidationContext;
+import org.opensaml.saml.common.assertion.ValidationResult;
+import org.opensaml.saml.saml2.assertion.BaseAssertionValidationTest;
+import org.opensaml.saml.saml2.core.Condition;
+import org.opensaml.saml.saml2.core.OneTimeUse;
+import org.opensaml.saml.saml2.core.ProxyRestriction;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class ProxyRestrictionConditionValidatorTest extends BaseAssertionValidationTest {
+
+ private ProxyRestrictionConditionValidator validator;
+
+ private Condition condition;
+
+ @BeforeMethod(dependsOnMethods="setUpBasicAssertion")
+ public void setUp() {
+ validator = new ProxyRestrictionConditionValidator();
+ condition = (Condition) buildXMLObject(ProxyRestriction.DEFAULT_ELEMENT_NAME);
+ getAssertion().getConditions().getConditions().add(condition);
+ }
+
+ @Test
+ public void testExpected() throws AssertionValidationException {
+ ValidationContext validationContext = new ValidationContext(buildBasicStaticParameters());
+
+ Assert.assertEquals(validator.validate(condition, getAssertion(), validationContext),
+ ValidationResult.VALID);
+ }
+
+ @Test
+ public void testUnexpected() throws AssertionValidationException {
+ condition = buildXMLObject(OneTimeUse.DEFAULT_ELEMENT_NAME);
+ getAssertion().getConditions().getConditions().add(condition);
+
+ ValidationContext validationContext = new ValidationContext(buildBasicStaticParameters());
+
+ Assert.assertEquals(validator.validate(condition, getAssertion(), validationContext),
+ ValidationResult.INDETERMINATE);
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list