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 com.att.cadi;
\r
25 import java.io.IOException;
\r
26 import java.io.InputStream;
\r
29 * Various Environments require different logging mechanisms, or at least allow
\r
30 * for different ones. We need the Framework to be able to hook into any particular instance of logging
\r
31 * mechanism, whether it be a Logging Object within a Servlet Context, or a direct library like log4j.
\r
32 * This interface, therefore, allows maximum pluggability in a variety of different app styles.
\r
36 public interface Access {
\r
39 DEBUG(0x1), INFO(0x10), AUDIT(0x100), WARN(0x2000), ERROR(0x4000), INIT(0x8000),NONE(0XFFFF);
\r
40 private final int bit;
\r
46 public boolean inMask(int mask) {
\r
47 return (mask & bit) == bit;
\r
50 public int addToMask(int mask) {
\r
54 public int delFromMask(int mask) {
\r
58 public int toggle(int mask) {
\r
60 return delFromMask(mask);
\r
62 return addToMask(mask);
\r
67 public int maskOf() {
\r
69 for(Level l : values()) {
\r
70 if(ordinal()<l.ordinal()) {
\r
79 * Write a variable list of Object's text via the toString() method with appropriate space, etc.
\r
82 public void log(Level level, Object ... elements);
\r
85 * Printf mechanism for Access
\r
90 public void printf(Level level, String fmt, Object ... elements);
\r
93 * Check if message will log before constructing
\r
97 public boolean willLog(Level level);
\r
100 * Write the contents of an exception, followed by a variable list of Object's text via the
\r
101 * toString() method with appropriate space, etc.
\r
103 * The Loglevel is always "ERROR"
\r
107 public void log(Exception e, Object ... elements);
\r
110 * Set the Level to compare logging too
\r
112 public void setLogLevel(Level level);
\r
115 * It is important in some cases to create a class from within the same Classloader that created
\r
116 * Security Objects. Specifically, it's pretty typical for Web Containers to separate classloaders
\r
117 * so as to allow Apps with different dependencies.
\r
120 public ClassLoader classLoader();
\r
122 public String getProperty(String string, String def);
\r
124 public void load(InputStream is) throws IOException;
\r
127 * if "anytext" is true, then decryption will always be attempted. Otherwise, only if starts with
\r
132 * @throws IOException
\r
134 public String decrypt(String encrypted, boolean anytext) throws IOException;
\r
136 public static final Access NULL = new Access() {
\r
137 public void log(Level level, Object... elements) {
\r
141 public void printf(Level level, String fmt, Object... elements) {
\r
144 public void log(Exception e, Object... elements) {
\r
147 public ClassLoader classLoader() {
\r
148 return this.classLoader();
\r
151 public String getProperty(String string, String def) {
\r
155 public void load(InputStream is) throws IOException {
\r
158 public void setLogLevel(Level level) {
\r
161 public String decrypt(String encrypted, boolean anytext) throws IOException {
\r
166 public boolean willLog(Level level) {
\r