+++ /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;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-\r
-/**\r
- * Various Environments require different logging mechanisms, or at least allow\r
- * for different ones. We need the Framework to be able to hook into any particular instance of logging\r
- * mechanism, whether it be a Logging Object within a Servlet Context, or a direct library like log4j.\r
- * This interface, therefore, allows maximum pluggability in a variety of different app styles. \r
- * \r
- *\r
- */\r
-public interface Access {\r
- // levels to use\r
- public enum Level {\r
- DEBUG(0x1), INFO(0x10), AUDIT(0x100), WARN(0x2000), ERROR(0x4000), INIT(0x8000),NONE(0XFFFF);\r
- private final int bit;\r
- \r
- Level(int ord) {\r
- bit = ord;\r
- }\r
- \r
- public boolean inMask(int mask) {\r
- return (mask & bit) == bit;\r
- }\r
- \r
- public int addToMask(int mask) {\r
- return mask | bit;\r
- }\r
-\r
- public int delFromMask(int mask) {\r
- return mask & ~bit;\r
- }\r
-\r
- public int toggle(int mask) {\r
- if(inMask(mask)) {\r
- return delFromMask(mask);\r
- } else {\r
- return addToMask(mask);\r
- }\r
- }\r
-\r
-\r
- public int maskOf() {\r
- int mask=0;\r
- for(Level l : values()) {\r
- if(ordinal()<l.ordinal()) {\r
- mask|=l.bit;\r
- }\r
- }\r
- return mask;\r
- }\r
- }\r
-\r
- /**\r
- * Write a variable list of Object's text via the toString() method with appropriate space, etc.\r
- * @param elements\r
- */\r
- public void log(Level level, Object ... elements);\r
-\r
- /**\r
- * Printf mechanism for Access\r
- * @param level\r
- * @param fmt\r
- * @param elements\r
- */\r
- public void printf(Level level, String fmt, Object ... elements);\r
- \r
- /** \r
- * Check if message will log before constructing\r
- * @param level\r
- * @return\r
- */\r
- public boolean willLog(Level level);\r
-\r
- /**\r
- * Write the contents of an exception, followed by a variable list of Object's text via the \r
- * toString() method with appropriate space, etc.\r
- * \r
- * The Loglevel is always "ERROR"\r
- * \r
- * @param elements\r
- */\r
- public void log(Exception e, Object ... elements);\r
- \r
- /**\r
- * Set the Level to compare logging too\r
- */\r
- public void setLogLevel(Level level);\r
- \r
- /**\r
- * It is important in some cases to create a class from within the same Classloader that created\r
- * Security Objects. Specifically, it's pretty typical for Web Containers to separate classloaders\r
- * so as to allow Apps with different dependencies. \r
- * @return\r
- */\r
- public ClassLoader classLoader();\r
-\r
- public String getProperty(String string, String def);\r
- \r
- public void load(InputStream is) throws IOException;\r
-\r
- /**\r
- * if "anytext" is true, then decryption will always be attempted. Otherwise, only if starts with \r
- * Symm.ENC\r
- * @param encrypted\r
- * @param anytext\r
- * @return\r
- * @throws IOException\r
- */\r
- public String decrypt(String encrypted, boolean anytext) throws IOException;\r
-\r
- public static final Access NULL = new Access() {\r
- public void log(Level level, Object... elements) {\r
- }\r
-\r
- @Override\r
- public void printf(Level level, String fmt, Object... elements) {\r
- }\r
-\r
- public void log(Exception e, Object... elements) {\r
- }\r
-\r
- public ClassLoader classLoader() {\r
- return this.classLoader();\r
- }\r
-\r
- public String getProperty(String string, String def) {\r
- return null;\r
- }\r
-\r
- public void load(InputStream is) throws IOException {\r
- }\r
-\r
- public void setLogLevel(Level level) {\r
- }\r
-\r
- public String decrypt(String encrypted, boolean anytext) throws IOException {\r
- return encrypted;\r
- }\r
-\r
- @Override\r
- public boolean willLog(Level level) {\r
- return false;\r
- }\r
- };\r
-\r
-\r
-}\r