mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
[FIXED HUDSON-6459] Fix in 1.358 did not work because exception thrown
when Cipher is used, not when it is created. Refactor to use a system property to force a particular provider, so Glassfish Enterprise users can workaround this glassfish bug until it is fixed. In 1.360. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@31455 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
c4f6034a11
commit
cb65e33c6b
1 file changed
+11
-6
@@ -144,14 +144,13 @@ public final class Secret {
|
||||
|
||||
/**
|
||||
* Workaround for HUDSON-6459 / https://glassfish.dev.java.net/issues/show_bug.cgi?id=11862 .
|
||||
* Falls back to "SunJCE" provider if unable to get the Cipher from the default provider.
|
||||
* This method uses specific provider selected via hudson.util.Secret.provider system property
|
||||
* to provide a workaround for the above bug where default provide gives an unusable instance.
|
||||
* (Glassfish Enterprise users should set value of this property to "SunJCE")
|
||||
*/
|
||||
public static Cipher getCipher(String algorithm) throws GeneralSecurityException {
|
||||
try {
|
||||
return Cipher.getInstance(algorithm);
|
||||
} catch (Exception e) {
|
||||
return Cipher.getInstance(algorithm, "SunJCE");
|
||||
}
|
||||
return PROVIDER != null ? Cipher.getInstance(algorithm, PROVIDER)
|
||||
: Cipher.getInstance(algorithm);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,6 +198,12 @@ public final class Secret {
|
||||
|
||||
private static final String MAGIC = "::::MAGIC::::";
|
||||
|
||||
/**
|
||||
* Workaround for HUDSON-6459 / https://glassfish.dev.java.net/issues/show_bug.cgi?id=11862 .
|
||||
* @see #getCipher(String)
|
||||
*/
|
||||
private static final String PROVIDER = System.getProperty(Secret.class.getName()+".provider");
|
||||
|
||||
/**
|
||||
* For testing only. Override the secret key so that we can test this class without {@link Hudson}.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user