acade37a23182426a9732ef949ac7d8e486aa72a
[aaf/authz.git] / cadi / core / src / main / java / org / onap / aaf / cadi / taf / TafResp.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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====================================================
19  *
20  */
21
22 package org.onap.aaf.cadi.taf;
23
24 import java.io.IOException;
25
26 import org.onap.aaf.cadi.Access;
27 import org.onap.aaf.cadi.CadiException;
28 import org.onap.aaf.cadi.principal.TaggedPrincipal;
29
30 /**
31  * Response from Taf objects, which inform users what has happened and/or what should be done
32  * 
33  * @author Jonathan
34  *
35  */
36 public interface TafResp {
37         public static enum RESP {
38                 IS_AUTHENTICATED, 
39                 NO_FURTHER_PROCESSING, 
40                 TRY_AUTHENTICATING, 
41                 TRY_ANOTHER_TAF,
42                 FAIL, 
43                 // A note was made to avoid the response REDIRECT.  However, I have deemed that it is 
44                 // unavoidable when the underlying TAF did do a REDIRECT, because it requires a HTTP
45                 // Service code to exit without modifying the Response any further.
46                 // Therefore, I have changed this to indicate what HAS happened, with should accommodate 
47                 // both positions.  Jonathan 10/18/2012
48 //              public static final int HTTP_REDIRECT_INVOKED = 11;
49                 HTTP_REDIRECT_INVOKED,
50                 HAS_PROCESSED};
51         
52         /**
53          * Basic success check
54          * @return
55          */
56         public boolean isValid();
57         
58         /**
59          *  String description of what has occurred (for logging/exceptions)
60          * @return
61          */
62         public String desc();
63         
64         /**
65          * Check Response
66          * @return
67          */
68         public RESP isAuthenticated();
69
70         /**
71          * Authenticate, returning FAIL or Other Valid indication
72          * 
73          * HTTP implementations should watch for "HTTP_REDIRECT_INVOKED", and end the HTTP call appropriately.
74          * @return
75          * @throws CadiException 
76          */
77         public RESP authenticate() throws IOException;
78
79         /**
80          * Once authenticated, this object should hold a Principal created from the authorization
81          * @return
82          */
83         public TaggedPrincipal getPrincipal();
84
85         /**
86          * get the Access object which created this object, allowing the responder to appropriate Log, etc
87          */
88         public Access getAccess();
89         
90         /**
91          * Be able to check if part of a Failed attempt
92          */
93         public boolean isFailedAttempt();
94         
95         /**
96          * report how long this took
97          * @return
98          */
99         public float timing();
100
101         /**
102          * Set end of timing in Millis, given Nanos
103          * @param start
104          */
105         void timing(long start);
106         
107         /**
108          * Support Taf Name
109          */
110         String taf();
111 }