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