1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.cadi;
\r
26 import java.io.IOException;
\r
27 import java.io.InputStream;
\r
30 * Various Environments require different logging mechanisms, or at least allow
\r
31 * for different ones. We need the Framework to be able to hook into any particular instance of logging
\r
32 * mechanism, whether it be a Logging Object within a Servlet Context, or a direct library like log4j.
\r
33 * This interface, therefore, allows maximum pluggability in a variety of different app styles.
\r
37 public interface Access {
\r
40 DEBUG(0x1), INFO(0x10), AUDIT(0x100), WARN(0x2000), ERROR(0x4000), INIT(0x8000),NONE(0XFFFF);
\r
41 private final int bit;
\r
47 public boolean inMask(int mask) {
\r
48 return (mask & bit) == bit;
\r
51 public int addToMask(int mask) {
\r
55 public int delFromMask(int mask) {
\r
59 public int toggle(int mask) {
\r
61 return delFromMask(mask);
\r
63 return addToMask(mask);
\r
68 public int maskOf() {
\r
70 for(Level l : values()) {
\r
71 if(ordinal()<l.ordinal()) {
\r
80 * Write a variable list of Object's text via the toString() method with appropriate space, etc.
\r
83 public void log(Level level, Object ... elements);
\r
86 * Printf mechanism for Access
\r
91 public void printf(Level level, String fmt, Object ... elements);
\r
94 * Check if message will log before constructing
\r
98 public boolean willLog(Level level);
\r
101 * Write the contents of an exception, followed by a variable list of Object's text via the
\r
102 * toString() method with appropriate space, etc.
\r
104 * The Loglevel is always "ERROR"
\r
108 public void log(Exception e, Object ... elements);
\r
111 * Set the Level to compare logging too
\r
113 public void setLogLevel(Level level);
\r
116 * It is important in some cases to create a class from within the same Classloader that created
\r
117 * Security Objects. Specifically, it's pretty typical for Web Containers to separate classloaders
\r
118 * so as to allow Apps with different dependencies.
\r
121 public ClassLoader classLoader();
\r
123 public String getProperty(String string, String def);
\r
125 public void load(InputStream is) throws IOException;
\r
128 * if "anytext" is true, then decryption will always be attempted. Otherwise, only if starts with
\r
133 * @throws IOException
\r
135 public String decrypt(String encrypted, boolean anytext) throws IOException;
\r
137 public static final Access NULL = new Access() {
\r
138 public void log(Level level, Object... elements) {
\r
142 public void printf(Level level, String fmt, Object... elements) {
\r
145 public void log(Exception e, Object... elements) {
\r
148 public ClassLoader classLoader() {
\r
149 return this.classLoader();
\r
152 public String getProperty(String string, String def) {
\r
156 public void load(InputStream is) throws IOException {
\r
159 public void setLogLevel(Level level) {
\r
162 public String decrypt(String encrypted, boolean anytext) throws IOException {
\r
167 public boolean willLog(Level level) {
\r