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