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.taf;
\r
26 import java.security.Principal;
\r
28 import com.att.cadi.Access;
\r
33 * Base class for TafResp (TAF Response Objects)
\r
36 public abstract class AbsTafResp implements TafResp {
\r
38 protected final String desc;
\r
39 protected final Principal principal;
\r
40 protected final Access access;
\r
46 * Description (for logging)
\r
47 * Principal (as created by derived class)
\r
48 * Access (for access to underlying container, i.e. for Logging, auditing, ClassLoaders, etc)
\r
52 * @param description
\r
54 public AbsTafResp(Access access, Principal principal, String description) {
\r
55 this.access = access;
\r
56 this.principal = principal;
\r
57 this.desc = description;
\r
63 * Respond in the affirmative if the TAF was able to Authenticate
\r
65 public boolean isValid() {
\r
66 return principal!=null;
\r
72 * Respond with description of response as given by the TAF
\r
74 public String desc() {
\r
81 * Respond with the TAF's code of whether Authenticated, or suggested next steps
\r
82 * default is either IS_AUTHENTICATED, or TRY_ANOTHER_TAF. The TAF can overload
\r
83 * and suggest others, such as "NO_FURTHER_PROCESSING", if it can detect that this
\r
84 * is some sort of security breach (i.e. Denial of Service)
\r
86 public RESP isAuthenticated() {
\r
87 return principal==null?RESP.TRY_ANOTHER_TAF:RESP.IS_AUTHENTICATED;
\r
93 * Return the principal created by the TAF based on Authentication.
\r
95 * Returns "null" if Authentication failed (no principal)
\r
97 public Principal getPrincipal() {
\r
104 * Get the Access object from the TAF, so that appropriate Logging, etc can be coordinated.
\r
106 public Access getAccess() {
\r
111 * @see com.att.cadi.taf.TafResp#isFailedAttempt()
\r
113 public boolean isFailedAttempt() {
\r