Skip to content

Commit

Permalink
portability updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Jul 20, 2014
1 parent 093053a commit a10aa6b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
16 changes: 16 additions & 0 deletions core/src/test/java/org/bouncycastle/math/ec/test/AllTests.java
@@ -1,5 +1,9 @@
package org.bouncycastle.math.ec.test;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

import junit.framework.Test;
import junit.framework.TestSuite;

Expand All @@ -21,4 +25,16 @@ public static Test suite()

return suite;
}

static List enumToList(Enumeration en)
{
List rv = new ArrayList();

while (en.hasMoreElements())
{
rv.add(en.nextElement());
}

return rv;
}
}
Expand Up @@ -3,15 +3,13 @@
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.bouncycastle.asn1.x9.ECNamedCurveTable;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.ec.CustomNamedCurves;
Expand Down Expand Up @@ -119,8 +117,8 @@ private BigInteger getRandomScalar(X9ECParameters x9)
private ArrayList getTestCurves()
{
ArrayList x9s = new ArrayList();
Set names = new HashSet(Collections.list(ECNamedCurveTable.getNames()));
names.addAll(Collections.list(CustomNamedCurves.getNames()));
Set names = new HashSet(AllTests.enumToList(ECNamedCurveTable.getNames()));
names.addAll(AllTests.enumToList(CustomNamedCurves.getNames()));

Iterator it = names.iterator();
while (it.hasNext())
Expand Down
Expand Up @@ -2,11 +2,8 @@

import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
Expand Down Expand Up @@ -176,8 +173,8 @@ private double randMult(SecureRandom random, ECPoint g, BigInteger n) throws Exc

public void testMultiply() throws Exception
{
SortedSet names = new TreeSet(enumToList(ECNamedCurveTable.getNames()));
names.addAll(enumToList(CustomNamedCurves.getNames()));
SortedSet names = new TreeSet(AllTests.enumToList(ECNamedCurveTable.getNames()));
names.addAll(AllTests.enumToList(CustomNamedCurves.getNames()));

Set oids = new HashSet();

Expand All @@ -198,16 +195,4 @@ public void testMultiply() throws Exception
randMult(name);
}
}

private List enumToList(Enumeration en)
{
List rv = new ArrayList();

while (en.hasMoreElements())
{
rv.add(en.nextElement());
}

return rv;
}
}
Expand Up @@ -43,7 +43,7 @@ public class SMIMECompressedGenerator
mc.addMailcap("application/pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.pkcs7_mime");
mc.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");

AccessController.doPrivileged(new PrivilegedAction<Object>()
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
Expand Down
Expand Up @@ -72,7 +72,7 @@ public class SMIMEEnvelopedGenerator

static
{
AccessController.doPrivileged(new PrivilegedAction<Object>()
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
Expand Down
Expand Up @@ -90,7 +90,7 @@ private static InputStream getInputStream(
mc.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");
mc.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed");

AccessController.doPrivileged(new PrivilegedAction<Object>()
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
Expand Down
Expand Up @@ -119,7 +119,7 @@ private static MailcapCommandMap addCommands(CommandMap cm)

static
{
AccessController.doPrivileged(new PrivilegedAction<Object>()
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
Expand Down
Expand Up @@ -133,7 +133,7 @@ private static CMSTypedStream getSignedInputStream(
mc.addMailcap("application/x-pkcs7-mime;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.x_pkcs7_mime");
mc.addMailcap("multipart/signed;; x-java-content-handler=org.bouncycastle.mail.smime.handlers.multipart_signed");

AccessController.doPrivileged(new PrivilegedAction<Object>()
AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
Expand Down

0 comments on commit a10aa6b

Please sign in to comment.