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;
30 * Base class for TafResp (TAF Response Objects)
35 public abstract class AbsTafResp implements TafResp {
37 protected final String desc;
38 protected final TaggedPrincipal principal;
39 protected final Access access;
45 * Description (for logging)
46 * Principal (as created by derived class)
47 * Access (for access to underlying container, i.e. for Logging, auditing, ClassLoaders, etc)
53 public AbsTafResp(Access access, TaggedPrincipal principal, String description) {
55 this.principal = principal;
56 this.desc = description;
62 * Respond in the affirmative if the TAF was able to Authenticate
64 public boolean isValid() {
65 return principal != null;
71 * Respond with description of response as given by the TAF
73 public String desc() {
80 * Respond with the TAF's code of whether Authenticated, or suggested next steps
81 * default is either IS_AUTHENTICATED, or TRY_ANOTHER_TAF. The TAF can overload
82 * and suggest others, such as "NO_FURTHER_PROCESSING", if it can detect that this
83 * is some sort of security breach (i.e. Denial of Service)
85 public RESP isAuthenticated() {
86 return principal==null?RESP.TRY_ANOTHER_TAF:RESP.IS_AUTHENTICATED;
92 * Return the principal created by the TAF based on Authentication.
94 * Returns "null" if Authentication failed (no principal)
96 public TaggedPrincipal getPrincipal() {
103 * Get the Access object from the TAF, so that appropriate Logging, etc can be coordinated.
105 public Access getAccess() {
110 * @see org.onap.aaf.cadi.taf.TafResp#isFailedAttempt()
112 public boolean isFailedAttempt() {