summaryrefslogtreecommitdiffstats
path: root/pki/base/util/src/com/netscape
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/util/src/com/netscape')
-rw-r--r--pki/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java14
-rw-r--r--pki/base/util/src/com/netscape/cmsutil/util/Cert.java10
-rw-r--r--pki/base/util/src/com/netscape/cmsutil/util/Utils.java17
3 files changed, 26 insertions, 15 deletions
diff --git a/pki/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java b/pki/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
index 98b8a0bd1..92d0f7e55 100644
--- a/pki/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
+++ b/pki/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
@@ -114,7 +114,7 @@ import org.mozilla.jss.util.Base64OutputStream;
import org.mozilla.jss.util.Password;
import com.netscape.cmsutil.util.Cert;
-import com.netscape.osutil.OSUtil;
+import com.netscape.cmsutil.util.Utils;
public class CryptoUtil {
@@ -132,7 +132,7 @@ public class CryptoUtil {
try {
return "-----BEGIN CERTIFICATE-----\n"
// + mEncoder.encodeBuffer(cert.getEncoded())
- + OSUtil.BtoA(cert.getEncoded())
+ + Utils.base64encode(cert.getEncoded())
+ "-----END CERTIFICATE-----\n";
} catch (Exception e) {
}
@@ -319,7 +319,7 @@ public class CryptoUtil {
public static byte[] base64Decode(String s) throws IOException {
// BASE64Decoder base64 = new BASE64Decoder();
// byte[] d = base64.decodeBuffer(s);
- byte[] d = OSUtil.AtoB(s);
+ byte[] d = Utils.base64decode(s);
return d;
}
@@ -1155,7 +1155,7 @@ public class CryptoUtil {
PasswordConverter passConverter = new
PasswordConverter();
- byte[] encoded = com.netscape.osutil.OSUtil.AtoB(wrappedRecoveredKey);
+ byte[] encoded = Utils.base64decode(wrappedRecoveredKey);
ByteArrayInputStream inStream = new ByteArrayInputStream(encoded);
cInfo = (EncryptedContentInfo)
@@ -1163,7 +1163,7 @@ public class CryptoUtil {
byte[] decodedData = cInfo.decrypt(pass, passConverter);
- unwrappedData = com.netscape.osutil.OSUtil.BtoA(decodedData);
+ unwrappedData = Utils.base64encode(decodedData);
return unwrappedData;
}
@@ -1177,7 +1177,7 @@ public class CryptoUtil {
Cipher decryptor = token.getCipherContext(alg);
decryptor.initDecrypt(recoveryKey, IV);
byte[] unwrappedData = decryptor.doFinal(wrappedRecoveredKey);
- String unwrappedS = com.netscape.osutil.OSUtil.BtoA(unwrappedData);
+ String unwrappedS = Utils.base64encode(unwrappedData);
return unwrappedS;
}
@@ -1206,7 +1206,7 @@ public class CryptoUtil {
public static byte[] wrapSymmetricKey(CryptoManager manager, CryptoToken token, String transportCert,
SymmetricKey sk) throws CertificateEncodingException, TokenException, NoSuchAlgorithmException,
InvalidKeyException, InvalidAlgorithmParameterException {
- byte transport[] = com.netscape.osutil.OSUtil.AtoB(transportCert);
+ byte transport[] = Utils.base64decode(transportCert);
X509Certificate tcert = manager.importCACertPackage(transport);
KeyWrapper rsaWrap = token.getKeyWrapper(KeyWrapAlgorithm.RSA);
rsaWrap.initWrap(tcert.getPublicKey(), null);
diff --git a/pki/base/util/src/com/netscape/cmsutil/util/Cert.java b/pki/base/util/src/com/netscape/cmsutil/util/Cert.java
index b280a7600..3563f70c7 100644
--- a/pki/base/util/src/com/netscape/cmsutil/util/Cert.java
+++ b/pki/base/util/src/com/netscape/cmsutil/util/Cert.java
@@ -28,8 +28,6 @@ import netscape.security.x509.X509CertImpl;
import org.mozilla.jss.crypto.SignatureAlgorithm;
-import com.netscape.osutil.OSUtil;
-
public class Cert {
public static SignatureAlgorithm mapAlgorithmToJss(String algname) {
@@ -96,7 +94,7 @@ public class Cert {
mime64 = stripCertBrackets(mime64.trim());
String newval = normalizeCertStr(mime64);
// byte rawPub[] = mDecoder.decodeBuffer(newval);
- byte rawPub[] = OSUtil.AtoB(newval);
+ byte rawPub[] = Utils.base64decode(newval);
X509CertImpl cert = null;
try {
@@ -111,7 +109,7 @@ public class Cert {
mime64 = stripCertBrackets(mime64.trim());
String newval = normalizeCertStr(mime64);
// byte rawPub[] = mDecoder.decodeBuffer(newval);
- byte rawPub[] = OSUtil.AtoB(newval);
+ byte rawPub[] = Utils.base64decode(newval);
PKCS7 p7 = null;
try {
@@ -127,7 +125,7 @@ public class Cert {
mime64 = stripCRLBrackets(mime64.trim());
String newval = normalizeCertStr(mime64);
// byte rawPub[] = mDecoder.decodeBuffer(newval);
- byte rawPub[] = OSUtil.AtoB(newval);
+ byte rawPub[] = Utils.base64decode(newval);
X509CRL crl = null;
try {
@@ -141,7 +139,7 @@ public class Cert {
throws IOException {
mime64 = stripCRLBrackets(mime64.trim());
- byte rawPub[] = OSUtil.AtoB(mime64);
+ byte rawPub[] = Utils.base64decode(mime64);
X509CRL crl = null;
try {
diff --git a/pki/base/util/src/com/netscape/cmsutil/util/Utils.java b/pki/base/util/src/com/netscape/cmsutil/util/Utils.java
index 06892fd84..a1801785c 100644
--- a/pki/base/util/src/com/netscape/cmsutil/util/Utils.java
+++ b/pki/base/util/src/com/netscape/cmsutil/util/Utils.java
@@ -39,7 +39,11 @@ public class Utils {
* Checks if this is NT.
*/
public static boolean isNT() {
- return ((File.separator).equals("\\"));
+ return File.separator.equals("\\");
+ }
+
+ public static boolean isUnix() {
+ return File.separator.equals("/");
}
public static boolean exec(String cmd) {
@@ -251,11 +255,20 @@ public class Utils {
* there'll be trouble if the Vector contains something other
* than just Strings
*/
- public static String[] getStringArrayFromVector(Vector v) {
+ public static String[] getStringArrayFromVector(Vector<String> v) {
String s[] = new String[v.size()];
v.copyInto(s);
return s;
}
+ public static String base64encode(byte[] bytes) {
+ String string = com.netscape.osutil.OSUtil.BtoA(bytes);
+ return string;
+ }
+
+ public static byte[] base64decode(String string) {
+ byte[] bytes = com.netscape.osutil.OSUtil.AtoB(string);
+ return bytes;
+ }
}