[java-opensaml2 COMMIT] in /branches/REL_2: doc/RELEASE-NOTES.txt pom.xml src/main/java/org/opensaml/saml2/metadata/p...

noreply at shibboleth.net noreply at shibboleth.net
Wed Mar 20 19:25:47 EDT 2013


Author: putmanb
Date: Wed Mar 20 19:25:47 2013
New Revision: 1632

URL: http://svn.shibboleth.net/view/java-opensaml2?rev=1632&view=rev
Log:
JOST-205: MetadataProvider doesn't report error during refresh if the metadata file doesn't exist any more

Modified:
    branches/REL_2/doc/RELEASE-NOTES.txt
    branches/REL_2/pom.xml
    branches/REL_2/src/main/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProvider.java
    branches/REL_2/src/test/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProviderTest.java

Modified: branches/REL_2/doc/RELEASE-NOTES.txt
URL: http://svn.shibboleth.net/view/java-opensaml2/branches/REL_2/doc/RELEASE-NOTES.txt?rev=1632&r1=1631&r2=1632&view=diff
==============================================================================
--- branches/REL_2/doc/RELEASE-NOTES.txt (original)
+++ branches/REL_2/doc/RELEASE-NOTES.txt Wed Mar 20 19:25:47 2013
@@ -18,6 +18,7 @@
 [JOST-200] - Reduce memory usage of unit tests
 [JOST-201] - SAML1 and 2 base message encoders have incorrect selection logic in getEndpointURL()
 [JOST-203] - Head/body template injection for SAML binding templates
+[JOST-205] - MetadataProvider doesn't report error during refresh if the metadata file doesn't exist any more
 
 Changes in Release 2.5.3
 =============================================

Modified: branches/REL_2/pom.xml
URL: http://svn.shibboleth.net/view/java-opensaml2/branches/REL_2/pom.xml?rev=1632&r1=1631&r2=1632&view=diff
==============================================================================
--- branches/REL_2/pom.xml (original)
+++ branches/REL_2/pom.xml Wed Mar 20 19:25:47 2013
@@ -177,6 +177,11 @@
                     <artifactId>commons-logging</artifactId>
                 </exclusion>
             </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 

Modified: branches/REL_2/src/main/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProvider.java
URL: http://svn.shibboleth.net/view/java-opensaml2/branches/REL_2/src/main/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProvider.java?rev=1632&r1=1631&r2=1632&view=diff
==============================================================================
--- branches/REL_2/src/main/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProvider.java (original)
+++ branches/REL_2/src/main/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProvider.java Wed Mar 20 19:25:47 2013
@@ -87,17 +87,7 @@
      */
     protected void setMetadataFile(File file) throws MetadataProviderException {
 
-        if (!file.exists()) {
-            throw new MetadataProviderException("Give metadata file, " + file.getAbsolutePath() + " does not exist");
-        }
-
-        if (!file.isFile()) {
-            throw new MetadataProviderException("Give metadata file, " + file.getAbsolutePath() + " is not a file");
-        }
-
-        if (!file.canRead()) {
-            throw new MetadataProviderException("Give metadata file, " + file.getAbsolutePath() + " is not readable");
-        }
+        validateMetadataFile(file);
 
         metadataFile = file;
     }
@@ -139,6 +129,7 @@
     /** {@inheritDoc} */
     protected byte[] fetchMetadata() throws MetadataProviderException {
         try {
+            validateMetadataFile(metadataFile);
             DateTime metadataUpdateTime = new DateTime(metadataFile.lastModified(), ISOChronology.getInstanceUTC());
             if (getLastRefresh() == null || metadataUpdateTime.isAfter(getLastRefresh())) {
                 return inputstreamToByteArray(new FileInputStream(metadataFile));
@@ -151,4 +142,26 @@
             throw new MetadataProviderException(errMsg, e);
         }
     }
+    
+    /**
+     * Validate the basic properties of the specified metadata file, for example that it exists; 
+     * that it is a file; and that it is readable.
+     *
+     * @param file the file to evaluate
+     * @throws MetadataProviderException if file does not pass basic properties required of a metadata file
+     */
+    protected void validateMetadataFile(File file) throws MetadataProviderException {
+        if (!file.exists()) {
+            throw new MetadataProviderException("Metadata file '" + file.getAbsolutePath() + "' does not exist");
+        }
+
+        if (!file.isFile()) {
+            throw new MetadataProviderException("Metadata file '" + file.getAbsolutePath() + "' is not a file");
+        }
+
+        if (!file.canRead()) {
+            throw new MetadataProviderException("Metadata file '" + file.getAbsolutePath() + "' is not readable");
+        }
+    }
+
 }

Modified: branches/REL_2/src/test/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProviderTest.java
URL: http://svn.shibboleth.net/view/java-opensaml2/branches/REL_2/src/test/java/org/opensaml/saml2/metadata/provider/FilesystemMetadataProviderTest.java?rev=1632&r1=1631&r2=1632&view=diff

[... 133 lines stripped ...]


More information about the commits mailing list