2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package org.onap.aaf.cadi.taf;
24 import org.onap.aaf.cadi.Access;
25 import org.onap.aaf.cadi.principal.TaggedPrincipal;
26 import org.onap.aaf.cadi.util.Timing;
31 * Base class for TafResp (TAF Response Objects)
36 public abstract class AbsTafResp implements TafResp {
38 protected final Access access;
39 protected final String tafName;
40 protected final TaggedPrincipal principal;
41 protected final String desc;
48 * Description (for logging)
49 * Principal (as created by derived class)
50 * Access (for access to underlying container, i.e. for Logging, auditing, ClassLoaders, etc)
57 public AbsTafResp(Access access, String tafname, TaggedPrincipal principal, String description) {
59 this.tafName = tafname;
60 this.principal = principal;
61 this.desc = description;
67 * Respond in the affirmative if the TAF was able to Authenticate
69 public boolean isValid() {
70 return principal != null;
76 * Respond with description of response as given by the TAF
78 public String desc() {
85 * Respond with the TAF's code of whether Authenticated, or suggested next steps
86 * default is either IS_AUTHENTICATED, or TRY_ANOTHER_TAF. The TAF can overload
87 * and suggest others, such as "NO_FURTHER_PROCESSING", if it can detect that this
88 * is some sort of security breach (i.e. Denial of Service)
90 public RESP isAuthenticated() {
91 return principal==null?RESP.TRY_ANOTHER_TAF:RESP.IS_AUTHENTICATED;
97 * Return the principal created by the TAF based on Authentication.
99 * Returns "null" if Authentication failed (no principal)
101 public TaggedPrincipal getPrincipal() {
108 * Get the Access object from the TAF, so that appropriate Logging, etc can be coordinated.
110 public Access getAccess() {
115 * @see org.onap.aaf.cadi.taf.TafResp#isFailedAttempt()
117 public boolean isFailedAttempt() {
122 public float timing() {
127 public void timing(final long start) {
128 timing = Timing.millis(start);
132 public String taf() {