package org.jasig.cas;

import org.jasig.cas.util.DateTimeUtils;

import java.io.File;
import java.net.URL;
import java.time.ZonedDateTime;

/**
 * Class that exposes the CAS version. Fetches the "Implementation-Version"
 * manifest attribute from the jar file.
 *
 * @author Dmitriy Kopylenko
 * @since 3.0.0
 */
public final class CasVersion {

    /**
     * Private constructor for CasVersion. You should not be able to instantiate
     * this class.
     */
    private CasVersion() {
        // this class is not instantiable
    }

    /**
     * @return Return the full CAS version string.
     * @see java.lang.Package#getImplementationVersion
     */
    public static String getVersion() {
        return CasVersion.class.getPackage().getImplementationVersion();
    }

    /**
     * Gets last modified date/time for the module.
     * @return the date/time
     */
    public static ZonedDateTime getDateTime() {
        try {
            final Class clazz = CasVersion.class;
            final URL resource = clazz.getResource(clazz.getSimpleName() + ".class");
            if ("file".equals(resource.getProtocol())) {
                return DateTimeUtils.zonedDateTimeOf(new File(resource.toURI()).lastModified());
            } else if ("jar".equals(resource.getProtocol())) {
                final String path = resource.getPath();
                final File file = new File(path.substring(5, path.indexOf('!')));
                return DateTimeUtils.zonedDateTimeOf(file.lastModified());
            }
            throw new IllegalArgumentException("Unhandled url protocol: "
                        + resource.getProtocol() + " for class: "
                        + clazz.getName() + " resource: " + resource);
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }
}

@@ -57,16 +57,121 @@
 meUtils;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.core.io.VfsResource;
 %0A%0Aimport
@@ -444,16 +444,98 @@
 rsion %7B%0A
+    private static Logger LOGGER = LoggerFactory.getLogger(CasVersion.class);%0A    
 %0A    /**
@@ -1256,16 +1256,29 @@
 lass%22);%0A
+            %0A
         
@@ -1440,13 +1440,33 @@
    %7D
- else
+%0A            %0A           
  if 
@@ -1724,32 +1724,33 @@
 );%0A            %7D
+ 
 %0A            thr
@@ -1750,69 +1750,224 @@
     
-throw new IllegalArgumentException(%22Unhandled url protocol: %22
+%0A            if (%22vfs%22.equals(resource.getProtocol())) %7B%0A                final File file = new VfsResource(resource).getFile();%0A                return DateTimeUtils.zonedDateTimeOf(file.lastModified());%0A            %7D
 %0A   
@@ -1967,32 +1967,33 @@
   %7D%0A            
+%0A
             + re
@@ -1992,36 +1992,47 @@
     
-+ resource.getP
+LOGGER.warn(%22Unhandled url p
 rotocol
-() + %22
+: %7B%7D
  for
@@ -2043,80 +2043,161 @@
 ss: 
-%22%0A                        + clazz.getName() + %22 resource: %22 + resource);
+%7B%7D and resource: %7B%7D%22, resource.getProtocol(),%0A                    resource.getProtocol(), resource);%0A            return ZonedDateTime.now();%0A            
 %0A   

Handle vfs resource when checking for cas date/time