Update project structure to org.onap.aaf
[aaf/authz.git] / authz-certman / src / main / java / org / onap / aaf / authz / cm / data / CertResp.java
diff --git a/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertResp.java b/authz-certman/src/main/java/org/onap/aaf/authz/cm/data/CertResp.java
new file mode 100644 (file)
index 0000000..d06f63b
--- /dev/null
@@ -0,0 +1,66 @@
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.authz.cm.data;\r
+\r
+import java.io.IOException;\r
+import java.security.GeneralSecurityException;\r
+import java.security.KeyPair;\r
+import java.security.cert.X509Certificate;\r
+\r
+import org.onap.aaf.authz.cm.cert.CSRMeta;\r
+\r
+import org.onap.aaf.cadi.cm.CertException;\r
+import org.onap.aaf.cadi.cm.Factory;\r
+import org.onap.aaf.inno.env.Trans;\r
+\r
+public class CertResp {\r
+       public CertResp(Trans trans, X509Certificate x509, CSRMeta csrMeta, String[] notes) throws IOException, GeneralSecurityException, CertException {\r
+               keyPair = csrMeta.keypair(trans);\r
+               privateKey = Factory.toString(trans, keyPair.getPrivate());\r
+               certString = Factory.toString(trans,x509);\r
+               challenge=csrMeta.challenge();\r
+               this.notes = notes;\r
+       }\r
+       private KeyPair keyPair;\r
+       private String challenge;\r
+       \r
+       private String privateKey, certString;\r
+       private String[] notes;\r
+       \r
+       \r
+       public String asCertString() {\r
+               return certString;\r
+       }\r
+       \r
+       public String privateString() throws IOException {\r
+               return privateKey;\r
+       }\r
+       \r
+       public String challenge() {\r
+               return challenge==null?"":challenge;\r
+       }\r
+       \r
+       public String[] notes() {\r
+               return notes;\r
+       }\r
+}\r