Remove Tabs, per Jococo
[aaf/authz.git] / auth / auth-batch / src / main / java / org / onap / aaf / auth / batch / helpers / X509.java
index 0ffaa8f..c68a994 100644 (file)
@@ -3,6 +3,8 @@
  * org.onap.aaf
  * ===========================================================================
  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright © 2018 IBM.
  * ===========================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +23,6 @@
 
 package org.onap.aaf.auth.batch.helpers;
 
-import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.security.cert.X509Certificate;
 import java.util.Iterator;
@@ -42,15 +43,18 @@ import com.datastax.driver.core.SimpleStatement;
 import com.datastax.driver.core.Statement;
 
 public class X509 {
-    public final String ca,id,x500,x509;
+    public final String ca;
+    public final String id;
+    public final String x500;
+    public final String x509;
     public ByteBuffer serial;
     
     public X509(String ca, String id, String x500, String x509, ByteBuffer serial) {
-       this.ca = ca;
-       this.id = id;
-       this.x500 = x500;
-       this.x509 = x509;
-       this.serial = serial;
+        this.ca = ca;
+        this.id = id;
+        this.x500 = x500;
+        this.x509 = x509;
+        this.serial = serial;
     }
     
 
@@ -77,7 +81,7 @@ public class X509 {
             tt = trans.start("Load X509s", Env.SUB);
             try {
                 while (iter.hasNext()) {
-                       ++count;
+                    ++count;
                     row = iter.next();
                     visitor.visit(new X509(row.getString(0),row.getString(1), row.getString(2),row.getString(3),row.getBytes(4)));
                 }
@@ -104,38 +108,48 @@ public class X509 {
     }
     
 
-       public void row(CSV.Writer cw, X509Certificate x509Cert) throws IOException {
-               cw.row("x509",ca,Hash.toHex(serial.array()),Chrono.dateOnlyStamp(x509Cert.getNotAfter()),x500);
-       }
-
-
-       public static void row(StringBuilder sb, List<String> row) throws IOException {
-       sb.append("DELETE from authz.x509 WHERE ca='");
-       sb.append(row.get(1));
-       sb.append("' AND serial=");
-       sb.append(row.get(2));
-       sb.append(";\n");
-       }
-
-
-       public static String histSubject(List<String> row) {
-               return row.get(4);
-       }
-
-
-       public static String histMemo(String fmt, List<String> row) {
-               String id="n/a";
-               for(String s : Split.splitTrim(',', row.get(4))) {
-                       if(s.startsWith("OU=") && s.indexOf('@')>=0) {
-                               int colon = s.indexOf(':');
-                               if(colon<0) {
-                                       colon=s.length();
-                               }
-                               id=s.substring(3,colon);
-                               break;
-                       }
-               }
-               return String.format(fmt, "Cert for " + id,"CA " + row.get(1),row.get(3));
-       }
+    public void row(CSV.Writer cw, X509Certificate x509Cert) {
+        cw.row("x509",ca,Hash.toHex(serial.array()),Chrono.dateOnlyStamp(x509Cert.getNotAfter()),x500);
+    }
+
+    public void row(CSV.Writer cw, X509Certificate x509Cert,String reason) {
+        cw.row("x509",ca,Hash.toHex(serial.array()),Chrono.dateOnlyStamp(x509Cert.getNotAfter()),x500,reason);
+    }
+
+
+    public static void row(StringBuilder sb, List<String> row) {
+        sb.append("DELETE from authz.x509 WHERE ca='");
+        sb.append(row.get(1));
+        sb.append("' AND serial=");
+        sb.append(row.get(2));
+        sb.append(";\n");
+    }
+
+    public static void batchDelete(StringBuilder sb, List<String> row) {
+        sb.append("DELETE from authz.x509 WHERE ca='");
+        sb.append(row.get(1));
+        sb.append("' AND serial=");
+        sb.append(row.get(2));
+        sb.append(";\n");
+    }
+    public static String histSubject(List<String> row) {
+        return row.get(4);
+    }
+
+
+    public static String histMemo(String fmt, List<String> row) {
+        String id="n/a";
+        for(String s : Split.splitTrim(',', row.get(4))) {
+            if(s.startsWith("OU=") && s.indexOf('@')>=0) {
+                int colon = s.indexOf(':');
+                if(colon<0) {
+                    colon=s.length();
+                }
+                id=s.substring(3,colon);
+                break;
+            }
+        }
+        return String.format(fmt, "Cert for " + id,"CA " + row.get(1),row.get(3));
+    }
 
 }
\ No newline at end of file