[java-opensaml COMMIT] in /trunk: opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointRe...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Feb 14 16:46:35 EST 2014
Author: scantor
Date: Fri Feb 14 16:46:34 2014
New Revision: 3622
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3622&view=rev
Log:
OSJ-61 - mostly done tests, improve default endpoint selection, remove old selector classes
Added:
trunk/opensaml-saml-impl/src/test/resources/data/org/opensaml/saml/common/binding/SPWithEndpoints.xml (with props)
Modified:
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointSelector.java
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/BasicEndpointSelector.java
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/saml1/binding/package.html
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/AuthnResponseEndpointSelector.java
trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/saml2/binding/package.html
trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/DefaultEndpointResolverTest.java
Modified: trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java?rev=3622&r1=3621&r2=3622&view=diff
==============================================================================
--- trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java (original)
+++ trunk/opensaml-saml-api/src/main/java/org/opensaml/saml/common/binding/AbstractEndpointResolver.java Fri Feb 14 16:46:34 2014
@@ -225,15 +225,42 @@
endpointType);
}
+ return sortCandidates(endpoints);
+ }
+
+ /**
+ * Copy and sort the endpoints such that the default endpoint by SAML rules comes first.
+ *
+ * @param candidates input list of endpoints
+ *
+ * @return a new list containing the endpoints such that the default is first
+ */
+ // Checkstyle: CyclomaticComplexity OFF
+ @Nonnull @NonnullElements private List<EndpointType> sortCandidates(
+ @Nonnull @NonnullElements List<Endpoint> candidates) {
+
// Use a linked list, and move the default endpoint to the head of the list.
// SAML defaulting rules apply to IndexedEnpdoint types, and require checking
- // for the isDefault attribute.
+ // for the isDefault attribute. The default is the one marked true, or if none are,
+ // the first not marked false.
+ EndpointType hardDefault = null;
+ EndpointType softDefault = null;
final LinkedList<EndpointType> toReturn = Lists.newLinkedList();
- for (final Endpoint endpoint : endpoints) {
- if (endpoint instanceof IndexedEndpoint) {
- Boolean flag = ((IndexedEndpoint) endpoint).isDefault();
- if (flag != null && flag.booleanValue()) {
- toReturn.addFirst((EndpointType) endpoint);
+ for (final Endpoint endpoint : candidates) {
+ if (hardDefault == null && endpoint instanceof IndexedEndpoint) {
+ final Boolean flag = ((IndexedEndpoint) endpoint).isDefault();
+ if (flag != null) {
+ if (flag.booleanValue()) {
+ hardDefault = (EndpointType) endpoint;
+ if (softDefault != null) {
+ toReturn.addFirst(softDefault);
+ softDefault = null;
+ }
+ } else {
+ toReturn.addLast((EndpointType) endpoint);
+ }
+ } else if (hardDefault == null && softDefault == null) {
+ softDefault = (EndpointType) endpoint;
} else {
toReturn.addLast((EndpointType) endpoint);
}
@@ -242,8 +269,15 @@
}
}
+ if (hardDefault != null) {
+ toReturn.addFirst(hardDefault);
+ } else if (softDefault != null) {
+ toReturn.addFirst(softDefault);
+ }
+
return toReturn;
}
+ // Checkstyle: CyclomaticComplexity ON
/**
* Return a prefix for logging messages for this component.
Modified: trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/DefaultEndpointResolverTest.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/DefaultEndpointResolverTest.java?rev=3622&r1=3621&r2=3622&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/DefaultEndpointResolverTest.java (original)
+++ trunk/opensaml-saml-impl/src/test/java/org/opensaml/saml/common/binding/DefaultEndpointResolverTest.java Fri Feb 14 16:46:34 2014
@@ -22,6 +22,8 @@
import java.io.FileNotFoundException;
[... 190 lines stripped ...]
More information about the commits
mailing list