diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-04-03 08:23:08 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2014-04-03 08:23:08 +0200 |
commit | 5cca5bacb14e284b6017ed293da7e3ee473bd5a8 (patch) | |
tree | f9d905033943329bf022fa0454139ef0ec9770a6 /id | |
parent | 84b05821944e2379d1cbe4259a8b83b163e2661c (diff) | |
download | moa-id-spss-5cca5bacb14e284b6017ed293da7e3ee473bd5a8.tar.gz moa-id-spss-5cca5bacb14e284b6017ed293da7e3ee473bd5a8.tar.bz2 moa-id-spss-5cca5bacb14e284b6017ed293da7e3ee473bd5a8.zip |
parse ConfigTool version from MANIFEST.MF
Diffstat (limited to 'id')
4 files changed, 67 insertions, 14 deletions
diff --git a/id/ConfigWebTool/pom.xml b/id/ConfigWebTool/pom.xml index 36fe03457..57aa5c794 100644 --- a/id/ConfigWebTool/pom.xml +++ b/id/ConfigWebTool/pom.xml @@ -139,18 +139,23 @@ <type>jar</type> <scope>compile</scope> </dependency> -<!-- <dependency> - <groupId>iaik</groupId> - <artifactId>commons-iaik</artifactId> - <version>0.7.1</version> - <exclusions> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - </exclusions> - </dependency> --> - </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>2.4</version> + <configuration> + <archive> + <manifestEntries> + <version>${project.version}</version> + </manifestEntries> + </archive> + </configuration> +</plugin> + </plugins> + </build> + </project> diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java index 513f046f1..69ac58d15 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/Constants.java @@ -22,13 +22,15 @@ *******************************************************************************/ package at.gv.egovernment.moa.id.configuration; -import java.util.Collection; import java.util.Hashtable; import java.util.Map; import edu.emory.mathcs.backport.java.util.Collections; public class Constants { + + public static final String DEFAULT_VERSION = "1.x"; + public static final String FILEPREFIX = "file:"; public static final String SERVLET_PVP2ASSERTION = "pvp2login.action"; diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java index e4cf5367d..e65163946 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java @@ -29,12 +29,15 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.net.URL; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.util.Properties; import java.util.Timer; +import java.util.jar.Attributes; +import java.util.jar.Manifest; import javax.servlet.http.HttpServletRequest; @@ -51,6 +54,7 @@ import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.auth.pvp2.MetaDataVerificationFilter; import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.utils.UserRequestCleaner; +import at.gv.egovernment.moa.id.protocols.pvp2x.config.PVPConfiguration; import at.gv.egovernment.moa.util.MiscUtil; @@ -445,6 +449,9 @@ public class ConfigurationProvider { return props.getProperty("general.mail.admin.adress"); } + public String getConfigToolVersion() { + return parseVersionFromManifest(); + } private void initalPVP2Login() throws ConfigurationException { try { @@ -480,6 +487,45 @@ public class ConfigurationProvider { } catch (Exception e) { log.warn("PVP2 authentification can not be initialized."); throw new ConfigurationException("PVP2 authentification can not be initialized.", e); + } + } + + private String parseVersionFromManifest() { + + + + try { + Class clazz = ConfigurationProvider.class; + String className = clazz.getSimpleName() + ".class"; + String classPath = clazz.getResource(className).toString(); + + if (classPath.startsWith("jar")) { + log.info("MOA-ID-Configuration Version can NOT parsed from Manifest. Set blank Version"); + return Constants.DEFAULT_VERSION; + + } + + String manifestPath = classPath.substring(0, classPath.lastIndexOf("WEB-INF/classes/") + "WEB-INF/classes/".length()) + + "../../META-INF/MANIFEST.MF"; + + Manifest manifest = new Manifest(new URL(manifestPath).openStream());; + + Attributes attributes = manifest.getMainAttributes(); + String version = attributes.getValue("version"); + + if (MiscUtil.isNotEmpty(version)) + return version; + + else { + log.info("MOA-ID-Configuration Version not found in Manifest. Set blank Version"); + return Constants.DEFAULT_VERSION; + + } + + } catch (Throwable e) { + log.info("MOA-ID Version can NOT parsed from Manifest. Set blank Version"); + + return Constants.DEFAULT_VERSION; } diff --git a/id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp b/id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp index 3f00984f2..e78319181 100644 --- a/id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp +++ b/id/ConfigWebTool/src/main/webapp/jsp/snippets/footer.jsp @@ -4,6 +4,6 @@ <html> <div id="footer_area"> - MOA-ID 2.x Konfigurations-Tool + MOA-ID Konfigurations-Tool (Version: <s:property value="ConfigToolVersion"/>) </div> </html>
\ No newline at end of file |