1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.client.test;
\r
25 import java.io.IOException;
\r
26 import java.io.InputStream;
\r
27 import java.io.PrintStream;
\r
28 import java.net.URI;
\r
29 import java.util.Properties;
\r
31 import org.onap.aaf.cadi.Access;
\r
32 import org.onap.aaf.cadi.Locator;
\r
33 import org.onap.aaf.cadi.Access.Level;
\r
34 import org.onap.aaf.cadi.Locator.Item;
\r
35 import org.onap.aaf.cadi.dme2.DME2Locator;
\r
37 import com.att.aft.dme2.api.DME2Manager;
\r
39 public class PaulUzee {
\r
40 public static void main(String[] args) {
\r
42 // You'll want to put this on Command line "-D" probably
\r
43 Properties props = System.getProperties();
\r
44 props.put("AFT_LATITUDE","32.780140");
\r
45 props.put("AFT_LONGITUDE","-96.800451");
\r
46 props.put("AFT_ENVIRONMENT","AFTPRD");
\r
49 // Use an "Access" class to hook up logging, properties, etc.
\r
50 // Make one that ties into your code's logging, property mechanism, etc.
\r
52 Access access = new PaulAccess();
\r
54 DME2Manager dm = new DME2Manager("Paul Uzee's Test",props);
\r
55 Locator loc = new DME2Locator(access ,dm,"com.att.authz.AuthorizationService","2.0","PROD","DEFAULT");
\r
58 for(Item item = loc.first(); item!=null; item=loc.next(item)) {
\r
59 URI location = (URI) loc.get(item);
\r
60 access.log(Level.INFO,location);
\r
61 access.log(Level.INFO,location.getScheme());
\r
62 access.log(Level.INFO,location.getHost());
\r
63 access.log(Level.INFO, location.getPort());
\r
65 } catch (Exception e) {
\r
66 e.printStackTrace();
\r
71 private static class PaulAccess implements Access {
\r
72 private Level willWrite = Level.INFO;
\r
75 public ClassLoader classLoader() {
\r
76 return getClass().getClassLoader();
\r
80 public String decrypt(String data, boolean def) throws IOException {
\r
85 public String getProperty(String tag, String def) {
\r
86 return System.getProperty(tag, def);
\r
90 public void load(InputStream is) throws IOException {
\r
91 System.getProperties().load(is);
\r
95 public void log(Level level, Object... obj) {
\r
96 if(level.compareTo(willWrite)<0) return;
\r
110 boolean first = true;
\r
111 for(Object o : obj) {
\r
112 if(first)first=false;
\r
113 else ps.print(' ');
\r
114 ps.print(o.toString());
\r
120 public void log(Exception e, Object... obj) {
\r
121 Object[] objs = new Object[obj.length+1];
\r
122 objs[0]=e.getMessage();
\r
123 System.arraycopy(objs, 1, obj, 0, obj.length);
\r
124 log(Level.ERROR,e,objs);
\r
128 public void setLogLevel(Level l) {
\r
133 * @see com.att.cadi.Access#willLog(com.att.cadi.Access.Level)
\r
136 public boolean willLog(Level level) {
\r
141 public void printf(Level level, String fmt, Object... elements) {
\r
142 // TODO Auto-generated method stub
\r