org.bouncycastle.est.Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpkix-fips Show documentation
Show all versions of bcpkix-fips Show documentation
The Bouncy Castle Java APIs for CMS, PKCS, EAC, TSP, CMP, CRMF, OCSP, S/MIME and certificate generation. The APIs are designed primarily to be used in conjunction with the BC FIPS provider. The APIs may also be used with other providers although if being used in a FIPS context it is the responsibility of the user to ensure that any other providers used are FIPS certified and used appropriately.
The newest version!
package org.bouncycastle.est;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import org.bouncycastle.asn1.est.AttrOrOID;
import org.bouncycastle.util.Strings;
class Utils
{
static AttrOrOID[] clone(AttrOrOID[] ids)
{
AttrOrOID[] tmp = new AttrOrOID[ids.length];
System.arraycopy(ids, 0, tmp, 0, ids.length);
return tmp;
}
static Set asKeySet(String propertyName)
{
Set set = new HashSet();
String p = fetchProperty(propertyName);
if (p != null)
{
StringTokenizer sTok = new StringTokenizer(p, ",");
while (sTok.hasMoreElements())
{
set.add(Strings.toLowerCase(sTok.nextToken()).trim());
}
}
return Collections.unmodifiableSet(set);
}
private static String fetchProperty(final String propertyName)
{
return (String)AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
return System.getProperty(propertyName);
}
});
}
}