Fix NPE when there is no relying party metadata
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 25 Feb 2008 12:56:25 +0000 (12:56 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 25 Feb 2008 12:56:25 +0000 (12:56 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2641 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/idp/profile/saml1/ShibbolethSSOEndpointSelector.java

index 890e498..9594b16 100644 (file)
@@ -57,6 +57,11 @@ public class ShibbolethSSOEndpointSelector extends BasicEndpointSelector {
 
     /** {@inheritDoc} */
     public Endpoint selectEndpoint() {
+        if (getEntityRoleMetadata() == null) {
+            log.debug("Unable to select endpoint, no entity role metadata available.");
+            return null;
+        }
+
         if (spAssertionConsumerService != null) {
             return selectEndpointByACS();
         } else {
@@ -70,11 +75,12 @@ public class ShibbolethSSOEndpointSelector extends BasicEndpointSelector {
      * @return endpoint corresponding to the SP-provdided ACS URL
      */
     protected Endpoint selectEndpointByACS() {
-        List<Endpoint> endpoints = getEntityRoleMetadata().getEndpoints();
-        log.debug("Relying party role contains {} endpoints", endpoints.size());
         log.debug("Selecting endpoint from metadata corresponding to provided ACS URL: {}",
                 getSpAssertionConsumerService());
 
+        List<Endpoint> endpoints = getEntityRoleMetadata().getEndpoints();
+        log.debug("Relying party role contains {} endpoints", endpoints.size());
+
         if (endpoints != null && endpoints.size() > 0) {
             for (Endpoint endpoint : endpoints) {
                 if (endpoint == null || !getSupportedIssuerBindings().contains(endpoint.getBinding())) {