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