Fix Agent and CM Issues
[aaf/authz.git] / auth / auth-certman / src / main / java / org / onap / aaf / auth / cm / cert / BCFactory.java
index 8edfa63..9715422 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -47,7 +47,7 @@ import org.onap.aaf.misc.env.Trans;
 /**
  * Additional Factory mechanisms for CSRs, and BouncyCastle.  The main Factory
  * utilizes only Java abstractions, and is useful in Client code.
- * 
+ *
  * @author JonathanGathman
  *
  */
@@ -59,13 +59,13 @@ public class BCFactory extends Factory {
         // Bouncy
         jcsb = new JcaContentSignerBuilder(Factory.SIG_ALGO);
     }
-    
+
     public static ContentSigner contentSigner(PrivateKey pk) throws OperatorCreationException {
         return jcsb.build(pk);
     }
-    
+
     public static String toString(PKCS10CertificationRequest csr) throws IOException, CertException {
-        if(csr==null) {
+        if (csr==null) {
             throw new CertException("x509 Certificate Request not built");
         }
         return textBuilder("CERTIFICATE REQUEST",csr.getEncoded());
@@ -89,32 +89,32 @@ public class BCFactory extends Factory {
             tt.done();
         }
     }
-    
+
     public static CSRMeta createCSRMeta(CA ca, String mechid, String sponsorEmail, List<String> fqdns) throws CertException {
         CSRMeta csr = ca.newCSRMeta();
         boolean first = true;
         // Set CN (and SAN)
-        for(String fqdn : fqdns) {
-            if(first) {
+        for (String fqdn : fqdns) {
+            if (first) {
                 first = false;
                 csr.cn(fqdn);
             }
-            csr.san(fqdn); // duplicate CN in SAN, per RFC 5280 section 4.2.1.6 
+            csr.san(fqdn); // duplicate CN in SAN, per RFC 5280 section 4.2.1.6
         }
-        
+
         csr.challenge(new String(Symm.randomGen(24)));
         csr.mechID(mechid);
         csr.email(sponsorEmail);
         String errs;
-        if((errs=validateApp(csr))!=null) {
+        if ((errs=validateApp(csr))!=null) {
             throw new CertException(errs);
         }
         return csr;
     }
-    
+
     private static String validateApp(CSRMeta csr) {
         CertmanValidator v = new CertmanValidator();
-        if(v.nullOrBlank("cn", csr.cn())
+        if (v.nullOrBlank("cn", csr.cn())
             .nullOrBlank("mechID", csr.mechID())
 //            .nullOrBlank("email", csr.email())
             .err()) {
@@ -130,7 +130,7 @@ public class BCFactory extends Factory {
         csr.challenge(new String(Symm.randomGen(24)));
         csr.email(email);
         String errs;
-        if((errs=validatePersonal(csr))!=null) {
+        if ((errs=validatePersonal(csr))!=null) {
             throw new CertException(errs);
         }
         return csr;
@@ -138,7 +138,7 @@ public class BCFactory extends Factory {
 
     private static String validatePersonal(CSRMeta csr) {
         CertmanValidator v = new CertmanValidator();
-        if(v.nullOrBlank("cn", csr.cn())
+        if (v.nullOrBlank("cn", csr.cn())
             .nullOrBlank("email", csr.email())
             .err()) {
             return v.errs();
@@ -146,6 +146,6 @@ public class BCFactory extends Factory {
             return null;
         }
     }
-    
+
 
 }