|
1 | 1 | package queueit.security; |
2 | 2 |
|
| 3 | +import java.io.File; |
| 4 | +import java.io.IOException; |
3 | 5 | import java.util.Locale; |
4 | 6 | import java.io.UnsupportedEncodingException; |
5 | 7 | import java.net.URLEncoder; |
6 | 8 | import java.util.UUID; |
| 9 | +import java.util.jar.Attributes; |
| 10 | +import static java.util.jar.Attributes.Name.IMPLEMENTATION_VERSION; |
| 11 | +import java.util.jar.JarFile; |
| 12 | +import java.util.jar.Manifest; |
| 13 | +import java.util.logging.Level; |
| 14 | +import java.util.logging.Logger; |
7 | 15 | import java.util.regex.Matcher; |
8 | 16 | import java.util.regex.Pattern; |
9 | 17 | import javax.servlet.http.HttpServletRequest; |
@@ -241,9 +249,30 @@ private UriComponentsBuilder generateQueueUrl(Boolean sslEnabled, String domainA |
241 | 249 | uri.queryParam("l", encodedLayoutName); |
242 | 250 | } |
243 | 251 |
|
| 252 | + uri.queryParam("ver", "j" + getVersionNumber()); |
| 253 | + |
244 | 254 | return uri; |
245 | 255 | } |
246 | 256 |
|
| 257 | + private String getVersionNumber() { |
| 258 | + // Get jarfile url |
| 259 | + String jarUrl = Queue.class |
| 260 | + .getProtectionDomain().getCodeSource() |
| 261 | + .getLocation().getFile(); |
| 262 | + |
| 263 | + try { |
| 264 | + JarFile jar = new JarFile(new File(jarUrl)); |
| 265 | + |
| 266 | + Manifest manifest = jar.getManifest(); |
| 267 | + Attributes attributes = manifest.getMainAttributes(); |
| 268 | + |
| 269 | + return attributes.getValue(IMPLEMENTATION_VERSION); |
| 270 | + |
| 271 | + } catch (IOException ex) { |
| 272 | + return "unknown"; |
| 273 | + } |
| 274 | + } |
| 275 | + |
247 | 276 | private static String encodeURIComponent(String s) { |
248 | 277 | String result; |
249 | 278 |
|
|
0 commit comments