1 /*
2 * Copyright 2008 University Corporation for Advanced Internet Development, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package edu.internet2.middleware.shibboleth.idp;
18
19 /** Class for printing the version of this IdP. */
20 public final class Version {
21
22 /** Name of the IdP. */
23 private static final String NAME;
24
25 /** IdP version. */
26 private static final String VERSION;
27
28 /** IdP major version number. */
29 private static final int MAJOR_VERSION;
30
31 /** IdP minor version number. */
32 private static final int MINOR_VERSION;
33
34 /** IdP micro version number. */
35 private static final int MICRO_VERSION;
36
37 /** Constructor. */
38 private Version() {
39 }
40
41 /**
42 * Main entry point to program.
43 *
44 * @param args command line arguments
45 */
46 public static void main(String[] args) {
47 Package pkg = Version.class.getPackage();
48 System.out.println(NAME + " version " + VERSION);
49 }
50
51 /**
52 * Gets the name of the IdP.
53 *
54 * @return name of the IdP
55 */
56 public static String getName() {
57 return NAME;
58 }
59
60 /**
61 * Gets the version of the IdP.
62 *
63 * @return version of the IdP
64 */
65 public static String getVersion() {
66 return VERSION;
67 }
68
69 /**
70 * Gets the major version number of the IdP.
71 *
72 * @return major version number of the IdP
73 */
74 public static int getMajorVersion() {
75 return MAJOR_VERSION;
76 }
77
78 /**
79 * Gets the minor version number of the IdP.
80 *
81 * @return minor version number of the IdP
82 */
83 public static int getMinorVersion() {
84 return MINOR_VERSION;
85 }
86
87 /**
88 * Gets the micro version number of the IdP.
89 *
90 * @return micro version number of the IdP
91 */
92 public static int getMicroVersion() {
93 return MICRO_VERSION;
94 }
95
96 static {
97 Package pkg = Version.class.getPackage();
98 NAME = pkg.getImplementationTitle().intern();
99 VERSION = pkg.getImplementationVersion().intern();
100 String[] versionParts = VERSION.split(".");
101 MAJOR_VERSION = Integer.parseInt(versionParts[0]);
102 MINOR_VERSION = Integer.parseInt(versionParts[1]);
103 MICRO_VERSION = Integer.parseInt(versionParts[2]);
104 }
105 }