serial = new BigInteger(64,random);
- if(params.length<1 || params[0].length<2) {
+ if (params.length<1 || params[0].length<2) {
throw new IOException("LocalCA expects cm_ca.<ca name>=org.onap.aaf.auth.cm.ca.LocalCA,<full path to key file>[;<Full Path to Trust Chain, ending with actual CA>]+");
}
// Read in the Private Key
String configured;
File f = new File(params[0][0]);
- if(f.exists() && f.isFile()) {
+ if (f.exists() && f.isFile()) {
String fileName = f.getName();
- if(fileName.endsWith(".key")) {
+ if (fileName.endsWith(".key")) {
caKey = Factory.toPrivateKey(NullTrans.singleton(),f);
List<FileReader> frs = new ArrayList<>(params.length-1);
try {
String dir = access.getProperty(CM_PUBLIC_DIR, "");
- if(!"".equals(dir) && !dir.endsWith("/")) {
+ if (!"".equals(dir) && !dir.endsWith("/")) {
dir = dir + '/';
}
String path;
- for(int i=1; i<params[0].length; ++i) { // first param is Private Key, remainder are TrustChain
+ for (int i=1; i<params[0].length; ++i) { // first param is Private Key, remainder are TrustChain
path = !params[0][i].contains("/")?dir+params[0][i]:params[0][i];
access.printf(Level.INIT, "Loading a TrustChain Member for %s from %s\n",name, path);
frs.add(new FileReader(path));
}
x509cwi = new X509ChainWithIssuer(frs);
} finally {
- for(FileReader fr : frs) {
- if(fr!=null) {
+ for (FileReader fr : frs) {
+ if (fr!=null) {
fr.close();
}
}
}
configured = "Configured with " + fileName;
} else {
- if(params.length<1 || params[0].length<3) {
+ if (params.length<1 || params[0].length<3) {
throw new CertException("LocalCA parameters must be <keystore [.p12|.pkcs12|.jks|.pkcs11(sun only)]; <alias>; enc:<encrypted Keystore Password>>");
}
try {
Provider p;
KeyStore keyStore;
FileInputStream fis = null;
- if(fileName.endsWith(".pkcs11")) {
+ if (fileName.endsWith(".pkcs11")) {
String ksType="PKCS11";
p = Factory.getSecurityProvider(ksType,params);
keyStore = KeyStore.getInstance(ksType,p);
- } else if(fileName.endsWith(".jks")) {
+ } else if (fileName.endsWith(".jks")) {
keyStore = KeyStore.getInstance("JKS");
fis = new FileInputStream(f);
- } else if(fileName.endsWith(".p12") || fileName.endsWith(".pkcs12")) {
+ } else if (fileName.endsWith(".p12") || fileName.endsWith(".pkcs12")) {
keyStore = KeyStore.getInstance("PKCS12");
fis = new FileInputStream(f);
} else {
try {
String pass = access.decrypt(params[0][2]/*encrypted passcode*/, true);
- if(pass==null) {
+ if (pass==null) {
throw new CertException("Passcode for " + fileName + " cannot be decrypted.");
}
char[] ksPass = pass.toCharArray();
fis.close();
}
Entry entry;
- if(fileName.endsWith(".pkcs11")) {
+ if (fileName.endsWith(".pkcs11")) {
entry = keyStore.getEntry(params[0][1]/*alias*/, null);
} else {
entry = keyStore.getEntry(params[0][1]/*alias*/, keyPass);
}
- if(entry==null) {
+ if (entry==null) {
throw new CertException("There is no Keystore entry with name '" + params[0][1] +'\'');
}
PrivateKeyEntry privateKeyEntry = (PrivateKeyEntry)entry;
X500NameBuilder xnb = new X500NameBuilder();
List<RDN> rp = RDN.parse(',', x509cwi.getIssuerDN());
Collections.reverse(rp);
- for(RDN rnd : rp) {
+ for (RDN rnd : rp) {
xnb.addRDN(rnd.aoi,rnd.value);
}
issuer = xnb.build();
// new SubjectPublicKeyInfo(ASN1Sequence.getInstance(caCert.getPublicKey().getEncoded()))
);
List<GeneralName> lsan = new ArrayList<>();
- for(String s : csrmeta.sans()) {
+ for (String s : csrmeta.sans()) {
lsan.add(new GeneralName(GeneralName.dNSName,s));
}
GeneralName[] sans = new GeneralName[lsan.size()];