Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-05-13 14:48:27 +0000
committerThomas Watson2014-05-13 14:56:13 +0000
commit6b81e87c3e0e3b7458c86e86d68068a9bcec7573 (patch)
treeed63ca800049b018edcddfcfde20f9a6b9d4d5d6
parent6b031e9fe74e06f605f44e1decd4e6677e6ea66c (diff)
downloadrt.equinox.framework-6b81e87c3e0e3b7458c86e86d68068a9bcec7573.tar.gz
rt.equinox.framework-6b81e87c3e0e3b7458c86e86d68068a9bcec7573.tar.xz
rt.equinox.framework-6b81e87c3e0e3b7458c86e86d68068a9bcec7573.zip
Bug 434711 - SignatureBlockProcessor can't handle special characters in
filenames - Use UTF-8 Charset for all string constructions Change-Id: If71a21be27682249d290605fb3040dc186be20d3 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java15
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java5
4 files changed, 16 insertions, 12 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java
index 902cd8bf4..48ab73208 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/BERProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others.
+ * Copyright (c) 2006, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -216,7 +216,7 @@ public class BERProcessor {
* @return the content from the current structure as a String.
*/
public String getString() {
- return new String(buffer, contentOffset, contentLength);
+ return new String(buffer, contentOffset, contentLength, SignedContentConstants.UTF8);
}
/**
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java
index 7650083bd..eed079e5e 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/PKCS7Processor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2006, 2014 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -194,7 +194,7 @@ public class PKCS7Processor implements SignedContentConstants {
eContentBER.stepOver();
// check time ends w/ 'Z'
- String dateString = new String(eContentBER.getBytes());
+ String dateString = new String(eContentBER.getBytes(), SignedContentConstants.UTF8);
if (!dateString.endsWith("Z")) //$NON-NLS-1$
throw new SignatureException("Wrong dateformat used in time-stamp token"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java
index bed2258dc..2d01cb18c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignatureBlockProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2007, 2014 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -8,7 +8,8 @@
******************************************************************************/
package org.eclipse.osgi.internal.signedcontent;
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
@@ -127,7 +128,7 @@ public class SignatureBlockProcessor implements SignedContentConstants {
*/
private void verifyManifestAndSignatureFile(byte[] manifestBytes, byte[] sfBytes) throws SignatureException {
- String sf = new String(sfBytes);
+ String sf = new String(sfBytes, SignedContentConstants.UTF8);
sf = stripContinuations(sf);
// check if there -Digest-Manfiest: header in the file
@@ -162,9 +163,9 @@ public class SignatureBlockProcessor implements SignedContentConstants {
}
}
- private void populateMDResults(byte mfBuf[], SignerInfo signerInfo) throws NoSuchAlgorithmException, UnsupportedEncodingException {
+ private void populateMDResults(byte mfBuf[], SignerInfo signerInfo) throws NoSuchAlgorithmException {
// need to make a string from the MF file data bytes
- String mfStr = new String(mfBuf, "UTF-8"); //$NON-NLS-1$
+ String mfStr = new String(mfBuf, SignedContentConstants.UTF8);
// start parsing each entry in the MF String
int entryStartOffset = mfStr.indexOf(MF_ENTRY_NEWLN_NAME);
@@ -306,7 +307,7 @@ public class SignatureBlockProcessor implements SignedContentConstants {
* Returns the Base64 encoded digest of the passed set of bytes.
*/
private static String calculateDigest(MessageDigest digest, byte[] bytes) {
- return new String(Base64.encode(digest.digest(bytes)));
+ return new String(Base64.encode(digest.digest(bytes)), SignedContentConstants.UTF8);
}
synchronized MessageDigest getMessageDigest(String algorithm) {
@@ -327,7 +328,7 @@ public class SignatureBlockProcessor implements SignedContentConstants {
*/
private static String getDigAlgFromSF(byte SFBuf[]) {
// need to make a string from the MF file data bytes
- String mfStr = new String(SFBuf);
+ String mfStr = new String(SFBuf, SignedContentConstants.UTF8);
String entryStr = null;
// start parsing each entry in the MF String
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java
index 352809ee5..adc32ce30 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/signedcontent/SignedContentConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2006, 2014 IBM Corporation and others. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,6 +9,8 @@
package org.eclipse.osgi.internal.signedcontent;
+import java.nio.charset.Charset;
+
public interface SignedContentConstants {
public static final String SHA1_STR = "SHA1"; //$NON-NLS-1$
@@ -28,6 +30,7 @@ public interface SignedContentConstants {
public static final String META_INF = "META-INF/"; //$NON-NLS-1$
public static final String META_INF_MANIFEST_MF = "META-INF/MANIFEST.MF"; //$NON-NLS-1$
public static final String[] EMPTY_STRING = new String[0];
+ public static final Charset UTF8 = Charset.forName("UTF-8"); //$NON-NLS-1$
//
// following are variables and methods to cache the entries related data

Back to the top