2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.cm.test;
24 import org.junit.After;
25 import org.junit.Before;
26 import org.junit.BeforeClass;
27 import org.onap.aaf.auth.env.AuthzEnv;
28 import org.onap.aaf.cadi.http.HBasicAuthSS;
29 import org.onap.aaf.cadi.http.HMangr;
30 import org.onap.aaf.misc.rosetta.env.RosettaDF;
32 import certman.v1_0.CertInfo;
33 import certman.v1_0.CertificateRequest;
35 public class CertmanTest {
37 private static HMangr hman;
38 private static AuthzEnv env;
39 private static HBasicAuthSS ss;
40 private static RosettaDF<CertificateRequest> reqDF;
41 private static RosettaDF<CertInfo> certDF;
44 public static void setUpBeforeClass() throws Exception {
46 // InputStream ris = env.classLoader().getResource("certman.props").openStream();
53 // Locator<URI> loc = new DNSLocator(env, "https", "aaf.it.att.com", "8150");
54 // for (Item item = loc.first(); item!=null; item=loc.next(item)) {
55 // System.out.println(loc.get(item));
59 // SecurityInfoC<HttpURLConnection> si = SecurityInfoC.instance(env, HttpURLConnection.class);
60 // ss = new HBasicAuthSS(si,"m12345@aaf.att.com",
61 // env.decrypt("enc:gvptdJyo0iKdVZw2rzMb0woxa7YKMdqLuhfQ4OQfZ8k",false));
62 // env.decrypt("enc:jFfAnO3mOKb9Gzm2OFysslmXpbnyuAxuoNJK",false), si);
63 // SecuritySetter<HttpURLConnection> ss = new X509SS(si, "aaf");
65 // hman = new HMangr(env,loc);
67 // reqDF = env.newDataFactory(CertificateRequest.class);
68 // reqDF.out(TYPE.JSON);
69 // certDF = env.newDataFactory(CertInfo.class);
73 // public static void tearDownAfterClass() throws Exception {
78 public void setUp() throws Exception {
83 public void tearDown() throws Exception {
87 // public void testX500Name() throws Exception {
89 // for ( InetAddress ia : InetAddress.getAllByName("aaf.dev.att.com")) {
90 // System.out.printf("%s - %s\n", ia.getHostName(), ia.getHostAddress());
91 // InetAddress ia1 = InetAddress.getByName(ia.getHostAddress());
92 // System.out.printf("%s - %s\n", ia1.getHostName(), ia1.getHostAddress());
95 // hman.best(ss, new Retryable<Void>() {
97 // public Void code(Rcli<?> client) throws APIException, CadiException {
98 // CertificateRequest cr = new CertificateRequest();
99 // cr.setMechid("a12345@org.osaaf.org");
100 // cr.setSponsor("something");
101 // cr.getFqdns().add("mithrilcsp.sbc.com");
102 // cr.getFqdns().add("zld01907.vci.att.com");
103 // cr.getFqdns().add("aaftest.test.att.com");
105 // String path = "/cert/local"; // Local Test
106 //// String path = "/cert/aaf"; // Official CA
107 // long end=0,start = System.nanoTime();
109 // System.out.println(reqDF.newData().option(Data.PRETTY).load(cr).asString());
110 // Future<String> f = client.updateRespondString(path, reqDF, cr);
111 // if (f.get(10000)) {
112 // end = System.nanoTime();
113 // System.out.println(f.body());
114 // CertInfo capi = certDF.newData().in(Data.TYPE.JSON).load(f.body()).asObject();
115 // for (String c :capi.getCerts()) {
116 // for ( java.security.cert.Certificate x509 : Factory.toX509Certificate(c)) {
117 // System.out.println(x509.toString());
121 // end = System.nanoTime();
122 // String msg = "Client returned " + f.code() + ": " + f.body();
123 // System.out.println(msg);
126 // } catch (CertificateException e) {
127 // throw new CadiException(e);
129 // System.out.println(Chrono.millisFromNanos(start,end) + " ms");
138 // public X500Principal ephemeral() {