+++ /dev/null
-/*******************************************************************************\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.cadi.lur.aaf.test;\r
-\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.PrintStream;\r
-\r
-import org.onap.aaf.cadi.Access;\r
-import org.onap.aaf.cadi.Symm;\r
-import org.onap.aaf.cadi.config.Config;\r
-\r
-public class JU_TestAccess implements Access {\r
- private Symm symm;\r
- private PrintStream out;\r
-\r
- public JU_TestAccess(PrintStream out) {\r
- this.out = out;\r
- InputStream is = ClassLoader.getSystemResourceAsStream("cadi.properties");\r
- try {\r
- System.getProperties().load(is);\r
- } catch (IOException e) {\r
- e.printStackTrace(out);\r
- } finally {\r
- try {\r
- is.close();\r
- } catch (IOException e) {\r
- e.printStackTrace(out);\r
- }\r
- }\r
- \r
- String keyfile = System.getProperty(Config.CADI_KEYFILE);\r
- if(keyfile==null) {\r
- System.err.println("No " + Config.CADI_KEYFILE + " in Classpath");\r
- } else {\r
- try {\r
- is = new FileInputStream(keyfile);\r
- try {\r
- symm = Symm.obtain(is);\r
- } finally {\r
- is.close();\r
- }\r
- } catch (IOException e) {\r
- e.printStackTrace(out);\r
- }\r
- }\r
- \r
-\r
-\r
- }\r
- \r
- public void log(Level level, Object... elements) {\r
- boolean first = true;\r
- for(int i=0;i<elements.length;++i) {\r
- if(first)first = false;\r
- else out.print(' ');\r
- out.print(elements[i].toString());\r
- }\r
- out.println();\r
- }\r
-\r
- public void log(Exception e, Object... elements) {\r
- e.printStackTrace(out);\r
- log(Level.ERROR,elements);\r
- }\r
-\r
- public void setLogLevel(Level level) {\r
- \r
- }\r
-\r
- @Override\r
- public boolean willLog(Level level) {\r
- return true;\r
- }\r
-\r
- public ClassLoader classLoader() {\r
- return ClassLoader.getSystemClassLoader();\r
- }\r
-\r
- public String getProperty(String string, String def) {\r
- String rv = System.getProperty(string);\r
- return rv==null?def:rv;\r
- }\r
-\r
- public void load(InputStream is) throws IOException {\r
- \r
- }\r
-\r
- public String decrypt(String encrypted, boolean anytext) throws IOException {\r
- return (encrypted!=null && (anytext==true || encrypted.startsWith(Symm.ENC)))\r
- ? symm.depass(encrypted)\r
- : encrypted;\r
- }\r
-\r
- @Override\r
- public void printf(Level level, String fmt, Object... elements) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
-}\r