[java-opensaml] branch master updated: Deprecate and replace long-winded AuthnContext methods.
Scott Cantor
cantor.2 at osu.edu
Mon Nov 18 11:41:34 EST 2019
This is an automated email from the git hooks/post-receive script.
scantor 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=5d94d8a0abd0d62783b0da23efcb9cf5f8a74748
The following commit(s) were added to refs/heads/master by this push:
new 5d94d8a Deprecate and replace long-winded AuthnContext methods.
5d94d8a is described below
commit 5d94d8a0abd0d62783b0da23efcb9cf5f8a74748
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Nov 18 11:41:26 2019 -0500
Deprecate and replace long-winded AuthnContext methods.
---
.../saml/saml2/core/AuthnContextClassRef.java | 38 +++++++++++++++++----
.../saml/saml2/core/AuthnContextDeclRef.java | 39 ++++++++++++++++++----
.../saml2/core/impl/AuthnContextClassRefImpl.java | 22 +++++++-----
.../core/impl/AuthnContextClassRefMarshaller.java | 4 +--
.../impl/AuthnContextClassRefUnmarshaller.java | 4 +--
.../saml2/core/impl/AuthnContextDeclRefImpl.java | 22 +++++++-----
.../core/impl/AuthnContextDeclRefMarshaller.java | 4 +--
.../core/impl/AuthnContextDeclRefUnmarshaller.java | 4 +--
.../opensaml/saml/saml2/core/AuthnRequestTest.java | 12 +++----
.../saml2/core/ResponseSuccessAuthnAttribTest.java | 32 +++++++++---------
.../saml2/core/impl/AuthnContextClassRefTest.java | 4 +--
.../saml2/core/impl/AuthnContextDeclRefTest.java | 4 +--
12 files changed, 127 insertions(+), 62 deletions(-)
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextClassRef.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextClassRef.java
index 5bea2f6..966bba3 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextClassRef.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextClassRef.java
@@ -20,35 +20,61 @@
*/
package org.opensaml.saml.saml2.core;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.saml.common.SAMLObject;
import org.opensaml.saml.common.xml.SAMLConstants;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
/**
* SAML 2.0 Core AuthnContextClassRef.
*/
public interface AuthnContextClassRef extends SAMLObject {
/** Element local name. */
- public static final String DEFAULT_ELEMENT_LOCAL_NAME = "AuthnContextClassRef";
+ @Nonnull @NotEmpty static final String DEFAULT_ELEMENT_LOCAL_NAME = "AuthnContextClassRef";
/** Default element name. */
- public static final QName DEFAULT_ELEMENT_NAME =
+ @Nonnull static final QName DEFAULT_ELEMENT_NAME =
new QName(SAMLConstants.SAML20_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
+
+ /**
+ * Gets the URI reference to an authentication context class.
+ *
+ * @return authentication context class reference URI
+ */
+ @Nullable String getURI();
+
+ /**
+ * Sets the URI reference to an authentication context class.
+ *
+ * @param uri the new AuthnContextClassRef URI
+ */
+ void setURI(@Nullable final String uri);
/**
* Gets the URI reference to an authentication context class.
*
* @return authentication context class reference URI
+ *
+ * @deprecated
*/
- public String getAuthnContextClassRef();
+ @Nullable default String getAuthnContextClassRef() {
+ return getURI();
+ }
/**
* Sets the URI reference to an authentication context class.
*
- * @param newAuthnContextClassRef the new AuthnContextClassRef URI
+ * @param uri the new AuthnContextClassRef URI
+ *
+ * @deprecated
*/
- public void setAuthnContextClassRef(String newAuthnContextClassRef);
+ default void setAuthnContextClassRef(@Nullable final String uri) {
+ setURI(uri);
+ }
-}
+}
\ No newline at end of file
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextDeclRef.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextDeclRef.java
index efe9605..3b28ad8 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextDeclRef.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/core/AuthnContextDeclRef.java
@@ -17,21 +17,25 @@
package org.opensaml.saml.saml2.core;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.saml.common.SAMLObject;
import org.opensaml.saml.common.xml.SAMLConstants;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
/**
* SAML 2.0 Core AuthnContextDeclRef.
*/
public interface AuthnContextDeclRef extends SAMLObject {
/** Element local name. */
- public static final String DEFAULT_ELEMENT_LOCAL_NAME = "AuthnContextDeclRef";
+ @Nonnull @NotEmpty static final String DEFAULT_ELEMENT_LOCAL_NAME = "AuthnContextDeclRef";
/** Default element name. */
- public static final QName DEFAULT_ELEMENT_NAME =
+ @Nonnull static final QName DEFAULT_ELEMENT_NAME =
new QName(SAMLConstants.SAML20_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
/**
@@ -39,12 +43,35 @@ public interface AuthnContextDeclRef extends SAMLObject {
*
* @return authentication context declaration reference URI
*/
- public String getAuthnContextDeclRef();
+ @Nullable String getURI();
/**
* Sets the URI reference to an authentication context declaration.
*
- * @param newAuthnContextDeclRef the new AuthnContextDeclRef URI
+ * @param uri the new AuthnContextDeclRef URI
+ */
+ void setURI(@Nullable final String uri);
+
+ /**
+ * Gets the URI reference to an authentication context declaration.
+ *
+ * @return authentication context declaration reference URI
+ *
+ * @deprecated
*/
- public void setAuthnContextDeclRef(String newAuthnContextDeclRef);
-}
+ @Nullable default String getAuthnContextDeclRef() {
+ return getURI();
+ }
+
+ /**
+ * Sets the URI reference to an authentication context declaration.
+ *
+ * @param uri the new AuthnContextDeclRef URI
+ *
+ * @deprecated
+ */
+ default void setAuthnContextDeclRef(@Nullable String uri) {
+ setURI(uri);
+ }
+
+}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefImpl.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefImpl.java
index 8f67526..174b8b0 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefImpl.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefImpl.java
@@ -23,17 +23,22 @@ package org.opensaml.saml.saml2.core.impl;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import org.opensaml.core.xml.AbstractXMLObject;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.saml.saml2.core.AuthnContextClassRef;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
/**
- * A concrete implementation of {@link org.opensaml.saml.saml2.core.AuthnContextClassRef}.
+ * A concrete implementation of {@link AuthnContextClassRef}.
*/
public class AuthnContextClassRefImpl extends AbstractXMLObject implements AuthnContextClassRef {
/** URI of the Authentication Context Class. */
- private String authnContextClassRef;
+ @Nullable private String authnContextClassRef;
/**
* Constructor.
@@ -42,23 +47,24 @@ public class AuthnContextClassRefImpl extends AbstractXMLObject implements Authn
* @param elementLocalName the local name of the XML element this Object represents
* @param namespacePrefix the prefix for the given namespace
*/
- protected AuthnContextClassRefImpl(final String namespaceURI, final String elementLocalName,
- final String namespacePrefix) {
+ protected AuthnContextClassRefImpl(@Nullable final String namespaceURI,
+ @Nonnull @NotEmpty final String elementLocalName, @Nullable final String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
}
/** {@inheritDoc} */
- public String getAuthnContextClassRef() {
+ @Nullable public String getURI() {
return authnContextClassRef;
}
/** {@inheritDoc} */
- public void setAuthnContextClassRef(final String newAuthnContextClassRef) {
- this.authnContextClassRef = prepareForAssignment(this.authnContextClassRef, newAuthnContextClassRef);
+ public void setURI(@Nullable final String uri) {
+ authnContextClassRef = prepareForAssignment(authnContextClassRef, uri);
}
/** {@inheritDoc} */
- public List<XMLObject> getOrderedChildren() {
+ @Nullable public List<XMLObject> getOrderedChildren() {
return null;
}
+
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefMarshaller.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefMarshaller.java
index 65ac343..0094f66 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefMarshaller.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefMarshaller.java
@@ -30,7 +30,7 @@ import org.opensaml.saml.saml2.core.AuthnContextClassRef;
import org.w3c.dom.Element;
/**
- * A thread-safe Marshaller for {@link org.opensaml.saml.saml2.core.AuthnContextClassRef}.
+ * A thread-safe Marshaller for {@link AuthnContextClassRef}.
*/
public class AuthnContextClassRefMarshaller extends AbstractSAMLObjectMarshaller {
@@ -38,6 +38,6 @@ public class AuthnContextClassRefMarshaller extends AbstractSAMLObjectMarshaller
protected void marshallElementContent(final XMLObject samlObject, final Element domElement)
throws MarshallingException {
final AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) samlObject;
- ElementSupport.appendTextContent(domElement, authnContextClassRef.getAuthnContextClassRef());
+ ElementSupport.appendTextContent(domElement, authnContextClassRef.getURI());
}
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefUnmarshaller.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefUnmarshaller.java
index 3f77b7d..580f9c6 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefUnmarshaller.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefUnmarshaller.java
@@ -26,13 +26,13 @@ import org.opensaml.saml.common.AbstractSAMLObjectUnmarshaller;
import org.opensaml.saml.saml2.core.AuthnContextClassRef;
/**
- * A thread-safe Unmarshaller for {@link org.opensaml.saml.saml2.core.AuthnContextClassRef}.
+ * A thread-safe Unmarshaller for {@link AuthnContextClassRef}.
*/
public class AuthnContextClassRefUnmarshaller extends AbstractSAMLObjectUnmarshaller {
/** {@inheritDoc} */
protected void processElementContent(final XMLObject samlObject, final String elementContent) {
final AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) samlObject;
- authnContextClassRef.setAuthnContextClassRef(elementContent);
+ authnContextClassRef.setURI(elementContent);
}
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefImpl.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefImpl.java
index 901763b..a6ec0bf 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefImpl.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefImpl.java
@@ -23,17 +23,22 @@ package org.opensaml.saml.saml2.core.impl;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import org.opensaml.core.xml.AbstractXMLObject;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.saml.saml2.core.AuthnContextDeclRef;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+
/**
- * A concrete implementation of {@link org.opensaml.saml.saml2.core.AuthnContextDeclRef}.
+ * A concrete implementation of {@link AuthnContextDeclRef}.
*/
public class AuthnContextDeclRefImpl extends AbstractXMLObject implements AuthnContextDeclRef {
/** URI of the Authentication Context Declaration. */
- private String authnContextDeclRef;
+ @Nullable private String authnContextDeclRef;
/**
* Constructor.
@@ -42,23 +47,24 @@ public class AuthnContextDeclRefImpl extends AbstractXMLObject implements AuthnC
* @param elementLocalName the local name of the XML element this Object represents
* @param namespacePrefix the prefix for the given namespace
*/
- protected AuthnContextDeclRefImpl(final String namespaceURI, final String elementLocalName,
- final String namespacePrefix) {
+ protected AuthnContextDeclRefImpl(@Nullable final String namespaceURI,
+ @Nonnull @NotEmpty final String elementLocalName, @Nullable final String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
}
/** {@inheritDoc} */
- public String getAuthnContextDeclRef() {
+ @Nullable public String getURI() {
return authnContextDeclRef;
}
/** {@inheritDoc} */
- public void setAuthnContextDeclRef(final String newAuthnContextDeclRef) {
- this.authnContextDeclRef = prepareForAssignment(this.authnContextDeclRef, newAuthnContextDeclRef);
+ public void setURI(@Nullable final String uri) {
+ authnContextDeclRef = prepareForAssignment(authnContextDeclRef, uri);
}
/** {@inheritDoc} */
- public List<XMLObject> getOrderedChildren() {
+ @Nullable public List<XMLObject> getOrderedChildren() {
return null;
}
+
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefMarshaller.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefMarshaller.java
index c0201de..72831e5 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefMarshaller.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefMarshaller.java
@@ -30,7 +30,7 @@ import org.opensaml.saml.saml2.core.AuthnContextDeclRef;
import org.w3c.dom.Element;
/**
- * A thread-safe Marshaller for {@link org.opensaml.saml.saml2.core.AuthnContextDeclRef}.
+ * A thread-safe Marshaller for {@link AuthnContextDeclRef}.
*/
public class AuthnContextDeclRefMarshaller extends AbstractSAMLObjectMarshaller {
@@ -38,6 +38,6 @@ public class AuthnContextDeclRefMarshaller extends AbstractSAMLObjectMarshaller
protected void marshallElementContent(final XMLObject samlObject, final Element domElement)
throws MarshallingException {
final AuthnContextDeclRef authnContextDeclRef = (AuthnContextDeclRef) samlObject;
- ElementSupport.appendTextContent(domElement, authnContextDeclRef.getAuthnContextDeclRef());
+ ElementSupport.appendTextContent(domElement, authnContextDeclRef.getURI());
}
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefUnmarshaller.java b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefUnmarshaller.java
index 256e9f4..d81655b 100644
--- a/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefUnmarshaller.java
+++ b/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefUnmarshaller.java
@@ -26,13 +26,13 @@ import org.opensaml.saml.common.AbstractSAMLObjectUnmarshaller;
import org.opensaml.saml.saml2.core.AuthnContextDeclRef;
/**
- * A thread-safe Unmarshaller for {@link org.opensaml.saml.saml2.core.AuthnContextDecl}.
+ * A thread-safe Unmarshaller for {@link AuthnContextDeclRef}.
*/
public class AuthnContextDeclRefUnmarshaller extends AbstractSAMLObjectUnmarshaller {
/** {@inheritDoc} */
protected void processElementContent(final XMLObject samlObject, final String elementContent) {
final AuthnContextDeclRef authnContextDeclRef = (AuthnContextDeclRef) samlObject;
- authnContextDeclRef.setAuthnContextDeclRef(elementContent);
+ authnContextDeclRef.setURI(elementContent);
}
}
\ No newline at end of file
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/AuthnRequestTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/AuthnRequestTest.java
index bcdf48c..c3b1792 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/AuthnRequestTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/AuthnRequestTest.java
@@ -61,20 +61,20 @@ public class AuthnRequestTest extends BaseComplexSAMLObjectTestCase {
Assert.assertEquals(request.getVersion().toString(), SAMLVersion.VERSION_20.toString(), "Version");
Assert.assertEquals(request.getIssueInstant(), Instant.parse("2005-01-31T12:00:00.000Z"), "IssueInstant");
Assert.assertEquals(request.getDestination(), "http://www.example.com/", "Destination");
- Assert.assertEquals(request.getConsent(), "urn:oasis:names:tc:SAML:2.0:consent:obtained", "Consent");
- Assert.assertEquals(request.getSubject().getNameID().getFormat(), "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", "Subject/NameID/@NameIdFormat");
+ Assert.assertEquals(request.getConsent(), RequestAbstractType.OBTAINED_CONSENT, "Consent");
+ Assert.assertEquals(request.getSubject().getNameID().getFormat(), NameIDType.EMAIL, "Subject/NameID/@NameIdFormat");
Assert.assertEquals(request.getSubject().getNameID().getValue(), "j.doe at company.com", "Subject/NameID contents");
Audience audience = request.getConditions().getAudienceRestrictions().get(0).getAudiences().get(0);
Assert.assertEquals(audience.getAudienceURI(), "urn:foo:sp.example.org", "Conditions/AudienceRestriction[1]/Audience[1] contents");
AuthnContextClassRef classRef = request.getRequestedAuthnContext().getAuthnContextClassRefs().get(0);
- Assert.assertEquals(classRef.getAuthnContextClassRef(), "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", "RequestedAuthnContext/AuthnContextClassRef[1] contents");
+ Assert.assertEquals(classRef.getURI(), AuthnContext.PPT_AUTHN_CTX, "RequestedAuthnContext/AuthnContextClassRef[1] contents");
}
/** {@inheritDoc} */
@Test
public void testMarshall() {
NameID nameid = (NameID) buildXMLObject(NameID.DEFAULT_ELEMENT_NAME);
- nameid.setFormat("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress");
+ nameid.setFormat(NameIDType.EMAIL);
nameid.setValue("j.doe at company.com");
Subject subject = (Subject) buildXMLObject(Subject.DEFAULT_ELEMENT_NAME);
@@ -90,7 +90,7 @@ public class AuthnRequestTest extends BaseComplexSAMLObjectTestCase {
conditions.getAudienceRestrictions().add(ar);
AuthnContextClassRef classRef = (AuthnContextClassRef) buildXMLObject(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
- classRef.setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
+ classRef.setURI(AuthnContext.PPT_AUTHN_CTX);
RequestedAuthnContext rac = (RequestedAuthnContext) buildXMLObject(RequestedAuthnContext.DEFAULT_ELEMENT_NAME);
rac.getAuthnContextClassRefs().add(classRef);
@@ -108,7 +108,7 @@ public class AuthnRequestTest extends BaseComplexSAMLObjectTestCase {
request.setVersion(SAMLVersion.VERSION_20);
request.setIssueInstant(Instant.parse("2005-01-31T12:00:00.000Z"));
request.setDestination("http://www.example.com/");
- request.setConsent("urn:oasis:names:tc:SAML:2.0:consent:obtained");
+ request.setConsent(RequestAbstractType.OBTAINED_CONSENT);
assertXMLEquals("Marshalled AuthnRequest", expectedDOM, request);
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/ResponseSuccessAuthnAttribTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/ResponseSuccessAuthnAttribTest.java
index b91310a..0694d28 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/ResponseSuccessAuthnAttribTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/ResponseSuccessAuthnAttribTest.java
@@ -66,19 +66,19 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
Assert.assertEquals(response.getInResponseTo(), "_abcdef123456", "InResponseTo");
Assert.assertEquals(response.getVersion().toString(), SAMLVersion.VERSION_20.toString(), "Version");
Assert.assertEquals(response.getIssueInstant(), Instant.parse("2006-01-26T13:35:05.000Z"), "IssueInstant");
- Assert.assertEquals(response.getIssuer().getFormat(), "urn:oasis:names:tc:SAML:2.0:nameid-format:entity", "Issuer/@Format");
- Assert.assertEquals(response.getStatus().getStatusCode().getValue(), "urn:oasis:names:tc:SAML:2.0:status:Success", "Status/Statuscode/@Value");
+ Assert.assertEquals(response.getIssuer().getFormat(), NameIDType.ENTITY, "Issuer/@Format");
+ Assert.assertEquals(response.getStatus().getStatusCode().getValue(), StatusCode.SUCCESS, "Status/Statuscode/@Value");
Assertion assertion = response.getAssertions().get(0);
Assert.assertNotNull(assertion, "Assertion[0] was null");
Assert.assertEquals(assertion.getID(), "_a75adf55-01d7-40cc-929f-dbd8372ebdfc", "Assertion ID");
Assert.assertEquals(assertion.getIssueInstant(), Instant.parse("2006-01-26T13:35:05.000Z"), "Assertion/@IssueInstant");
Assert.assertEquals(assertion.getVersion().toString(), SAMLVersion.VERSION_20.toString(), "Assertion/@Version");
- Assert.assertEquals(assertion.getIssuer().getFormat(), "urn:oasis:names:tc:SAML:2.0:nameid-format:entity", "Assertion/Issuer/@Format");
- Assert.assertEquals(assertion.getSubject().getNameID().getFormat(), "urn:oasis:names:tc:SAML:2.0:nameid-format:transient", "Assertion/Subject/NameID/@Format");
+ Assert.assertEquals(assertion.getIssuer().getFormat(), NameIDType.ENTITY, "Assertion/Issuer/@Format");
+ Assert.assertEquals(assertion.getSubject().getNameID().getFormat(), NameIDType.TRANSIENT, "Assertion/Subject/NameID/@Format");
Assert.assertEquals(assertion.getSubject().getNameID().getValue(), "_820d2843-2342-8236-ad28-8ac94fb3e6a1", "Assertion/Subject/NameID contents");
SubjectConfirmation sc = assertion.getSubject().getSubjectConfirmations().get(0);
- Assert.assertEquals(sc.getMethod(), "urn:oasis:names:tc:SAML:2.0:cm:bearer", "Assertion/Subject/SubjectConfirmation/@Method");
+ Assert.assertEquals(sc.getMethod(), SubjectConfirmation.METHOD_BEARER, "Assertion/Subject/SubjectConfirmation/@Method");
Assert.assertEquals(assertion.getConditions().getNotBefore(), Instant.parse("2006-01-26T13:35:05.000Z"), "Assertion/Condition/@NotBefore");
Assert.assertEquals(assertion.getConditions().getNotOnOrAfter(), Instant.parse("2006-01-26T13:45:05.000Z"), "Assertion/Condition/@NotOnOrAfter");
Audience audience = assertion.getConditions().getAudienceRestrictions().get(0).getAudiences().get(0);
@@ -86,7 +86,7 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
AuthnStatement authnStatement = assertion.getAuthnStatements().get(0);
Assert.assertEquals(authnStatement.getAuthnInstant(), Instant.parse("2006-01-26T13:35:05.000Z"), "Assertion/AuthnStatement/@AuthnInstant");
- Assert.assertEquals(authnStatement.getAuthnContext().getAuthnContextClassRef().getAuthnContextClassRef(), "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport", "Assertion/AuthnStatement/AuthnContext/AuthnContextClassRef contents");
+ Assert.assertEquals(authnStatement.getAuthnContext().getAuthnContextClassRef().getURI(), AuthnContext.PPT_AUTHN_CTX, "Assertion/AuthnStatement/AuthnContext/AuthnContextClassRef contents");
AttributeStatement attribStatement = assertion.getAttributeStatements().get(0);
Attribute attrib = null;
@@ -95,7 +95,7 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
attrib = attribStatement.getAttributes().get(0);
Assert.assertEquals(attrib.getFriendlyName(), "fooAttrib", "Attribute/@FriendlyName");
Assert.assertEquals(attrib.getName(), "urn:foo:attrib", "Attribute/@Name");
- Assert.assertEquals(attrib.getNameFormat(), "urn:oasis:names:tc:SAML:2.0:attrname-format:uri", "Attribute/@NameFormat");
+ Assert.assertEquals(attrib.getNameFormat(), Attribute.URI_REFERENCE, "Attribute/@NameFormat");
Assert.assertEquals(attrib.getAttributeValues().size(), 2, "Number of fooAttrib AttributeValues");
value = (XSString) attrib.getAttributeValues().get(0);
Assert.assertEquals(value.getValue(), "SomeValue", "Attribute content");
@@ -105,7 +105,7 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
attrib = attribStatement.getAttributes().get(1);
Assert.assertEquals(attrib.getFriendlyName(), "eduPersonPrincipalName", "Attribute/@FriendlyName");
Assert.assertEquals(attrib.getName(), "urn:oid:1.3.6.1.4.1.5923.1.1.1.6", "Attribute/@Name");
- Assert.assertEquals(attrib.getNameFormat(), "urn:oasis:names:tc:SAML:2.0:attrname-format:uri", "Attribute/@NameFormat");
+ Assert.assertEquals(attrib.getNameFormat(), Attribute.URI_REFERENCE, "Attribute/@NameFormat");
Assert.assertEquals(attrib.getAttributeValues().size(), 1, "Number of ldapAttrib AttributeValues");
value = (XSString) attrib.getAttributeValues().get(0);
Assert.assertEquals(value.getValue(), "j.doe at idp.example.org", "Attribute content");
@@ -120,28 +120,28 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
response.setIssueInstant(Instant.parse("2006-01-26T13:35:05.000Z"));
Issuer rIssuer = (Issuer) buildXMLObject(Issuer.DEFAULT_ELEMENT_NAME);
- rIssuer.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:entity");
+ rIssuer.setFormat(NameIDType.ENTITY);
rIssuer.setValue("https://idp.example.org");
Status status = (Status) buildXMLObject(Status.DEFAULT_ELEMENT_NAME);
StatusCode statusCode = (StatusCode) buildXMLObject(StatusCode.DEFAULT_ELEMENT_NAME);
- statusCode.setValue("urn:oasis:names:tc:SAML:2.0:status:Success");
+ statusCode.setValue(StatusCode.SUCCESS);
Assertion assertion = (Assertion) buildXMLObject(Assertion.DEFAULT_ELEMENT_NAME);
assertion.setID("_a75adf55-01d7-40cc-929f-dbd8372ebdfc");
assertion.setIssueInstant(Instant.parse("2006-01-26T13:35:05.000Z"));
Issuer aIssuer = (Issuer) buildXMLObject(Issuer.DEFAULT_ELEMENT_NAME);
- aIssuer.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:entity");
+ aIssuer.setFormat(NameIDType.ENTITY);
aIssuer.setValue("https://idp.example.org");
Subject subject = (Subject) buildXMLObject(Subject.DEFAULT_ELEMENT_NAME);
NameID nameID = (NameID) buildXMLObject(NameID.DEFAULT_ELEMENT_NAME);
- nameID.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:transient");
+ nameID.setFormat(NameIDType.TRANSIENT);
nameID.setValue("_820d2843-2342-8236-ad28-8ac94fb3e6a1");
SubjectConfirmation subjectConfirmation = (SubjectConfirmation) buildXMLObject(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
- subjectConfirmation.setMethod("urn:oasis:names:tc:SAML:2.0:cm:bearer");
+ subjectConfirmation.setMethod(SubjectConfirmation.METHOD_BEARER);
Conditions conditions = (Conditions) buildXMLObject(Conditions.DEFAULT_ELEMENT_NAME);
conditions.setNotBefore(Instant.parse("2006-01-26T13:35:05.000Z"));
@@ -156,7 +156,7 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
AuthnContext authnContext = (AuthnContext) buildXMLObject(AuthnContext.DEFAULT_ELEMENT_NAME);
AuthnContextClassRef classRef = (AuthnContextClassRef) buildXMLObject(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
- classRef.setAuthnContextClassRef("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport");
+ classRef.setURI(AuthnContext.PPT_AUTHN_CTX);
AttributeStatement attribStatement = (AttributeStatement) buildXMLObject(AttributeStatement.DEFAULT_ELEMENT_NAME);
XMLObjectBuilder<XSString> stringBuilder = builderFactory.getBuilderOrThrow(XSString.TYPE_NAME);
@@ -164,7 +164,7 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
Attribute fooAttrib = (Attribute) buildXMLObject(Attribute.DEFAULT_ELEMENT_NAME);
fooAttrib.setFriendlyName("fooAttrib");
fooAttrib.setName("urn:foo:attrib");
- fooAttrib.setNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:uri");
+ fooAttrib.setNameFormat(Attribute.URI_REFERENCE);
XSString fooAttribValue = null;
fooAttribValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
fooAttribValue.setValue("SomeValue");
@@ -176,7 +176,7 @@ public class ResponseSuccessAuthnAttribTest extends BaseComplexSAMLObjectTestCas
Attribute ldapAttrib = (Attribute) buildXMLObject(Attribute.DEFAULT_ELEMENT_NAME);
ldapAttrib.setFriendlyName("eduPersonPrincipalName");
ldapAttrib.setName("urn:oid:1.3.6.1.4.1.5923.1.1.1.6");
- ldapAttrib.setNameFormat("urn:oasis:names:tc:SAML:2.0:attrname-format:uri");
+ ldapAttrib.setNameFormat(Attribute.URI_REFERENCE);
XSString ldapAttribValue = stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
ldapAttribValue.setValue("j.doe at idp.example.org");
ldapAttrib.getAttributeValues().add(ldapAttribValue);
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefTest.java
index b42dbb3..c3ed018 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextClassRefTest.java
@@ -49,7 +49,7 @@ public class AuthnContextClassRefTest extends XMLObjectProviderBaseTestCase {
public void testSingleElementUnmarshall() {
AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) unmarshallElement(singleElementFile);
- String classRef = authnContextClassRef.getAuthnContextClassRef();
+ String classRef = authnContextClassRef.getURI();
Assert.assertEquals(classRef, expectedClassRef, "Class Reference was " + classRef + ", expected " + expectedClassRef);
}
@@ -65,7 +65,7 @@ public class AuthnContextClassRefTest extends XMLObjectProviderBaseTestCase {
QName qname = new QName(SAMLConstants.SAML20_NS, AuthnContextClassRef.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
AuthnContextClassRef authnContextClassRef = (AuthnContextClassRef) buildXMLObject(qname);
- authnContextClassRef.setAuthnContextClassRef(expectedClassRef);
+ authnContextClassRef.setURI(expectedClassRef);
assertXMLEquals(expectedDOM, authnContextClassRef);
}
diff --git a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefTest.java b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefTest.java
index 30de1a2..d041991 100644
--- a/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefTest.java
+++ b/opensaml-saml-impl/src/test/java/org/opensaml/saml/saml2/core/impl/AuthnContextDeclRefTest.java
@@ -49,7 +49,7 @@ public class AuthnContextDeclRefTest extends XMLObjectProviderBaseTestCase {
public void testSingleElementUnmarshall() {
AuthnContextDeclRef authnContextDeclRef = (AuthnContextDeclRef) unmarshallElement(singleElementFile);
- String declRef = authnContextDeclRef.getAuthnContextDeclRef();
+ String declRef = authnContextDeclRef.getURI();
Assert.assertEquals(declRef, expectedDeclRef, "Declartion Reference was " + declRef + ", expected " + expectedDeclRef);
}
@@ -65,7 +65,7 @@ public class AuthnContextDeclRefTest extends XMLObjectProviderBaseTestCase {
QName qname = new QName(SAMLConstants.SAML20_NS, AuthnContextDeclRef.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX);
AuthnContextDeclRef authnContextDeclRef = (AuthnContextDeclRef) buildXMLObject(qname);
- authnContextDeclRef.setAuthnContextDeclRef(expectedDeclRef);
+ authnContextDeclRef.setURI(expectedDeclRef);
assertXMLEquals(expectedDOM, authnContextDeclRef);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list