1 /*******************************************************************************
2 * ============LICENSE_START====================================================
4 * * ===========================================================================
5 * * Copyright © 2017 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====================================================
21 ******************************************************************************/
22 package org.onap.aaf.cadi.lur.aaf.test;
24 import java.io.FileInputStream;
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.io.PrintStream;
28 import java.util.Properties;
30 import org.onap.aaf.cadi.Access;
31 import org.onap.aaf.cadi.Symm;
32 import org.onap.aaf.cadi.config.Config;
34 public class JU_TestAccess implements Access {
36 private PrintStream out;
38 public JU_TestAccess(PrintStream out) {
40 InputStream is = ClassLoader.getSystemResourceAsStream("cadi.properties");
42 System.getProperties().load(is);
43 } catch (IOException e) {
44 e.printStackTrace(out);
48 } catch (IOException e) {
49 e.printStackTrace(out);
53 String keyfile = System.getProperty(Config.CADI_KEYFILE);
55 System.err.println("No " + Config.CADI_KEYFILE + " in Classpath");
58 is = new FileInputStream(keyfile);
60 symm = Symm.obtain(is);
64 } catch (IOException e) {
65 e.printStackTrace(out);
73 public void log(Level level, Object... elements) {
75 for(int i=0;i<elements.length;++i) {
76 if(first)first = false;
78 out.print(elements[i].toString());
83 public void log(Exception e, Object... elements) {
84 e.printStackTrace(out);
85 log(Level.ERROR,elements);
88 public void setLogLevel(Level level) {
93 public boolean willLog(Level level) {
97 public ClassLoader classLoader() {
98 return ClassLoader.getSystemClassLoader();
101 public String getProperty(String string, String def) {
102 String rv = System.getProperty(string);
103 return rv==null?def:rv;
107 public Properties getProperties() {
108 return System.getProperties();
111 public void load(InputStream is) throws IOException {
115 public String decrypt(String encrypted, boolean anytext) throws IOException {
116 return (encrypted!=null && (anytext==true || encrypted.startsWith(Symm.ENC)))
117 ? symm.depass(encrypted)
122 public void printf(Level level, String fmt, Object... elements) {
123 // TODO Auto-generated method stub