You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by vi...@apache.org on 2004/08/08 18:16:36 UTC
cvs commit: james-server/src/java/org/apache/james/transport/mailets SMIMEAbstractSign.java
vincenzo 2004/08/08 09:16:35
Modified: src/java/org/apache/james/security Tag: branch_2_1_fcs
KeyHolder.java
src/java/org/apache/james/transport/mailets Tag:
branch_2_1_fcs SMIMEAbstractSign.java
Log:
Removed all dependencies from JDK 1.4.
Revision Changes Path
No revision
No revision
1.1.2.2 +5 -5 james-server/src/java/org/apache/james/security/KeyHolder.java
Index: KeyHolder.java
===================================================================
RCS file: /home/cvs/james-server/src/java/org/apache/james/security/KeyHolder.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- KeyHolder.java 5 Aug 2004 12:30:48 -0000 1.1.2.1
+++ KeyHolder.java 8 Aug 2004 16:16:35 -0000 1.1.2.2
@@ -27,11 +27,11 @@
import org.bouncycastle.mail.smime.*;
/* the following 3 imports are needed if support for both jdk 1.3 and jdk 1.4+ is needed */
-//import java.security.cert.X509Certificate; // needed if jdk 1.3+, not needed if jdk 1.4+
-//import org.bouncycastle.jce.*; // needed for jdk 1.3
-//import org.bouncycastle.jce.cert.*; // needed for jdk 1.3
+import java.security.cert.X509Certificate; // needed if jdk 1.3+, not needed if jdk 1.4+
+import org.bouncycastle.jce.*; // needed for jdk 1.3
+import org.bouncycastle.jce.cert.*; // needed for jdk 1.3
/* the following import should be used instead of the 3 above if no support for jdk 1.3 is needed, but only for jdk 1.4+ */
-import java.security.cert.*;
+//import java.security.cert.*;
import org.bouncycastle.mail.smime.*;
No revision
No revision
1.1.2.2 +21 -13 james-server/src/java/org/apache/james/transport/mailets/SMIMEAbstractSign.java
Index: SMIMEAbstractSign.java
===================================================================
RCS file: /home/cvs/james-server/src/java/org/apache/james/transport/mailets/SMIMEAbstractSign.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- SMIMEAbstractSign.java 5 Aug 2004 12:30:49 -0000 1.1.2.1
+++ SMIMEAbstractSign.java 8 Aug 2004 16:16:35 -0000 1.1.2.2
@@ -654,31 +654,39 @@
protected final String getReplacedExplanationText(String explanationText, String signerName,
String signerAddress, String reversePath, String headers) {
- StringBuffer replacedExplanationText = new StringBuffer(explanationText);
+ String replacedExplanationText = explanationText;
- replaceTemplate(replacedExplanationText, SIGNER_NAME_PATTERN, signerName);
- replaceTemplate(replacedExplanationText, SIGNER_ADDRESS_PATTERN, signerAddress);
- replaceTemplate(replacedExplanationText, REVERSE_PATH_PATTERN, reversePath);
- replaceTemplate(replacedExplanationText, HEADERS_PATTERN, headers);
+ replacedExplanationText = getReplacedString(replacedExplanationText, SIGNER_NAME_PATTERN, signerName);
+ replacedExplanationText = getReplacedString(replacedExplanationText, SIGNER_ADDRESS_PATTERN, signerAddress);
+ replacedExplanationText = getReplacedString(replacedExplanationText, REVERSE_PATH_PATTERN, reversePath);
+ replacedExplanationText = getReplacedString(replacedExplanationText, HEADERS_PATTERN, headers);
- return replacedExplanationText.toString();
+ return replacedExplanationText;
}
/**
- * Searches the <I>template</I> StringBuffer for all occurrences of the <I>pattern</I> string
- * and substitutes them with the <I>actual</I> string.
- * Requires jdk 1.4+.
- * @param template The template StringBuffer to work on.
+ * Searches the <I>template</I> String for all occurrences of the <I>pattern</I> string
+ * and creates a new String substituting them with the <I>actual</I> String.
+ * @param template The template String to work on.
* @param pattern The string to search for the replacement.
* @param actual The actual string to use for the replacement.
*/
- private void replaceTemplate(StringBuffer template, String pattern, String actual) {
+ private String getReplacedString(String template, String pattern, String actual) {
if (actual != null) {
+ StringBuffer sb = new StringBuffer(template.length());
int fromIndex = 0;
int index;
while ((index = template.indexOf(pattern, fromIndex)) >= 0) {
- template.replace(index, index + pattern.length(), actual);
+ sb.append(template.substring(fromIndex, index));
+ sb.append(actual);
+ fromIndex = index + pattern.length();
}
+ if (fromIndex < template.length()){
+ sb.append(template.substring(fromIndex));
+ }
+ return sb.toString();
+ } else {
+ return new String(template);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org