Added dynamic boundary.
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.math.BigInteger;
+import java.security.SecureRandom;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -180,7 +182,7 @@ public SMIMESignedWriter build(OutputStream mimeOut)
}
else
{
- boundary = "=----F64236F869294814A5429491E2A0401B";
+ boundary = generateBoundary();
// handle Content-Type specially
StringBuffer contValue = new StringBuffer(detValues[0]);
@@ -277,6 +279,13 @@ private void addBoundary(
header.append(boundary);
header.append("\"");
}
+
+ private String generateBoundary()
+ {
+ SecureRandom random = new SecureRandom();
+
+ return "==" + new BigInteger(180, random).setBit(179).toString(16) + "=";
+ }
}
private final CMSSignedDataStreamGenerator sigGen;
