X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-certman%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fcm%2Ftest%2FCertmanTest.java;h=f23acd833ed948fbbfe3808fbe53aca81d304aea;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=a8f9934ae12b0080848c04fd176c9eeb421c275d;hpb=8206227ce04d26834a0023b4497d6b2ad67e906b;p=aaf%2Fauthz.git diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/CertmanTest.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/CertmanTest.java index a8f9934a..f23acd83 100644 --- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/CertmanTest.java +++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/test/CertmanTest.java @@ -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. @@ -18,149 +18,125 @@ * ============LICENSE_END==================================================== * */ -package org.onap.aaf.auth.cm.test; - -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.URI; -import java.security.cert.CertificateException; -import javax.security.auth.x500.X500Principal; +package org.onap.aaf.auth.cm.test; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Test; -import static org.junit.Assert.*; import org.onap.aaf.auth.env.AuthzEnv; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.Locator; -import org.onap.aaf.cadi.Locator.Item; -import org.onap.aaf.cadi.client.Future; -import org.onap.aaf.cadi.client.Rcli; -import org.onap.aaf.cadi.client.Retryable; -import org.onap.aaf.cadi.config.SecurityInfoC; -import org.onap.aaf.cadi.configure.Factory; import org.onap.aaf.cadi.http.HBasicAuthSS; import org.onap.aaf.cadi.http.HMangr; -import org.onap.aaf.cadi.locator.DNSLocator; -import org.onap.aaf.misc.env.APIException; -import org.onap.aaf.misc.env.Data; -import org.onap.aaf.misc.env.Data.TYPE; -import org.onap.aaf.misc.env.util.Chrono; import org.onap.aaf.misc.rosetta.env.RosettaDF; import certman.v1_0.CertInfo; import certman.v1_0.CertificateRequest; -import junit.framework.Assert; public class CertmanTest { - private static HMangr hman; - private static AuthzEnv env; - private static HBasicAuthSS ss; - private static RosettaDF reqDF; - private static RosettaDF certDF; + private static HMangr hman; + private static AuthzEnv env; + private static HBasicAuthSS ss; + private static RosettaDF reqDF; + private static RosettaDF certDF; - @BeforeClass - public static void setUpBeforeClass() throws Exception { - env = new AuthzEnv(); -// InputStream ris = env.classLoader().getResource("certman.props").openStream(); -// try { -// env.load(ris); -// } finally { -// ris.close(); -// } + @BeforeClass + public static void setUpBeforeClass() throws Exception { + env = new AuthzEnv(); +// InputStream ris = env.classLoader().getResource("certman.props").openStream(); +// try { +// env.load(ris); +// } finally { +// ris.close(); +// } +// +// Locator loc = new DNSLocator(env, "https", "aaf.it.att.com", "8150"); +// for (Item item = loc.first(); item!=null; item=loc.next(item)) { +// System.out.println(loc.get(item)); +// } +// // -// Locator loc = new DNSLocator(env, "https", "aaf.it.att.com", "8150"); -// for(Item item = loc.first(); item!=null; item=loc.next(item)) { -// System.out.println(loc.get(item)); -// } -// -// -// SecurityInfoC si = SecurityInfoC.instance(env, HttpURLConnection.class); -// ss = new HBasicAuthSS(si,"m12345@aaf.att.com", -// env.decrypt("enc:gvptdJyo0iKdVZw2rzMb0woxa7YKMdqLuhfQ4OQfZ8k",false)); -// env.decrypt("enc:jFfAnO3mOKb9Gzm2OFysslmXpbnyuAxuoNJK",false), si); -// SecuritySetter ss = new X509SS(si, "aaf"); - -// hman = new HMangr(env,loc); +// SecurityInfoC si = SecurityInfoC.instance(env, HttpURLConnection.class); +// ss = new HBasicAuthSS(si,"m12345@aaf.att.com", +// env.decrypt("enc:gvptdJyo0iKdVZw2rzMb0woxa7YKMdqLuhfQ4OQfZ8k",false)); +// env.decrypt("enc:jFfAnO3mOKb9Gzm2OFysslmXpbnyuAxuoNJK",false), si); +// SecuritySetter ss = new X509SS(si, "aaf"); + +// hman = new HMangr(env,loc); // -// reqDF = env.newDataFactory(CertificateRequest.class); -// reqDF.out(TYPE.JSON); -// certDF = env.newDataFactory(CertInfo.class); - } +// reqDF = env.newDataFactory(CertificateRequest.class); +// reqDF.out(TYPE.JSON); +// certDF = env.newDataFactory(CertInfo.class); + } -// @AfterClass -// public static void tearDownAfterClass() throws Exception { -// hman.close(); -// } +// @AfterClass +// public static void tearDownAfterClass() throws Exception { +// hman.close(); +// } - @Before - public void setUp() throws Exception { + @Before + public void setUp() throws Exception { - } + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } -// @Test -// public void testX500Name() throws Exception { -// -// for( InetAddress ia : InetAddress.getAllByName("aaf.dev.att.com")) { -// System.out.printf("%s - %s\n", ia.getHostName(), ia.getHostAddress()); -// InetAddress ia1 = InetAddress.getByName(ia.getHostAddress()); -// System.out.printf("%s - %s\n", ia1.getHostName(), ia1.getHostAddress()); -// } -// -// hman.best(ss, new Retryable() { -// @Override -// public Void code(Rcli client) throws APIException, CadiException { -// CertificateRequest cr = new CertificateRequest(); -// cr.setMechid("a12345@org.osaaf.org"); -// cr.setSponsor("something"); -// cr.getFqdns().add("mithrilcsp.sbc.com"); -// cr.getFqdns().add("zld01907.vci.att.com"); -// cr.getFqdns().add("aaftest.test.att.com"); -// -// String path = "/cert/local"; // Local Test -//// String path = "/cert/aaf"; // Official CA -// long end=0,start = System.nanoTime(); -// try { -// System.out.println(reqDF.newData().option(Data.PRETTY).load(cr).asString()); -// Future f = client.updateRespondString(path, reqDF, cr); -// if(f.get(10000)) { -// end = System.nanoTime(); -// System.out.println(f.body()); -// CertInfo capi = certDF.newData().in(Data.TYPE.JSON).load(f.body()).asObject(); -// for(String c :capi.getCerts()) { -// for( java.security.cert.Certificate x509 : Factory.toX509Certificate(c)) { -// System.out.println(x509.toString()); -// } -// } -// } else { -// end = System.nanoTime(); -// String msg = "Client returned " + f.code() + ": " + f.body(); -// System.out.println(msg); -// Assert.fail(msg); -// } -// } catch (CertificateException e) { -// throw new CadiException(e); -// } finally { -// System.out.println(Chrono.millisFromNanos(start,end) + " ms"); -// } -// return null; -// } -// }); -// -// -// } +// @Test +// public void testX500Name() throws Exception { +// +// for ( InetAddress ia : InetAddress.getAllByName("aaf.dev.att.com")) { +// System.out.printf("%s - %s\n", ia.getHostName(), ia.getHostAddress()); +// InetAddress ia1 = InetAddress.getByName(ia.getHostAddress()); +// System.out.printf("%s - %s\n", ia1.getHostName(), ia1.getHostAddress()); +// } +// +// hman.best(ss, new Retryable() { +// @Override +// public Void code(Rcli client) throws APIException, CadiException { +// CertificateRequest cr = new CertificateRequest(); +// cr.setMechid("a12345@org.osaaf.org"); +// cr.setSponsor("something"); +// cr.getFqdns().add("mithrilcsp.sbc.com"); +// cr.getFqdns().add("zld01907.vci.att.com"); +// cr.getFqdns().add("aaftest.test.att.com"); +// +// String path = "/cert/local"; // Local Test +//// String path = "/cert/aaf"; // Official CA +// long end=0,start = System.nanoTime(); +// try { +// System.out.println(reqDF.newData().option(Data.PRETTY).load(cr).asString()); +// Future f = client.updateRespondString(path, reqDF, cr); +// if (f.get(10000)) { +// end = System.nanoTime(); +// System.out.println(f.body()); +// CertInfo capi = certDF.newData().in(Data.TYPE.JSON).load(f.body()).asObject(); +// for (String c :capi.getCerts()) { +// for ( java.security.cert.Certificate x509 : Factory.toX509Certificate(c)) { +// System.out.println(x509.toString()); +// } +// } +// } else { +// end = System.nanoTime(); +// String msg = "Client returned " + f.code() + ": " + f.body(); +// System.out.println(msg); +// Assert.fail(msg); +// } +// } catch (CertificateException e) { +// throw new CadiException(e); +// } finally { +// System.out.println(Chrono.millisFromNanos(start,end) + " ms"); +// } +// return null; +// } +// }); // -// public X500Principal ephemeral() { -// return null; -// } - +// +// } +// +// public X500Principal ephemeral() { +// return null; +// } + }