[java-identity-provider] 01/02: IDP-2069 Null handling
Rod Widdowson
rdw at steadingsoftware.com
Tue Mar 7 14:34:40 UTC 2023
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=baaa70e019d9e2c620736ef8860a14abd5452556
commit baaa70e019d9e2c620736ef8860a14abd5452556
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Fri Mar 3 11:18:16 2023 +0000
IDP-2069 Null handling
https://shibboleth.atlassian.net/browse/IDP-2069
idp-conf tests
---
...ferFileSystemApplicationContextInitializer.java | 2 +-
.../idp/test/PreferFileSystemContextLoader.java | 6 +-
...stEnvironmentApplicationContextInitializer.java | 3 +-
.../idp/test/flows/AbstractFlowTest.java | 39 +++++++-----
.../idp/test/flows/SetupForResolver.java | 2 +-
.../shibboleth/idp/test/flows/c14n/TestC14N.java | 11 +---
.../test/flows/c14n/actions/SetupForSAML1C14N.java | 5 +-
.../test/flows/c14n/actions/SetupForSAML2C14N.java | 9 ++-
.../idp/test/flows/c14n/actions/TestAfterC14N.java | 3 +-
.../idp/test/flows/cas/LoginFlowTest.java | 50 +++++++++-------
.../idp/test/flows/cas/ProxyValidateFlowTest.java | 4 +-
.../idp/test/flows/cas/SamlValidateFlowTest.java | 17 ++++--
.../test/flows/cas/ServiceValidateFlowTest.java | 52 ++++++++++------
.../idp/test/flows/cas/ValidateFlowTest.java | 8 ++-
.../idp/test/flows/exception/ThrowException.java | 6 +-
.../test/flows/interceptor/InterceptFlowTest.java | 17 ++++--
.../idp/test/flows/mapper/SpoofSAMLMessage.java | 5 +-
.../idp/test/flows/mapper/TestAfterFilter.java | 4 +-
.../test/flows/saml1/AbstractSAML1FlowTest.java | 18 +++---
.../flows/saml1/SAML1AttributeQueryFlowTest.java | 39 +++++++-----
.../flows/saml1/SAML1TestResponseValidator.java | 56 ++++++++++--------
.../test/flows/saml2/AbstractSAML2FlowTest.java | 13 ++--
.../test/flows/saml2/AbstractSAML2SSOFlowTest.java | 62 ++++++++++---------
.../flows/saml2/SAML2AttributeQueryFlowTest.java | 55 +++++++++--------
.../idp/test/flows/saml2/SAML2ECPSSOFlowTest.java | 1 +
.../idp/test/flows/saml2/SAML2POSTSSOFlowTest.java | 1 +
.../saml2/SAML2POSTSimpleSignSSOFlowTest.java | 1 +
.../test/flows/saml2/SAML2RedirectSSOFlowTest.java | 1 +
.../flows/saml2/SAML2TestResponseValidator.java | 69 +++++++++++++---------
.../SAML2TestStatusResponseTypeValidator.java | 5 +-
30 files changed, 335 insertions(+), 229 deletions(-)
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemApplicationContextInitializer.java b/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemApplicationContextInitializer.java
index 7b5c743f1..d33b2d248 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemApplicationContextInitializer.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemApplicationContextInitializer.java
@@ -20,11 +20,11 @@ package net.shibboleth.idp.test;
import javax.annotation.Nonnull;
import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.spring.resource.ConditionalResourceResolver;
import net.shibboleth.shared.spring.resource.PreferFileSystemResourceLoader;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemContextLoader.java b/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemContextLoader.java
index b285738c1..cbd21cbc6 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemContextLoader.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/PreferFileSystemContextLoader.java
@@ -17,6 +17,8 @@
package net.shibboleth.idp.test;
+import javax.annotation.Nonnull;
+
import org.springframework.test.context.web.GenericXmlWebContextLoader;
import org.springframework.test.context.web.WebMergedContextConfiguration;
import org.springframework.web.context.support.GenericWebApplicationContext;
@@ -37,8 +39,8 @@ public class PreferFileSystemContextLoader extends GenericXmlWebContextLoader {
* Set the resource loader used by the application context to {@link PreferFileSystemResourceLoader}.
* </p>
*/
- @Override protected void customizeContext(GenericWebApplicationContext context,
- WebMergedContextConfiguration webMergedConfig) {
+ @Override protected void customizeContext(@Nonnull GenericWebApplicationContext context,
+ @Nonnull WebMergedContextConfiguration webMergedConfig) {
final PreferFileSystemResourceLoader loader = new PreferFileSystemResourceLoader();
loader.addProtocolResolver(new ConditionalResourceResolver());
context.setResourceLoader(loader);
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/TestEnvironmentApplicationContextInitializer.java b/idp-conf/src/test/java/net/shibboleth/idp/test/TestEnvironmentApplicationContextInitializer.java
index 44fa18eb3..98d0a66f2 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/TestEnvironmentApplicationContextInitializer.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/TestEnvironmentApplicationContextInitializer.java
@@ -20,13 +20,14 @@ package net.shibboleth.idp.test;
import javax.annotation.Nonnull;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.mock.env.MockPropertySource;
+import net.shibboleth.shared.primitive.LoggerFactory;
+
/**
* An {@link ApplicationContextInitializer} which prepends properties.
*
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java
index 7afffce3f..2ec832a5f 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/AbstractFlowTest.java
@@ -23,16 +23,17 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensaml.core.xml.XMLObject;
+import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.XMLObjectBuilderFactory;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.io.MarshallerFactory;
import org.opensaml.core.xml.io.UnmarshallerFactory;
+import org.opensaml.messaging.context.MessageContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.security.credential.Credential;
import org.opensaml.soap.soap11.Body;
import org.opensaml.soap.soap11.Envelope;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.binding.expression.Expression;
@@ -77,6 +78,7 @@ import net.shibboleth.idp.test.PreferFileSystemContextLoader;
import net.shibboleth.idp.test.TestEnvironmentApplicationContextInitializer;
import net.shibboleth.shared.annotation.constraint.NonnullAfterInit;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.security.IdentifierGenerationStrategy;
import net.shibboleth.shared.security.IdentifierGenerationStrategy.ProviderType;
import net.shibboleth.shared.servlet.impl.HttpServletRequestResponseContext;
@@ -149,16 +151,16 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
@NonnullAfterInit private static InMemoryDirectory directoryServer;
/** Mock external context. */
- @Nonnull protected MockExternalContext externalContext;
+ protected MockExternalContext externalContext;
/** The web flow executor. */
- @Nonnull protected FlowExecutor flowExecutor;
+ protected FlowExecutor flowExecutor;
/** Mock request. */
- @Nonnull protected MockHttpServletRequest request;
+ protected MockHttpServletRequest request;
/** Mock response. */
- @Nonnull protected MockHttpServletResponse response;
+ protected MockHttpServletResponse response;
/** Parser pool */
@NonnullAfterInit protected static ParserPool parserPool;
@@ -173,7 +175,7 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
@NonnullAfterInit protected static UnmarshallerFactory unmarshallerFactory;
/** UUID identifier generation strategy. */
- @Nonnull protected IdentifierGenerationStrategy idGenerator;
+ protected IdentifierGenerationStrategy idGenerator;
/** IdP credential wired via test/test-beans.xml. */
@Qualifier("test.idp.Credential") @Autowired protected Credential idpCredential;
@@ -195,6 +197,7 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
* Initialize the web flow executor.
*/
@BeforeMethod public void initializeFlowExecutor() {
+ assert applicationContext!=null;
flowExecutor = applicationContext.getBean("flowExecutor", FlowExecutor.class);
Assert.assertNotNull(flowExecutor);
}
@@ -216,6 +219,7 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
* {@link HttpServletRequestResponseContext#loadCurrent(HttpServletRequest, HttpServletResponse)}
*/
@BeforeMethod public void initializeThreadLocals() {
+ assert request!=null && response!=null;
HttpServletRequestResponseContext.loadCurrent(request, response);
}
@@ -262,7 +266,7 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
* @param flowID the flow id
*/
public void assertFlowExecutionResult(@Nullable final FlowExecutionResult result, @Nonnull String flowID) {
- Assert.assertNotNull(result);
+ assert result!=null;
Assert.assertEquals(result.getFlowId(), flowID);
Assert.assertTrue(result.isEnded());
}
@@ -289,6 +293,7 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
public void assertFlowExecutionOutcome(@Nullable final FlowExecutionOutcome outcome,
@Nullable final String endStateId) {
Assert.assertNotNull(outcome, "Flow ended with an error");
+ assert outcome != null;
Assert.assertEquals(outcome.getId(), endStateId);
Assert.assertTrue(outcome.getOutput().contains(END_STATE_OUTPUT_ATTR_NAME));
Assert.assertTrue(outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME) instanceof ProfileRequestContext);
@@ -296,14 +301,13 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
/**
* Assert that the profile request context has an outbound message context and that the outbound message context has
- * a message.
- *
+ * a message.C *
* @param profileRequestContext the profile request context
*/
public void assertProfileRequestContext(@Nullable final ProfileRequestContext profileRequestContext) {
- Assert.assertNotNull(profileRequestContext);
- Assert.assertNotNull(profileRequestContext.getOutboundMessageContext());
- Assert.assertNotNull(profileRequestContext.getOutboundMessageContext().getMessage());
+ assert profileRequestContext!=null;
+ final MessageContext omc = profileRequestContext.getOutboundMessageContext();
+ assert omc != null && omc.getMessage() != null;
}
/**
@@ -313,11 +317,16 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
* @return the SOAP11 envelop
*/
@Nonnull public static Envelope buildSOAP11Envelope(@Nonnull final XMLObject payload) {
+ final XMLObjectBuilderFactory bf = builderFactory;
+ assert bf != null;
+ final XMLObjectBuilder<?> bfe = bf.getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
+ final XMLObjectBuilder<?> bfb = bf.getBuilder(Body.DEFAULT_ELEMENT_NAME);
+ assert bfe!=null && bfb!=null;
final Envelope envelope =
- (Envelope) builderFactory.getBuilder(Envelope.DEFAULT_ELEMENT_NAME).buildObject(
+ (Envelope) bfe.buildObject(
Envelope.DEFAULT_ELEMENT_NAME);
final Body body =
- (Body) builderFactory.getBuilder(Body.DEFAULT_ELEMENT_NAME).buildObject(Body.DEFAULT_ELEMENT_NAME);
+ (Body) bfb.buildObject(Body.DEFAULT_ELEMENT_NAME);
body.getUnknownXMLObjects().add(payload);
envelope.setBody(body);
@@ -344,7 +353,7 @@ public abstract class AbstractFlowTest extends AbstractTestNGSpringContextTests
((FlowExecutorImpl) flowExecutor).getDefinitionLocator().getFlowDefinition(flowID);
Constraint.isTrue(flowDefinition instanceof Flow, "The flow definition must be an instance of " + Flow.class);
-
+
return (Flow) flowDefinition;
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/SetupForResolver.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/SetupForResolver.java
index 9ee2783bc..cb88ee2ce 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/SetupForResolver.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/SetupForResolver.java
@@ -37,7 +37,7 @@ public class SetupForResolver extends AbstractProfileAction {
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
- final SubjectContext sc = profileRequestContext.getSubcontext(SubjectContext.class, true);
+ final SubjectContext sc = profileRequestContext.getOrCreateSubcontext(SubjectContext.class);
sc.setPrincipalName("PETER_THE_PRINCIPAL");
final RelyingPartyContext rpContext = profileRequestContext.getOrCreateSubcontext(RelyingPartyContext.class);
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/TestC14N.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/TestC14N.java
index 3a72b3275..6106a7962 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/TestC14N.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/TestC14N.java
@@ -17,25 +17,18 @@
package net.shibboleth.idp.test.flows.c14n;
-import javax.annotation.Nonnull;
-
-import net.shibboleth.idp.test.flows.AbstractFlowTest;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.webflow.executor.FlowExecutionResult;
import org.testng.annotations.Test;
+import net.shibboleth.idp.test.flows.AbstractFlowTest;
+
/**
* Tests for C14N.
*/
@ContextConfiguration({"classpath:/c14n/test-webflow-config.xml", "classpath:/c14n/locate-resolver.xml"})
public class TestC14N extends AbstractFlowTest {
- /** Class logger. */
- @Nonnull private final Logger log = LoggerFactory.getLogger(TestC14N.class);
-
@Test public void testTransientNameID() {
final FlowExecutionResult result = flowExecutor.launchExecution("transientNameID", null, externalContext);
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML1C14N.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML1C14N.java
index fc96cafe0..d5eef18f5 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML1C14N.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML1C14N.java
@@ -94,6 +94,7 @@ public class SetupForSAML1C14N extends AbstractProfileAction {
@Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
final RelyingPartyContext rpc = profileRequestContext.getSubcontext(RelyingPartyContext.class);
+ assert rpc!=null;
NameIdentifier nid = null;
@@ -105,6 +106,7 @@ public class SetupForSAML1C14N extends AbstractProfileAction {
}
} else {
final AttributeContext ac = rpc.getSubcontext(AttributeContext.class);
+ assert ac != null;
nid = encode(ac.getIdPAttributes().get(attributeName));
}
@@ -118,10 +120,11 @@ public class SetupForSAML1C14N extends AbstractProfileAction {
sub.getPrincipals().add(nidp);
final SubjectCanonicalizationContext scc =
- profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class, true);
+ profileRequestContext.getOrCreateSubcontext(SubjectCanonicalizationContext.class);
scc.setSubject(sub);
scc.setRequesterId(rpc.getRelyingPartyId());
final RelyingPartyConfiguration rpConfig = (RelyingPartyConfiguration) rpc.getConfiguration();
+ assert rpConfig!=null;
scc.setResponderId(rpConfig.getIssuer(profileRequestContext));
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML2C14N.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML2C14N.java
index eb936aa6b..08d52f61b 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML2C14N.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/SetupForSAML2C14N.java
@@ -93,6 +93,7 @@ public class SetupForSAML2C14N extends AbstractProfileAction {
@Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
final RelyingPartyContext rpc = profileRequestContext.getSubcontext(RelyingPartyContext.class);
+ assert rpc!=null;
final AttributeContext ac = rpc.getSubcontext(AttributeContext.class);
NameID nid = null;
@@ -104,7 +105,10 @@ public class SetupForSAML2C14N extends AbstractProfileAction {
}
} else {
- nid = encode(ac.getIdPAttributes().get(attributeName));
+ assert ac != null;
+ final IdPAttribute attr = ac.getIdPAttributes().get(attributeName);
+ assert attr!=null;
+ nid = encode(attr);
}
if (nid == null) {
@@ -117,10 +121,11 @@ public class SetupForSAML2C14N extends AbstractProfileAction {
sub.getPrincipals().add(nidp);
final SubjectCanonicalizationContext scc =
- profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class, true);
+ profileRequestContext.getOrCreateSubcontext(SubjectCanonicalizationContext.class);
scc.setSubject(sub);
scc.setRequesterId(rpc.getRelyingPartyId());
final RelyingPartyConfiguration rpConfig = (RelyingPartyConfiguration) rpc.getConfiguration();
+ assert rpConfig!=null;
scc.setResponderId(rpConfig.getIssuer(profileRequestContext));
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/TestAfterC14N.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/TestAfterC14N.java
index 954922071..f17dbc158 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/TestAfterC14N.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/c14n/actions/TestAfterC14N.java
@@ -36,7 +36,8 @@ public class TestAfterC14N extends AbstractProfileAction {
@Nonnull final ProfileRequestContext profileRequestContext) {
SubjectCanonicalizationContext scc = profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class, false);
- SubjectContext sc = profileRequestContext.getSubcontext(SubjectContext.class, true);
+ assert scc != null;
+ SubjectContext sc = profileRequestContext.getOrCreateSubcontext(SubjectContext.class);
Assert.assertEquals(sc.getPrincipalName(), scc.getPrincipalName());
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java
index 79ac4eaf0..b53d96611 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/LoginFlowTest.java
@@ -154,11 +154,13 @@ public class LoginFlowTest extends AbstractFlowTest {
assertEquals(outcome.getId(), "RedirectToService");
final String ticketId = getTicketIdFromUrl(externalContext.getExternalRedirectUrl());
final Ticket st = ticketService.removeServiceTicket(ticketId);
- assertNotNull(st);
+ assert st!=null;
+ final String sid = st.getSessionId();
+ assert sid!=null;
final IdPSession session = sessionManager.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(st.getSessionId())));
- assertNotNull(session);
-
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert session!=null;
+
final ProfileRequestContext prc = (ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME);
assertNotNull(prc.getSubcontext(SubjectContext.class));
assertPopulatedAttributeContext(prc);
@@ -183,11 +185,13 @@ public class LoginFlowTest extends AbstractFlowTest {
assertEquals(1, matcher.groupCount());
final String ticketId = matcher.group(1);
final Ticket st = ticketService.removeServiceTicket(ticketId);
- assertNotNull(st);
+ assert st!=null;
+ final String sid = st.getSessionId();
+ assert sid!=null;
final IdPSession session = sessionManager.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(st.getSessionId())));
- assertNotNull(session);
-
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert session!=null;
+
final ProfileRequestContext prc = (ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME);
assertNotNull(prc.getSubcontext(SubjectContext.class));
assertPopulatedAttributeContext(prc);
@@ -206,11 +210,13 @@ public class LoginFlowTest extends AbstractFlowTest {
assertEquals(result.getOutcome().getId(), "RedirectToService");
final String ticketId = getTicketIdFromUrl(externalContext.getExternalRedirectUrl());
final Ticket st = ticketService.removeServiceTicket(ticketId);
- assertNotNull(st);
+ assert st!=null;
+ final String sid = st.getSessionId();
+ assert sid!=null;
final IdPSession session = sessionManager.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(st.getSessionId())));
- assertNotNull(session);
-
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert session!=null;
+
// Ensure we passed through the consent intercept subflow
final ProfileRequestContext prc = (ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME);
assertNotNull(prc);
@@ -233,10 +239,12 @@ public class LoginFlowTest extends AbstractFlowTest {
assertEquals(outcome.getId(), "RedirectToService");
final String ticketId = getTicketIdFromUrl(externalContext.getExternalRedirectUrl());
final Ticket st = ticketService.removeServiceTicket(ticketId);
- assertNotNull(st);
+ assert st!=null;
+ final String sid = st.getSessionId();
+ assert sid!=null;
final IdPSession session = sessionManager.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(st.getSessionId())));
- assertNotNull(session);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert session!=null;
assertEquals(session.getId(), existing.getId());
final ProfileRequestContext prc = (ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME);
@@ -258,10 +266,12 @@ public class LoginFlowTest extends AbstractFlowTest {
assertEquals(outcome.getId(), "RedirectToService");
final String ticketId = getTicketIdFromUrl(externalContext.getExternalRedirectUrl());
final Ticket st = ticketService.removeServiceTicket(ticketId);
- assertNotNull(st);
+ assert st!=null;
+ final String sid = st.getSessionId();
+ assert sid!=null;
final IdPSession session = sessionManager.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(st.getSessionId())));
- assertNotNull(session);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert session!=null;
// Expect a new session to be created since authentication was required
assertNotEquals(session.getId(), existing.getId());
@@ -301,9 +311,9 @@ public class LoginFlowTest extends AbstractFlowTest {
private void assertPopulatedAttributeContext(final ProfileRequestContext prc) {
assertNotNull(prc);
final RelyingPartyContext rpc = prc.getSubcontext(RelyingPartyContext.class, false);
- assertNotNull(rpc);
+ assert rpc!=null;
final AttributeContext ac= rpc.getSubcontext(AttributeContext.class, false);
- assertNotNull(ac);
+ assert ac!=null;
assertFalse(ac.getUnfilteredIdPAttributes().isEmpty());
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java
index f383865fb..ed320ecf0 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ProxyValidateFlowTest.java
@@ -145,11 +145,13 @@ public class ProxyValidateFlowTest extends AbstractFlowTest {
final String principal = "john";
final int pgtTTLMillis = 20;
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket st = ticketService.createServiceTicket(
new TicketIdentifierGenerationStrategy("ST", 25).generateIdentifier(),
Instant.now().plusSeconds(5),
"https://service.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
final ProxyGrantingTicket pgt1 = ticketService.createProxyGrantingTicket(
new TicketIdentifierGenerationStrategy("PGT", 50).generateIdentifier(),
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/SamlValidateFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/SamlValidateFlowTest.java
index 29ddc7f27..cab85beca 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/SamlValidateFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/SamlValidateFlowTest.java
@@ -76,11 +76,13 @@ public class SamlValidateFlowTest extends AbstractFlowTest {
public void testSuccess() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://test.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
final String requestBody = SAML_REQUEST_TEMPLATE.replace("@@TICKET@@", ticket.getId());
request.setMethod("POST");
@@ -107,7 +109,9 @@ public class SamlValidateFlowTest extends AbstractFlowTest {
public void testSuccessWithConsent() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
- final TicketState state = new TicketState(session.getId(), principal, Instant.now(), "Password");
+ final String sid = session.getId();
+ assert sid!=null;
+ final TicketState state = new TicketState(sid, principal, Instant.now(), "Password");
state.setConsentedAttributeIds(CollectionSupport.setOf("uid", "eduPersonPrincipalName"));
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
@@ -156,11 +160,14 @@ public class SamlValidateFlowTest extends AbstractFlowTest {
public void testSuccessWhenResolveAttributesFalse() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
+
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-2718281828-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://no-attrs.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
final String requestBody = SAML_REQUEST_TEMPLATE.replace("@@TICKET@@", ticket.getId());
request.setMethod("POST");
@@ -186,9 +193,9 @@ public class SamlValidateFlowTest extends AbstractFlowTest {
private void assertPopulatedAttributeContext(final ProfileRequestContext prc) {
assertNotNull(prc);
final RelyingPartyContext rpc = prc.getSubcontext(RelyingPartyContext.class, false);
- assertNotNull(rpc);
+ assert rpc!=null;;
final AttributeContext ac= rpc.getSubcontext(AttributeContext.class, false);
- assertNotNull(ac);
+ assert ac!=null;
assertFalse(ac.getUnfilteredIdPAttributes().isEmpty());
}
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java
index ef12142e6..24495c714 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ServiceValidateFlowTest.java
@@ -107,7 +107,9 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
public void testSuccess() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
- final TicketState state = new TicketState(session.getId(), principal, Instant.now(), "Password");
+ final String sid = session.getId();
+ assert sid!=null;
+ final TicketState state = new TicketState(sid, principal, Instant.now(), "Password");
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
@@ -135,8 +137,8 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
assertPopulatedAttributeContext((ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME));
final IdPSession updatedSession = sessionResolver.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(session.getId())));
- assertNotNull(updatedSession);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert updatedSession!=null;
assertEquals(updatedSession.getSPSessions().size(), 0);
}
@@ -144,7 +146,9 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
public void testSuccessWithConsent() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
- final TicketState state = new TicketState(session.getId(), principal, Instant.now(), "Password");
+ final String sid = session.getId();
+ assert sid!=null;
+ final TicketState state = new TicketState(sid, principal, Instant.now(), "Password");
state.setConsentedAttributeIds(CollectionSupport.setOf("uid", "eduPersonPrincipalName"));
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
@@ -173,8 +177,8 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
assertPopulatedAttributeContext((ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME));
final IdPSession updatedSession = sessionResolver.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(session.getId())));
- assertNotNull(updatedSession);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert updatedSession!=null;
assertEquals(updatedSession.getSPSessions().size(), 0);
}
@@ -182,11 +186,13 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
public void testSuccessWithSLOParticipant() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://slo.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
externalContext.getMockRequestParameterMap().put("service", ticket.getService());
@@ -205,8 +211,8 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
assertPopulatedAttributeContext((ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME));
final IdPSession updatedSession = sessionResolver.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(session.getId())));
- assertNotNull(updatedSession);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert updatedSession!=null;
assertEquals(updatedSession.getSPSessions().size(), 1);
}
@@ -227,11 +233,13 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
public void testSuccessWithProxy() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://test.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
externalContext.getMockRequestParameterMap().put("service", ticket.getService());
@@ -257,11 +265,13 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
public void testProxyCallbackAuthnFailure() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://test.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
externalContext.getMockRequestParameterMap().put("service", ticket.getService());
@@ -283,11 +293,13 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
public void testSuccessWithAltUsername() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-pnqph79ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://alt-username.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
externalContext.getMockRequestParameterMap().put("service", ticket.getService());
@@ -306,8 +318,8 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
assertPopulatedAttributeContext((ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME));
final IdPSession updatedSession = sessionResolver.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(session.getId())));
- assertNotNull(updatedSession);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert updatedSession!=null;
assertEquals(updatedSession.getSPSessions().size(), 0);
}
@@ -315,11 +327,13 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
public void testSuccessNoAttributes() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-2718281828-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://no-attrs.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
externalContext.getMockRequestParameterMap().put("service", ticket.getService());
@@ -341,8 +355,8 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
assertFalse(responseBody.contains("<cas:proxies>"));
final IdPSession updatedSession = sessionResolver.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(session.getId())));
- assertNotNull(updatedSession);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert updatedSession!=null;
assertEquals(updatedSession.getSPSessions().size(), 0);
}
@@ -350,9 +364,9 @@ public class ServiceValidateFlowTest extends AbstractFlowTest {
private void assertPopulatedAttributeContext(final ProfileRequestContext prc) {
assertNotNull(prc);
final RelyingPartyContext rpc = prc.getSubcontext(RelyingPartyContext.class, false);
- assertNotNull(rpc);
+ assert rpc != null;
final AttributeContext ac= rpc.getSubcontext(AttributeContext.class, false);
- assertNotNull(ac);
+ assert ac!=null;
assertFalse(ac.getUnfilteredIdPAttributes().isEmpty());
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ValidateFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ValidateFlowTest.java
index da82fa483..7488a5de6 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ValidateFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/cas/ValidateFlowTest.java
@@ -69,11 +69,13 @@ public class ValidateFlowTest extends AbstractFlowTest {
public void testSuccess() throws Exception {
final String principal = "john";
final IdPSession session = sessionManager.createSession(principal);
+ final String sid = session.getId();
+ assert sid!=null;
final ServiceTicket ticket = ticketService.createServiceTicket(
"ST-1415133132-ompog68ygxKyX9BPwPuw0hESQBjuA",
Instant.now().plusSeconds(5),
"https://test.example.org/",
- new TicketState(session.getId(), principal, Instant.now(), "Password"),
+ new TicketState(sid, principal, Instant.now(), "Password"),
false);
externalContext.getMockRequestParameterMap().put("service", ticket.getService());
@@ -89,8 +91,8 @@ public class ValidateFlowTest extends AbstractFlowTest {
assertEquals("text/plain;charset=utf-8", response.getContentType());
final IdPSession updatedSession = sessionResolver.resolveSingle(
- new CriteriaSet(new SessionIdCriterion(session.getId())));
- assertNotNull(updatedSession);
+ new CriteriaSet(new SessionIdCriterion(sid)));
+ assert updatedSession!=null;
assertEquals(updatedSession.getSPSessions().size(), 0);
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/exception/ThrowException.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/exception/ThrowException.java
index ca6071089..72ffa607e 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/exception/ThrowException.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/exception/ThrowException.java
@@ -24,6 +24,7 @@ import net.shibboleth.idp.profile.context.SpringRequestContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.webflow.execution.RequestContext;
/**
* Test action that throws exception.
@@ -46,8 +47,11 @@ public class ThrowException extends AbstractProfileAction {
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
if (commitResponse) {
final SpringRequestContext springContext = profileRequestContext.getSubcontext(SpringRequestContext.class);
+ assert springContext!=null;
+ final RequestContext requestContext = springContext.getRequestContext();
+ assert requestContext != null;
final MockHttpServletResponse response =
- (MockHttpServletResponse) springContext.getRequestContext().getExternalContext().getNativeResponse();
+ (MockHttpServletResponse) requestContext.getExternalContext().getNativeResponse();
response.setOutputStreamAccessAllowed(false);
response.setWriterAccessAllowed(false);
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/interceptor/InterceptFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/interceptor/InterceptFlowTest.java
index c0aa50322..60f5c9664 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/interceptor/InterceptFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/interceptor/InterceptFlowTest.java
@@ -28,7 +28,7 @@ import net.shibboleth.idp.test.flows.AbstractFlowTest;
import org.opensaml.profile.action.EventIds;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import net.shibboleth.shared.primitive.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.executor.FlowExecutionResult;
@@ -100,9 +100,10 @@ public class InterceptFlowTest extends AbstractFlowTest {
assertFlowExecutionOutcome(result.getOutcome());
final ProfileRequestContext prc = retrieveProfileRequestContext(result);
- Assert.assertNotNull(prc);
+ assert prc!=null;
final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+ assert interceptorCtx!=null;
Assert.assertTrue(interceptorCtx.getAvailableFlows().isEmpty());
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed1"), false);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed2"), false);
@@ -120,9 +121,10 @@ public class InterceptFlowTest extends AbstractFlowTest {
assertFlowExecutionOutcome(result.getOutcome());
final ProfileRequestContext prc = retrieveProfileRequestContext(result);
- Assert.assertNotNull(prc);
+ assert prc!=null;
final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+ assert interceptorCtx!=null;
Assert.assertEquals(interceptorCtx.getAvailableFlows().size(), 0);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed1"), true);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed2"), false);
@@ -141,9 +143,10 @@ public class InterceptFlowTest extends AbstractFlowTest {
assertFlowExecutionOutcome(result.getOutcome());
final ProfileRequestContext prc = retrieveProfileRequestContext(result);
- Assert.assertNotNull(prc);
+ assert prc!=null;
final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+ assert interceptorCtx!=null;
Assert.assertEquals(interceptorCtx.getAvailableFlows().size(), 0);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed1"), true);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed2"), true);
@@ -161,9 +164,10 @@ public class InterceptFlowTest extends AbstractFlowTest {
assertFlowExecutionOutcome(result.getOutcome(), EventIds.INVALID_PROFILE_CTX);
final ProfileRequestContext prc = retrieveProfileRequestContext(result);
- Assert.assertNotNull(prc);
+ assert prc!=null;
final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+ assert interceptorCtx!=null;
Assert.assertEquals(interceptorCtx.getAvailableFlows().size(), 1);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed1"), false);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed2"), false);
@@ -182,9 +186,10 @@ public class InterceptFlowTest extends AbstractFlowTest {
assertFlowExecutionOutcome(result.getOutcome(), EventIds.INVALID_PROFILE_CTX);
final ProfileRequestContext prc = retrieveProfileRequestContext(result);
- Assert.assertNotNull(prc);
+ assert prc!=null;
final ProfileInterceptorContext interceptorCtx = prc.getSubcontext(ProfileInterceptorContext.class);
+ assert interceptorCtx!=null;
Assert.assertEquals(interceptorCtx.getAvailableFlows().size(), 1);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed1"), true);
Assert.assertEquals(result.getOutcome().getOutput().get("testProceed2"), false);
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/SpoofSAMLMessage.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/SpoofSAMLMessage.java
index 56943c528..fa46a9cd8 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/SpoofSAMLMessage.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/SpoofSAMLMessage.java
@@ -36,11 +36,10 @@ public class SpoofSAMLMessage extends AbstractProfileAction {
final MessageContext mc = new MessageContext();
profileRequestContext.setInboundMessageContext(mc);
- SAMLPeerEntityContext spec = mc.getSubcontext(SAMLPeerEntityContext.class, true);
-
+ SAMLPeerEntityContext spec = mc.getOrCreateSubcontext(SAMLPeerEntityContext.class);
spec.setEntityId("https://sp.example.org");
spec.setRole(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
- mc.getSubcontext(SAMLProtocolContext.class, true).setProtocol(SAMLConstants.SAML20P_NS);
+ mc.getOrCreateSubcontext(SAMLProtocolContext.class).setProtocol(SAMLConstants.SAML20P_NS);
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/TestAfterFilter.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/TestAfterFilter.java
index 2c0a009f0..09a92d5e4 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/TestAfterFilter.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/mapper/TestAfterFilter.java
@@ -36,9 +36,9 @@ public class TestAfterFilter extends AbstractProfileAction {
@Nonnull final ProfileRequestContext profileRequestContext) {
final RelyingPartyContext rpc = profileRequestContext.getSubcontext(RelyingPartyContext.class);
-
+ assert rpc!=null;
final AttributeContext ac = rpc.getSubcontext(AttributeContext.class);
-
+ assert ac!=null;
Assert.assertNull(ac.getIdPAttributes().get("IdPNotOK"));
Assert.assertNull(ac.getIdPAttributes().get("IdPEA1"));
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/AbstractSAML1FlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/AbstractSAML1FlowTest.java
index 659e6c627..f897fde5b 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/AbstractSAML1FlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/AbstractSAML1FlowTest.java
@@ -18,16 +18,16 @@
package net.shibboleth.idp.test.flows.saml1;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import net.shibboleth.idp.test.flows.AbstractFlowTest;
+import org.opensaml.messaging.context.MessageContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.saml.saml1.core.Response;
import org.springframework.webflow.execution.FlowExecutionOutcome;
import org.springframework.webflow.executor.FlowExecutionResult;
import org.testng.Assert;
+import net.shibboleth.idp.test.flows.AbstractFlowTest;
+
/**
* Abstract SAML 1 flow test.
*/
@@ -39,7 +39,7 @@ public abstract class AbstractSAML1FlowTest extends AbstractFlowTest {
* @param result the flow execution result
* @param flowId the flow ID
*/
- public void validateResult(@Nullable final FlowExecutionResult result, @Nonnull final String flowId) {
+ public void validateResult(@Nonnull final FlowExecutionResult result, @Nonnull final String flowId) {
validateResult(result, flowId, new SAML1TestResponseValidator());
}
@@ -50,7 +50,7 @@ public abstract class AbstractSAML1FlowTest extends AbstractFlowTest {
* @param flowId the flow ID
* @param validator the response validator
*/
- public void validateResult(@Nullable final FlowExecutionResult result, @Nonnull final String flowId,
+ public void validateResult(@Nonnull final FlowExecutionResult result, @Nonnull final String flowId,
@Nonnull final SAML1TestResponseValidator validator) {
assertFlowExecutionResult(result, flowId);
validator.validateResponse(getResponse(result));
@@ -62,14 +62,16 @@ public abstract class AbstractSAML1FlowTest extends AbstractFlowTest {
* @param result the flow result
* @return the SAML response
*/
- public Response getResponse(@Nullable final FlowExecutionResult result) {
+ public Response getResponse(@Nonnull FlowExecutionResult result) {
final FlowExecutionOutcome outcome = result.getOutcome();
assertFlowExecutionOutcome(outcome);
final ProfileRequestContext prc = (ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME);
assertProfileRequestContext(prc);
- Assert.assertTrue(prc.getOutboundMessageContext().getMessage() instanceof Response);
+ final MessageContext omc = prc.getOutboundMessageContext();
+ assert omc!=null;
+ Assert.assertTrue(omc.getMessage() instanceof Response);
- return (Response) prc.getOutboundMessageContext().getMessage();
+ return (Response) omc.getMessage();
}
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1AttributeQueryFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1AttributeQueryFlowTest.java
index 0263a64ff..b88163213 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1AttributeQueryFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1AttributeQueryFlowTest.java
@@ -29,6 +29,7 @@ import net.shibboleth.shared.security.IdentifierGenerationStrategy.ProviderType;
import net.shibboleth.shared.xml.SerializeSupport;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
+import org.opensaml.core.xml.io.Marshaller;
import org.opensaml.saml.common.SAMLObjectBuilder;
import org.opensaml.saml.saml1.core.AttributeDesignator;
import org.opensaml.saml.saml1.core.ConfirmationMethod;
@@ -66,10 +67,10 @@ public class SAML1AttributeQueryFlowTest extends AbstractSAML1FlowTest {
nameIdentifier.setFormat(null);
nameIdentifier.setNameQualifier(null);
- validator = new SAML1TestResponseValidator();
- validator.validateAuthenticationStatements = false;
- validator.nameIdentifier = nameIdentifier;
- validator.confirmationMethod = ConfirmationMethod.METHOD_SENDER_VOUCHES;
+ final SAML1TestResponseValidator val = validator = new SAML1TestResponseValidator();
+ val.validateAuthenticationStatements = false;
+ val.nameIdentifier = nameIdentifier;
+ val.confirmationMethod = ConfirmationMethod.METHOD_SENDER_VOUCHES;
}
/**
@@ -87,11 +88,12 @@ public class SAML1AttributeQueryFlowTest extends AbstractSAML1FlowTest {
overrideEndStateOutput(FLOW_ID);
final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ final SAML1TestResponseValidator val = validator;
+ assert val!=null;
+ val.statusCode = StatusCode.SUCCESS;
+ val.usedAttributeDesignators = false;
- validator.statusCode = StatusCode.SUCCESS;
- validator.usedAttributeDesignators = false;
-
- validateResult(result, FLOW_ID, validator);
+ validateResult(result, FLOW_ID, val);
}
/**
@@ -109,11 +111,13 @@ public class SAML1AttributeQueryFlowTest extends AbstractSAML1FlowTest {
overrideEndStateOutput(FLOW_ID);
final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ final SAML1TestResponseValidator val = validator;
+ assert val!=null;
- validator.statusCode = StatusCode.SUCCESS;
- validator.usedAttributeDesignators = true;
+ val.statusCode = StatusCode.SUCCESS;
+ val.usedAttributeDesignators = true;
- validateResult(result, FLOW_ID, validator);
+ validateResult(result, FLOW_ID, val);
}
/**
@@ -128,11 +132,13 @@ public class SAML1AttributeQueryFlowTest extends AbstractSAML1FlowTest {
overrideEndStateOutput(FLOW_ID);
final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ final SAML1TestResponseValidator val = validator;
+ assert val!=null;
- validator.statusCode = StatusCode.REQUESTER;
- validator.usedAttributeDesignators = false;
+ val.statusCode = StatusCode.REQUESTER;
+ val.usedAttributeDesignators = false;
- validateResult(result, FLOW_ID, validator);
+ validateResult(result, FLOW_ID, val);
}
/**
@@ -172,9 +178,10 @@ public class SAML1AttributeQueryFlowTest extends AbstractSAML1FlowTest {
}
final Envelope envelope = buildSOAP11Envelope(attributeQuery);
-
+ final Marshaller m = marshallerFactory.getMarshaller(envelope);
+ assert m!=null;
final String requestContent =
- SerializeSupport.nodeToString(marshallerFactory.getMarshaller(envelope).marshall(envelope,
+ SerializeSupport.nodeToString(m.marshall(envelope,
parserPool.newDocument()));
request.setMethod("POST");
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1TestResponseValidator.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1TestResponseValidator.java
index ff624531e..36c7a94fa 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1TestResponseValidator.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml1/SAML1TestResponseValidator.java
@@ -25,8 +25,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.namespace.QName;
-import net.shibboleth.idp.saml.xml.SAMLConstants;
-
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.schema.XSAny;
import org.opensaml.saml.common.SAMLObjectBuilder;
@@ -47,6 +45,8 @@ import org.opensaml.saml.saml1.core.Subject;
import org.opensaml.saml.saml1.core.SubjectConfirmation;
import org.testng.Assert;
+import net.shibboleth.idp.saml.xml.SAMLConstants;
+
/**
* Validate a test SAML 1 Response.
*/
@@ -109,6 +109,7 @@ public class SAML1TestResponseValidator {
* @param response the SAML response
*/
public void validateResponse(@Nullable final Response response) {
+ assert response!=null;
assertResponse(response);
@@ -147,10 +148,11 @@ public class SAML1TestResponseValidator {
* @param assertion the assertion
*/
public void validateConditions(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
+ assert assertion!=null;
final Conditions conditions = assertion.getConditions();
assertConditions(conditions);
+ assert conditions!=null;
final List<AudienceRestrictionCondition> audienceRestrictionConditions =
conditions.getAudienceRestrictionConditions();
@@ -174,7 +176,7 @@ public class SAML1TestResponseValidator {
* @param assertion the assertion
*/
public void validateAuthenticationStatements(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
+ assert assertion!=null;
final List<AuthenticationStatement> authenticationStatements = assertion.getAuthenticationStatements();
assertAuthenticationStatements(authenticationStatements);
@@ -205,7 +207,7 @@ public class SAML1TestResponseValidator {
* @param assertion the assertion
*/
public void validateAttributeStatements(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
+ assert assertion!=null;
final List<AttributeStatement> attributeStatements = assertion.getAttributeStatements();
assertAttributeStatements(attributeStatements);
@@ -240,7 +242,7 @@ public class SAML1TestResponseValidator {
* @param response the SAML 1 response
*/
public void assertResponse(@Nullable final Response response) {
- Assert.assertNotNull(response);
+ assert response!=null;
Assert.assertNotNull(response.getID());
Assert.assertFalse(response.getID().isEmpty());
Assert.assertNotNull(response.getIssueInstant());
@@ -259,7 +261,7 @@ public class SAML1TestResponseValidator {
* @param status the status
*/
public void assertStatus(@Nullable final Status status) {
- Assert.assertNotNull(status);
+ assert status!=null;
Assert.assertNotNull(status.getStatusCode());
Assert.assertEquals(status.getStatusCode().getValue(), statusCode);
if (statusCode != StatusCode.SUCCESS) {
@@ -273,7 +275,7 @@ public class SAML1TestResponseValidator {
* @param assertions the assertions
*/
public void assertAssertions(@Nullable final List<Assertion> assertions) {
- Assert.assertNotNull(assertions);
+ assert assertions!=null;
Assert.assertFalse(assertions.isEmpty());
Assert.assertEquals(assertions.size(), 1);
Assert.assertNotNull(assertions.get(0));
@@ -291,9 +293,11 @@ public class SAML1TestResponseValidator {
* @param assertion the assertion
*/
public void assertAssertion(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
- Assert.assertNotNull(assertion.getID());
- Assert.assertFalse(assertion.getID().isEmpty());
+ assert assertion!=null;
+ final String id = assertion.getID();
+ assert id!=null;
+
+ Assert.assertFalse(id.isEmpty());
Assert.assertNotNull(assertion.getIssueInstant());
Assert.assertEquals(assertion.getMajorVersion(), SAMLVersion.VERSION_11.getMajorVersion());
Assert.assertEquals(assertion.getMinorVersion(), SAMLVersion.VERSION_11.getMinorVersion());
@@ -306,7 +310,7 @@ public class SAML1TestResponseValidator {
* @param authenticationStatements the authentication statements
*/
public void assertAuthenticationStatements(@Nullable final List<AuthenticationStatement> authenticationStatements) {
- Assert.assertNotNull(authenticationStatements);
+ assert authenticationStatements!=null;
Assert.assertFalse(authenticationStatements.isEmpty());
Assert.assertEquals(authenticationStatements.size(), 1);
Assert.assertNotNull(authenticationStatements.get(0));
@@ -323,7 +327,7 @@ public class SAML1TestResponseValidator {
* @param authenticationStatement the authentication statement
*/
public void assertAuthenticationStatement(@Nullable final AuthenticationStatement authenticationStatement) {
- Assert.assertNotNull(authenticationStatement);
+ assert authenticationStatement!=null;
Assert.assertNotNull(authenticationStatement.getSubject());
Assert.assertNotNull(authenticationStatement.getAuthenticationInstant());
Assert.assertNotNull(authenticationStatement.getAuthenticationMethod());
@@ -336,7 +340,7 @@ public class SAML1TestResponseValidator {
* @param method the authentication method
*/
public void assertAuthenticationMethod(@Nullable final String method) {
- Assert.assertNotNull(method);
+ assert method!=null;
Assert.assertEquals(method, authenticationMethod);
}
@@ -347,7 +351,7 @@ public class SAML1TestResponseValidator {
*/
public void assertAudienceRestrictionConditions(
@Nullable final List<AudienceRestrictionCondition> audienceRestrictionConditions) {
- Assert.assertNotNull(audienceRestrictionConditions);
+ assert audienceRestrictionConditions!=null;
Assert.assertEquals(audienceRestrictionConditions.size(), 1);
}
@@ -357,7 +361,7 @@ public class SAML1TestResponseValidator {
* @param audiences the audiences
*/
public void assertAudiences(@Nullable final List<Audience> audiences) {
- Assert.assertNotNull(audiences);
+ assert audiences!=null;
Assert.assertEquals(audiences.size(), 1);
Assert.assertEquals(audiences.get(0).getURI(), spEntityID);
}
@@ -369,7 +373,7 @@ public class SAML1TestResponseValidator {
* @param conditions the conditions
*/
public void assertConditions(@Nullable final Conditions conditions) {
- Assert.assertNotNull(conditions);
+ assert conditions!=null;
Assert.assertNotNull(conditions.getNotBefore());
Assert.assertNotNull(conditions.getNotOnOrAfter());
// TODO check time via some range ?
@@ -383,7 +387,7 @@ public class SAML1TestResponseValidator {
* @param attributeStatements the attribute statements
*/
public void assertAttributeStatements(@Nullable final List<AttributeStatement> attributeStatements) {
- Assert.assertNotNull(attributeStatements);
+ assert attributeStatements!=null;
Assert.assertFalse(attributeStatements.isEmpty());
Assert.assertEquals(attributeStatements.size(), 1);
Assert.assertNotNull(attributeStatements.get(0));
@@ -395,7 +399,7 @@ public class SAML1TestResponseValidator {
* @param attributeStatement the attribute statement
*/
public void assertAttributeStatement(@Nullable final AttributeStatement attributeStatement) {
- Assert.assertNotNull(attributeStatement);
+ assert attributeStatement!=null;
Assert.assertNotNull(attributeStatement.getSubject());
Assert.assertNotNull(attributeStatement.getAttributes());
}
@@ -406,7 +410,7 @@ public class SAML1TestResponseValidator {
* @param subject the subject
*/
public void assertSubject(@Nullable final Subject subject) {
- Assert.assertNotNull(subject);
+ assert subject!=null;
Assert.assertNotNull(subject.getNameIdentifier());
Assert.assertNotNull(subject.getSubjectConfirmation());
}
@@ -425,7 +429,7 @@ public class SAML1TestResponseValidator {
* @param identifier the name identifier
*/
public void assertNameIdentifier(@Nullable final NameIdentifier identifier) {
- Assert.assertNotNull(identifier);
+ assert identifier!=null;
Assert.assertNotNull(identifier.getValue());
if (nameIdentifier.getFormat() != null
&& !nameIdentifier.getFormat().equals(SAMLConstants.SAML1_NAMEID_TRANSIENT)) {
@@ -441,7 +445,7 @@ public class SAML1TestResponseValidator {
* @param subjectConfirmation the subject confirmation
*/
public void assertSubjectConfirmation(@Nullable final SubjectConfirmation subjectConfirmation) {
- Assert.assertNotNull(subjectConfirmation);
+ assert subjectConfirmation!=null;
Assert.assertEquals(subjectConfirmation.getConfirmationMethods().size(), 1);
}
@@ -453,7 +457,7 @@ public class SAML1TestResponseValidator {
* @param confirmationMethods the confirmation methods
*/
public void assertConfirmationMethods(@Nullable final List<ConfirmationMethod> confirmationMethods) {
- Assert.assertNotNull(confirmationMethods);
+ assert confirmationMethods!=null;
Assert.assertFalse(confirmationMethods.isEmpty());
Assert.assertEquals(confirmationMethods.size(), 1);
Assert.assertNotNull(confirmationMethods.get(0));
@@ -466,7 +470,7 @@ public class SAML1TestResponseValidator {
* @param method the confirmation method
*/
public void assertConfirmationMethod(@Nullable final ConfirmationMethod method) {
- Assert.assertNotNull(method);
+ assert method!=null;
Assert.assertEquals(method.getURI(), confirmationMethod);
}
@@ -495,7 +499,7 @@ public class SAML1TestResponseValidator {
* @param attributes the attributes
*/
public void assertAttributes(@Nullable final List<Attribute> attributes) {
- Assert.assertNotNull(attributes);
+ assert attributes!=null;
Assert.assertFalse(attributes.isEmpty());
Assert.assertEquals(attributes.size(), usedAttributeDesignators ? 2 : 4);
@@ -548,7 +552,7 @@ public class SAML1TestResponseValidator {
*/
public void assertAttribute(@Nullable final Attribute attribute, @Nonnull final String attributeName,
@Nonnull final String attributeValue) {
- Assert.assertNotNull(attribute);
+ assert attribute!=null;
Assert.assertEquals(attribute.getAttributeName(), attributeName);
Assert.assertEquals(attribute.getAttributeNamespace(), SAMLConstants.SAML1_ATTR_NAMESPACE_URI);
Assert.assertEquals(attribute.getAttributeValues().size(), 1);
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2FlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2FlowTest.java
index 809ff31f5..afad6101e 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2FlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2FlowTest.java
@@ -22,6 +22,7 @@ import javax.annotation.Nullable;
import net.shibboleth.idp.test.flows.AbstractFlowTest;
+import org.opensaml.messaging.context.MessageContext;
import org.opensaml.profile.context.ProfileRequestContext;
import org.opensaml.saml.saml2.core.Response;
import org.springframework.webflow.execution.FlowExecutionOutcome;
@@ -39,7 +40,7 @@ public class AbstractSAML2FlowTest extends AbstractFlowTest {
* @param result the flow execution result
* @param flowId the flow ID
*/
- public void validateResult(@Nullable final FlowExecutionResult result, @Nonnull final String flowId) {
+ public void validateResult(@Nonnull final FlowExecutionResult result, @Nonnull final String flowId) {
final SAML2TestResponseValidator validator = new SAML2TestResponseValidator();
validator.spCredential = spCredential;
validateResult(result, flowId, validator);
@@ -52,7 +53,7 @@ public class AbstractSAML2FlowTest extends AbstractFlowTest {
* @param flowId the flow ID
* @param validator the response validator
*/
- public void validateResult(@Nullable final FlowExecutionResult result, @Nonnull final String flowId,
+ public void validateResult(@Nonnull final FlowExecutionResult result, @Nonnull final String flowId,
@Nonnull final SAML2TestResponseValidator validator) {
assertFlowExecutionResult(result, flowId);
validator.validateResponse(getResponse(result));
@@ -64,14 +65,16 @@ public class AbstractSAML2FlowTest extends AbstractFlowTest {
* @param result the flow result
* @return the SAML response
*/
- public Response getResponse(@Nullable final FlowExecutionResult result) {
+ public Response getResponse(@Nonnull final FlowExecutionResult result) {
final FlowExecutionOutcome outcome = result.getOutcome();
assertFlowExecutionOutcome(outcome);
final ProfileRequestContext prc = (ProfileRequestContext) outcome.getOutput().get(END_STATE_OUTPUT_ATTR_NAME);
assertProfileRequestContext(prc);
- Assert.assertTrue(prc.getOutboundMessageContext().getMessage() instanceof Response);
+ final MessageContext omc = prc.getOutboundMessageContext();
+ assert omc!=null;
+ Assert.assertTrue(omc.getMessage() instanceof Response);
- return (Response) prc.getOutboundMessageContext().getMessage();
+ return (Response) omc.getMessage();
}
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2SSOFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2SSOFlowTest.java
index 1dcbc8f14..5d28de885 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2SSOFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/AbstractSAML2SSOFlowTest.java
@@ -22,6 +22,7 @@ import java.time.Instant;
import javax.annotation.Nonnull;
+import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.messaging.context.MessageContext;
import org.opensaml.saml.common.messaging.context.SAMLEndpointContext;
import org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext;
@@ -45,12 +46,12 @@ import org.opensaml.xmlsec.encryption.support.EncryptionException;
import org.opensaml.xmlsec.encryption.support.KeyEncryptionParameters;
import org.opensaml.xmlsec.keyinfo.impl.X509KeyInfoGeneratorFactory;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import jakarta.servlet.http.HttpServletRequest;
import net.shibboleth.idp.test.flows.AbstractFlowTest;
import net.shibboleth.shared.net.SimpleURLCanonicalizer;
import net.shibboleth.shared.net.URLBuilder;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Abstract SAML 2 SSO flow test.
@@ -61,7 +62,7 @@ public abstract class AbstractSAML2SSOFlowTest extends AbstractSAML2FlowTest {
/** Class logger. */
@Nonnull protected final Logger log = LoggerFactory.getLogger(AbstractSAML2SSOFlowTest.class);
- public String getDestinationRedirect(HttpServletRequest servletRequest) {
+ public String getDestinationRedirect(@Nonnull HttpServletRequest servletRequest) {
// TODO servlet context
String destinationPath = "/idp/profile/SAML2/Redirect/SSO";
try {
@@ -75,7 +76,7 @@ public abstract class AbstractSAML2SSOFlowTest extends AbstractSAML2FlowTest {
}
}
- public String getDestinationPost(HttpServletRequest servletRequest) {
+ public String getDestinationPost(@Nonnull HttpServletRequest servletRequest) {
// TODO servlet context
String destinationPath = "/idp/profile/SAML2/POST/SSO";
String baseUrl = getBaseUrl(servletRequest);
@@ -89,7 +90,7 @@ public abstract class AbstractSAML2SSOFlowTest extends AbstractSAML2FlowTest {
}
}
- public String getDestinationPostSimpleSign(HttpServletRequest servletRequest) {
+ public String getDestinationPostSimpleSign(@Nonnull HttpServletRequest servletRequest) {
// TODO servlet context
String destinationPath = "/idp/profile/SAML2/POST-SimpleSign/SSO";
String baseUrl = getBaseUrl(servletRequest);
@@ -123,43 +124,45 @@ public abstract class AbstractSAML2SSOFlowTest extends AbstractSAML2FlowTest {
public AuthnRequest buildAuthnRequest(final HttpServletRequest servletRequest, final String acsURL, final String outboundBinding)
throws EncryptionException {
- final AuthnRequest authnRequest =
- (AuthnRequest) builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME).buildObject(
- AuthnRequest.DEFAULT_ELEMENT_NAME);
+ final XMLObjectBuilder<?> authnRequestBuilder = builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
+ assert authnRequestBuilder!=null;
+ final AuthnRequest authnRequest = (AuthnRequest) authnRequestBuilder.buildObject(AuthnRequest.DEFAULT_ELEMENT_NAME);
authnRequest.setID(idGenerator.generateIdentifier());
authnRequest.setIssueInstant(Instant.now());
authnRequest.setAssertionConsumerServiceURL(acsURL);
authnRequest.setProtocolBinding(outboundBinding);
- final Issuer issuer =
- (Issuer) builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME)
- .buildObject(Issuer.DEFAULT_ELEMENT_NAME);
+ final XMLObjectBuilder<?> issuerBuilder = builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
+ assert issuerBuilder!=null;
+ final Issuer issuer = (Issuer) issuerBuilder.buildObject(Issuer.DEFAULT_ELEMENT_NAME);
issuer.setValue(AbstractFlowTest.SP_ENTITY_ID);
authnRequest.setIssuer(issuer);
- final NameIDPolicy nameIDPolicy =
- (NameIDPolicy) builderFactory.getBuilder(NameIDPolicy.DEFAULT_ELEMENT_NAME).buildObject(
+ final XMLObjectBuilder<?> nidPolicyBuilder = builderFactory.getBuilder(NameIDPolicy.DEFAULT_ELEMENT_NAME);
+ assert nidPolicyBuilder!=null;
+ final NameIDPolicy nameIDPolicy = (NameIDPolicy) nidPolicyBuilder.buildObject(
NameIDPolicy.DEFAULT_ELEMENT_NAME);
nameIDPolicy.setAllowCreate(true);
authnRequest.setNameIDPolicy(nameIDPolicy);
- final NameID nameID =
- (NameID) builderFactory.getBuilder(NameID.DEFAULT_ELEMENT_NAME)
- .buildObject(NameID.DEFAULT_ELEMENT_NAME);
+ final XMLObjectBuilder<?> nidBuilder = builderFactory.getBuilder(NameID.DEFAULT_ELEMENT_NAME);
+ assert nidBuilder!=null;
+ final NameID nameID = (NameID) nidBuilder.buildObject(NameID.DEFAULT_ELEMENT_NAME);
nameID.setValue("jdoe");
- final Subject subject =
- (Subject) builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME).buildObject(
- Subject.DEFAULT_ELEMENT_NAME);
+ final XMLObjectBuilder<?> subjectBuilder = builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME);
+ assert subjectBuilder!=null;
+ final Subject subject = (Subject) subjectBuilder.buildObject(Subject.DEFAULT_ELEMENT_NAME);
subject.setEncryptedID(getEncrypter().encrypt(nameID));
authnRequest.setSubject(subject);
- final RequestedAuthnContext reqAC =
- (RequestedAuthnContext) builderFactory.getBuilder(RequestedAuthnContext.DEFAULT_ELEMENT_NAME).buildObject(
- RequestedAuthnContext.DEFAULT_ELEMENT_NAME);
- final AuthnContextClassRef ac =
- (AuthnContextClassRef) builderFactory.getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME).buildObject(
+ final XMLObjectBuilder<?> racBuilder = builderFactory.getBuilder(RequestedAuthnContext.DEFAULT_ELEMENT_NAME);
+ assert racBuilder!=null;
+ final RequestedAuthnContext reqAC = (RequestedAuthnContext) racBuilder.buildObject(RequestedAuthnContext.DEFAULT_ELEMENT_NAME);
+ final XMLObjectBuilder<?> accRefBuilder = builderFactory.getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
+ assert accRefBuilder!=null;
+ final AuthnContextClassRef ac = (AuthnContextClassRef) accRefBuilder.buildObject(
AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
ac.setURI(AuthnContext.UNSPECIFIED_AUTHN_CTX);
reqAC.getAuthnContextClassRefs().add(ac);
@@ -189,6 +192,7 @@ public abstract class AbstractSAML2SSOFlowTest extends AbstractSAML2FlowTest {
public String getAcsUrl(final HttpServletRequest servletRequest, final String acsURL) {
// TODO servlet context
String baseUrl = getBaseUrl(servletRequest);
+ assert baseUrl!=null;
try {
URLBuilder urlBuilder = new URLBuilder(SimpleURLCanonicalizer.canonicalize(baseUrl));
urlBuilder.setPath(acsURL);
@@ -200,9 +204,9 @@ public abstract class AbstractSAML2SSOFlowTest extends AbstractSAML2FlowTest {
}
public SingleSignOnService buildIdpSsoEndpoint(String binding, String destination) {
- SingleSignOnService ssoEndpoint =
- (SingleSignOnService) builderFactory.getBuilder(SingleSignOnService.DEFAULT_ELEMENT_NAME).buildObject(
- SingleSignOnService.DEFAULT_ELEMENT_NAME);
+ final XMLObjectBuilder<?> builder = builderFactory.getBuilder(SingleSignOnService.DEFAULT_ELEMENT_NAME);
+ assert builder!=null;
+ SingleSignOnService ssoEndpoint = (SingleSignOnService) builder.buildObject(SingleSignOnService.DEFAULT_ELEMENT_NAME);
ssoEndpoint.setBinding(binding);
ssoEndpoint.setLocation(destination);
return ssoEndpoint;
@@ -230,16 +234,16 @@ public abstract class AbstractSAML2SSOFlowTest extends AbstractSAML2FlowTest {
final MessageContext messageContext = new MessageContext();
messageContext.setMessage(authnRequest);
- SAMLPeerEntityContext peerContext = messageContext.getSubcontext(SAMLPeerEntityContext.class, true);
+ SAMLPeerEntityContext peerContext = messageContext.getOrCreateSubcontext(SAMLPeerEntityContext.class);
peerContext.setEntityId(AbstractFlowTest.IDP_ENTITY_ID);
- SAMLEndpointContext endpointContext = peerContext.getSubcontext(SAMLEndpointContext.class, true);
+ SAMLEndpointContext endpointContext = peerContext.getOrCreateSubcontext(SAMLEndpointContext.class);
endpointContext.setEndpoint(buildIdpSsoEndpoint(bindingUri, authnRequest.getDestination()));
SignatureSigningParameters signingParameters = new SignatureSigningParameters();
signingParameters.setSigningCredential(spCredential);
SecurityParametersContext secParamsContext =
- messageContext.getSubcontext(SecurityParametersContext.class, true);
+ messageContext.getOrCreateSubcontext(SecurityParametersContext.class);
secParamsContext.setSignatureSigningParameters(signingParameters);
return messageContext;
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2AttributeQueryFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2AttributeQueryFlowTest.java
index 64d9a6e69..cd0dbfbfd 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2AttributeQueryFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2AttributeQueryFlowTest.java
@@ -23,12 +23,9 @@ import java.time.Instant;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.shared.security.IdentifierGenerationStrategy;
-import net.shibboleth.shared.security.IdentifierGenerationStrategy.ProviderType;
-import net.shibboleth.shared.xml.SerializeSupport;
-
import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
+import org.opensaml.core.xml.io.Marshaller;
import org.opensaml.core.xml.schema.XSAny;
import org.opensaml.saml.common.SAMLObjectBuilder;
import org.opensaml.saml.saml2.core.Attribute;
@@ -46,6 +43,10 @@ import org.springframework.webflow.executor.FlowExecutionResult;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import net.shibboleth.shared.security.IdentifierGenerationStrategy;
+import net.shibboleth.shared.security.IdentifierGenerationStrategy.ProviderType;
+import net.shibboleth.shared.xml.SerializeSupport;
+
/**
* SAML 2 attribute query flow test.
*/
@@ -69,12 +70,12 @@ public class SAML2AttributeQueryFlowTest extends AbstractSAML2FlowTest {
nameID.setSPNameQualifier(null);
nameID.setFormat(null);
- validator = new SAML2TestResponseValidator();
- validator.nameID = nameID;
- validator.spCredential = spCredential;
- validator.subjectConfirmationMethod = SubjectConfirmation.METHOD_SENDER_VOUCHES;
- validator.validateAuthnStatements = false;
- validator.validateSubjectConfirmationData = false;
+ final SAML2TestResponseValidator localValidator = this.validator = new SAML2TestResponseValidator();
+ localValidator.nameID = nameID;
+ localValidator.spCredential = spCredential;
+ localValidator.subjectConfirmationMethod = SubjectConfirmation.METHOD_SENDER_VOUCHES;
+ localValidator.validateAuthnStatements = false;
+ localValidator.validateSubjectConfirmationData = false;
}
/**
@@ -92,11 +93,13 @@ public class SAML2AttributeQueryFlowTest extends AbstractSAML2FlowTest {
overrideEndStateOutput(FLOW_ID);
final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ assert result != null;
+ final SAML2TestResponseValidator localValidator = validator;
+ assert localValidator!= null;
+ localValidator.statusCode = StatusCode.SUCCESS;
+ localValidator.usedAttributeDesignators = false;
- validator.statusCode = StatusCode.SUCCESS;
- validator.usedAttributeDesignators = false;
-
- validateResult(result, FLOW_ID, validator);
+ validateResult(result, FLOW_ID, localValidator);
}
/**
@@ -114,11 +117,14 @@ public class SAML2AttributeQueryFlowTest extends AbstractSAML2FlowTest {
overrideEndStateOutput(FLOW_ID);
final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ assert result != null;
+ final SAML2TestResponseValidator localValidator = validator;
+ assert localValidator!= null;
- validator.statusCode = StatusCode.SUCCESS;
- validator.usedAttributeDesignators = true;
+ localValidator.statusCode = StatusCode.SUCCESS;
+ localValidator.usedAttributeDesignators = true;
- validateResult(result, FLOW_ID, validator);
+ validateResult(result, FLOW_ID, localValidator);
}
/**
@@ -133,11 +139,14 @@ public class SAML2AttributeQueryFlowTest extends AbstractSAML2FlowTest {
overrideEndStateOutput(FLOW_ID);
final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+ assert result != null;
+ final SAML2TestResponseValidator localValidator = validator;
+ assert localValidator!= null;
- validator.statusCode = StatusCode.REQUESTER;
- validator.usedAttributeDesignators = false;
+ localValidator.statusCode = StatusCode.REQUESTER;
+ localValidator.usedAttributeDesignators = false;
- validateResult(result, FLOW_ID, validator);
+ validateResult(result, FLOW_ID, localValidator);
}
/**
@@ -181,10 +190,10 @@ public class SAML2AttributeQueryFlowTest extends AbstractSAML2FlowTest {
}
final Envelope envelope = buildSOAP11Envelope(attributeQuery);
-
+ final Marshaller m = marshallerFactory.getMarshaller(envelope);
+ assert m != null;
final String requestContent =
- SerializeSupport.nodeToString(marshallerFactory.getMarshaller(envelope).marshall(envelope,
- parserPool.newDocument()));
+ SerializeSupport.nodeToString(m.marshall(envelope, parserPool.newDocument()));
request.setMethod("POST");
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2ECPSSOFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2ECPSSOFlowTest.java
index 1c02b8cf6..d3212c350 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2ECPSSOFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2ECPSSOFlowTest.java
@@ -76,6 +76,7 @@ public class SAML2ECPSSOFlowTest extends AbstractSAML2SSOFlowTest {
final MessageContext messageContext =
buildOutboundMessageContext(authnRequest, SAMLConstants.SAML2_SOAP11_BINDING_URI);
final SAMLObject message = (SAMLObject) messageContext.getMessage();
+ assert message!=null;
request.setContent(encodeMessage(message).getBytes("UTF-8"));
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSSOFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSSOFlowTest.java
index 8b0c6f366..340925a85 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSSOFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSSOFlowTest.java
@@ -76,6 +76,7 @@ public class SAML2POSTSSOFlowTest extends AbstractSAML2SSOFlowTest {
final MessageContext messageContext =
buildOutboundMessageContext(authnRequest, SAMLConstants.SAML2_POST_BINDING_URI);
final SAMLObject message = (SAMLObject) messageContext.getMessage();
+ assert message!=null;
final String encodedMessage = encodeMessage(message);
request.addParameter("SAMLRequest", encodedMessage);
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSimpleSignSSOFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSimpleSignSSOFlowTest.java
index a41f8fad4..e43ffc7ab 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSimpleSignSSOFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2POSTSimpleSignSSOFlowTest.java
@@ -76,6 +76,7 @@ public class SAML2POSTSimpleSignSSOFlowTest extends AbstractSAML2SSOFlowTest {
final MessageContext messageContext =
buildOutboundMessageContext(authnRequest, SAMLConstants.SAML2_POST_SIMPLE_SIGN_BINDING_URI);
final SAMLObject message = (SAMLObject) messageContext.getMessage();
+ assert message!=null;
final String encodedMessage = encodeMessage(message);
request.addParameter("SAMLRequest", encodedMessage);
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2RedirectSSOFlowTest.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2RedirectSSOFlowTest.java
index bb9f38974..dad0c4b87 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2RedirectSSOFlowTest.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2RedirectSSOFlowTest.java
@@ -79,6 +79,7 @@ public class SAML2RedirectSSOFlowTest extends AbstractSAML2SSOFlowTest {
final MessageContext messageContext =
buildOutboundMessageContext(authnRequest, SAMLConstants.SAML2_REDIRECT_BINDING_URI);
final SAMLObject message = (SAMLObject) messageContext.getMessage();
+ assert message!=null;
final String encodedMessage = encodeMessage(message);
request.addParameter("SAMLRequest", encodedMessage);
}
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java
index eccb1ce3c..64554e677 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java
@@ -91,10 +91,10 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
@Nonnull public IPRange subjectConfirmationDataAddressRangeV6 = IPRange.parseCIDRBlock("::1/128");
/** Whether authn statements should be validated. */
- @Nonnull public boolean validateAuthnStatements = true;
+ public boolean validateAuthnStatements = true;
/** Whether subject confirmation data should be validated. */
- @Nonnull public boolean validateSubjectConfirmationData = true;
+ public boolean validateSubjectConfirmationData = true;
/** Whether attributes were limited by designators. */
public boolean usedAttributeDesignators = false;
@@ -131,6 +131,14 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
nameID.setSPNameQualifier(spEntityID);
buildExpectedAttributes();
+ // fool code analyzer
+ uidAttribute = uidAttribute;
+ homeOrgAttribute = homeOrgAttribute;
+ eppnAttribute = eppnAttribute;
+ mailAttribute = mailAttribute;
+ eduPersonScopedAffiliationAttribute = eduPersonScopedAffiliationAttribute;
+ expectedDesignatedAttributes = expectedDesignatedAttributes;
+ expectedAttributes = expectedAttributes;
}
/** Build expected attributes. */
@@ -200,11 +208,12 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
expectedDesignatedAttributes.add(mailAttribute);
}
- private Assertion decryptAssertion(final EncryptedAssertion encrypted) throws DecryptionException {
+ private Assertion decryptAssertion(@Nonnull final EncryptedAssertion encrypted) throws DecryptionException {
ArrayList<EncryptedKeyResolver> resolverChain = new ArrayList<>();
resolverChain.add(new InlineEncryptedKeyResolver());
resolverChain.add(new EncryptedElementTypeEncryptedKeyResolver());
final ChainingEncryptedKeyResolver chain = new ChainingEncryptedKeyResolver(resolverChain);
+ assert spCredential!=null;
final Decrypter decrypter = new Decrypter(null, new StaticKeyInfoCredentialResolver(spCredential), chain);
return decrypter.decrypt(encrypted);
}
@@ -229,7 +238,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
*
* @param response the flow execution result
*/
- public void validateResponse(@Nullable final Response response) {
+ public void validateResponse(@Nonnull final Response response) {
super.validateResponse(response);
@@ -279,7 +288,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
*
* @param subject the subject
*/
- public void validateSubject(@Nullable final Subject subject) {
+ public void validateSubject(@Nonnull final Subject subject) {
assertSubject(subject);
assertNameID(subject.getNameID());
assertSubjectConfirmations(subject.getSubjectConfirmations());
@@ -303,8 +312,8 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
*
* @param assertion the assertion
*/
- public void validateConditions(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
+ public void validateConditions(@Nullable Assertion assertion) {
+ assert assertion!=null;
final Conditions conditions = assertion.getConditions();
assertConditions(conditions);
@@ -328,7 +337,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param assertion the assertion
*/
public void validateAuthnStatements(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
+ assert assertion!=null;
final List<AuthnStatement> authnStatements = assertion.getAuthnStatements();
assertAuthnStatements(authnStatements);
@@ -351,7 +360,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param assertion the assertion
*/
public void validateAttributeStatements(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
+ assert assertion!=null;
final List<AttributeStatement> attributeStatements = assertion.getAttributeStatements();
assertAttributeStatements(attributeStatements);
@@ -369,7 +378,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param assertions the assertions
*/
public void assertAssertions(@Nullable List<Assertion> assertions) {
- Assert.assertNotNull(assertions);
+ assert assertions!=null;
Assert.assertFalse(assertions.isEmpty());
Assert.assertEquals(assertions.size(), 1);
Assert.assertNotNull(assertions.get(0));
@@ -387,7 +396,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param assertion the assertion
*/
public void assertAssertion(@Nullable final Assertion assertion) {
- Assert.assertNotNull(assertion);
+ assert assertion!=null;
Assert.assertNotNull(assertion.getID());
Assert.assertFalse(assertion.getID().isEmpty());
Assert.assertNotNull(assertion.getIssueInstant());
@@ -401,7 +410,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param subject the subject
*/
public void assertSubject(@Nullable final Subject subject) {
- Assert.assertNotNull(subject);
+ assert subject!=null;
Assert.assertNotNull(subject.getNameID());
Assert.assertNotNull(subject.getSubjectConfirmations());
}
@@ -412,7 +421,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param subjectConfirmations the subject confirmations
*/
public void assertSubjectConfirmations(@Nullable final List<SubjectConfirmation> subjectConfirmations) {
- Assert.assertNotNull(subjectConfirmations);
+ assert subjectConfirmations!=null;
Assert.assertEquals(subjectConfirmations.size(), 1);
}
@@ -422,7 +431,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param subjectConfirmation the subject confirmation
*/
public void assertSubjectConfirmation(@Nullable final SubjectConfirmation subjectConfirmation) {
- Assert.assertNotNull(subjectConfirmation);
+ assert subjectConfirmation!=null;
Assert.assertNotNull(subjectConfirmation.getMethod());
}
@@ -432,6 +441,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param method the subject confirmation
*/
public void assertSubjectConfirmationMethod(@Nullable final SubjectConfirmation method) {
+ assert method!=null;
Assert.assertEquals(method.getMethod(), subjectConfirmationMethod);
}
@@ -446,6 +456,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param subjectConfirmationData the subject confirmation data
*/
public void assertSubjectConfirmationData(@Nullable final SubjectConfirmationData subjectConfirmationData) {
+ assert subjectConfirmationData!=null;
final InetAddress address = InetAddresses.forString(subjectConfirmationData.getAddress());
if (address instanceof Inet4Address) {
boolean matches = false;
@@ -481,7 +492,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param id the NameID
*/
public void assertNameID(@Nullable final NameID id) {
- Assert.assertNotNull(id);
+ assert id!=null;
Assert.assertNotNull(id.getValue());
if (nameID.getFormat() != null && !nameID.getFormat().equals(NameID.TRANSIENT)) {
Assert.assertEquals(id.getValue(), nameID.getValue());
@@ -497,7 +508,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param conditions the conditions
*/
public void assertConditions(@Nullable final Conditions conditions) {
- Assert.assertNotNull(conditions);
+ assert conditions!=null;
Assert.assertNotNull(conditions.getNotBefore());
Assert.assertNotNull(conditions.getNotOnOrAfter());
// TODO check time via some range ?
@@ -509,7 +520,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param audienceRestrictions the audience restrictions
*/
public void assertAudienceRestrictions(@Nullable final List<AudienceRestriction> audienceRestrictions) {
- Assert.assertNotNull(audienceRestrictions);
+ assert audienceRestrictions!=null;
Assert.assertEquals(audienceRestrictions.size(), 1);
}
@@ -519,7 +530,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param audienceRestriction the audience restriction
*/
public void assertAudienceRestriction(@Nullable final AudienceRestriction audienceRestriction) {
- Assert.assertNotNull(audienceRestriction);
+ assert audienceRestriction!=null;
final List<Audience> audiences = audienceRestriction.getAudiences();
Assert.assertEquals(audiences.size(), 1);
@@ -534,7 +545,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param authnStatements the authn statements
*/
public void assertAuthnStatements(@Nullable final List<AuthnStatement> authnStatements) {
- Assert.assertNotNull(authnStatements);
+ assert authnStatements!=null;
Assert.assertEquals(authnStatements.size(), 1);
Assert.assertNotNull(authnStatements.get(0));
}
@@ -545,7 +556,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param authnStatement the authn statement
*/
public void assertAuthnStatement(@Nonnull final AuthnStatement authnStatement) {
- Assert.assertNotNull(authnStatement);
+ assert authnStatement!=null;
Assert.assertNotNull(authnStatement.getAuthnInstant());
// TODO check authn instant time ?
Assert.assertNotNull(authnStatement.getAuthnContext());
@@ -557,7 +568,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
*
* @param authnContext the authn context
*/
- public void assertAuthnContextClassRef(@Nullable final AuthnContextClassRef authnContext) {
+ public void assertAuthnContextClassRef(@Nonnull final AuthnContextClassRef authnContext) {
Assert.assertEquals(authnContext.getURI(), authnContextClassRef);
}
@@ -567,7 +578,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param attributeStatements the attribute statements
*/
public void assertAttributeStatements(@Nullable final List<AttributeStatement> attributeStatements) {
- Assert.assertNotNull(attributeStatements);
+ assert attributeStatements!=null;
Assert.assertFalse(attributeStatements.isEmpty());
Assert.assertEquals(attributeStatements.size(), 1);
Assert.assertNotNull(attributeStatements.get(0));
@@ -579,7 +590,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param attributeStatement the attribute statement
*/
public void assertAttributeStatement(@Nullable final AttributeStatement attributeStatement) {
- Assert.assertNotNull(attributeStatement);
+ assert attributeStatement!=null;
Assert.assertNotNull(attributeStatement.getAttributes());
}
@@ -595,7 +606,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param attributes the attributes
*/
public void assertAttributes(@Nullable final List<Attribute> attributes) {
- Assert.assertNotNull(attributes);
+ assert attributes!=null;
Assert.assertFalse(attributes.isEmpty());
Assert.assertEquals(attributes.size(), usedAttributeDesignators ? expectedDesignatedAttributes.size() : expectedAttributes.size());
@@ -611,7 +622,11 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
Assert.assertNotNull(actualAttribute);
assertAttributeName(actualAttribute, expectedAttribute.getName(), expectedAttribute.getNameFormat(),
expectedAttribute.getFriendlyName());
- assertAttributeValue(actualAttribute, ((XSAny) expectedAttribute.getAttributeValues().get(0)).getTextContent());
+ final XSAny any = ((XSAny) expectedAttribute.getAttributeValues().get(0));
+ assert any!=null;
+ final String text = any.getTextContent();
+ assert text!=null;
+ assertAttributeValue(actualAttribute, text);
}
}
@@ -625,7 +640,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
*/
public void assertAttributeName(@Nullable final Attribute attribute, @Nonnull final String name,
@Nonnull final String nameFormat, @Nonnull final String friendlyName) {
- Assert.assertNotNull(attribute);
+ assert attribute!=null;
Assert.assertEquals(attribute.getName(), name);
Assert.assertEquals(attribute.getNameFormat(), nameFormat);
Assert.assertEquals(attribute.getFriendlyName(), friendlyName);
@@ -637,7 +652,7 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
* @param attribute the attribute
* @param attributeValue the attribute value
*/
- public void assertAttributeValue(@Nullable final Attribute attribute, @Nonnull final String attributeValue) {
+ public void assertAttributeValue(@Nonnull final Attribute attribute, @Nonnull final String attributeValue) {
Assert.assertEquals(attribute.getAttributeValues().size(), 1);
Assert.assertTrue(attribute.getAttributeValues().get(0) instanceof XSAny);
Assert.assertEquals(((XSAny) attribute.getAttributeValues().get(0)).getTextContent(), attributeValue);
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestStatusResponseTypeValidator.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestStatusResponseTypeValidator.java
index b920e25b1..1b4e3be7d 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestStatusResponseTypeValidator.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestStatusResponseTypeValidator.java
@@ -62,6 +62,7 @@ public class SAML2TestStatusResponseTypeValidator {
*/
public void validateResponse(@Nullable final StatusResponseType response) {
assertResponse(response);
+ assert response!=null;
assertStatus(response.getStatus());
}
@@ -80,7 +81,7 @@ public class SAML2TestStatusResponseTypeValidator {
* @param response the status response type
*/
public void assertResponse(@Nullable final StatusResponseType response) {
- Assert.assertNotNull(response);
+ assert response!=null;
Assert.assertNotNull(response.getID());
Assert.assertFalse(response.getID().isEmpty());
Assert.assertNotNull(response.getIssueInstant());
@@ -104,7 +105,7 @@ public class SAML2TestStatusResponseTypeValidator {
* @param status the status
*/
public void assertStatus(@Nullable final Status status) {
- Assert.assertNotNull(status);
+ assert status!=null;
Assert.assertNotNull(status.getStatusCode());
Assert.assertEquals(status.getStatusCode().getValue(), statusCode);
if (statusCode != StatusCode.SUCCESS) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list