Update project structure for aaf/cadi
[aaf/cadi.git] / cass / src / main / java / org / onap / aaf / cadi / aaf / cass / AAFAuthenticatedUser.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.aaf.cass;\r
24 \r
25 import java.security.Principal;\r
26 \r
27 import org.apache.cassandra.auth.AuthenticatedUser;\r
28 import org.onap.aaf.cadi.Access;\r
29 \r
30 public class AAFAuthenticatedUser extends AuthenticatedUser implements Principal {\r
31         private boolean anonymous = false, supr=false, local=false;\r
32         private String fullName;\r
33 //      private Access access;\r
34 \r
35         public AAFAuthenticatedUser(Access access, String name) {\r
36                 super(name);\r
37 //              this.access = access;\r
38             int endIndex = name.indexOf("@");\r
39             if(endIndex >= 0) {\r
40                 fullName = name;\r
41             } else {\r
42                 fullName = name + '@' + AAFBase.default_realm;\r
43             }\r
44         }\r
45         \r
46         public String getFullName() {\r
47                 return fullName;\r
48         }\r
49         \r
50         public String getName() {\r
51                 return fullName;\r
52         }\r
53         \r
54         /* (non-Javadoc)\r
55          * @see org.apache.cassandra.auth.AuthenticatedUser#isAnonymous()\r
56          */\r
57         @Override\r
58         public boolean isAnonymous() {\r
59                 return anonymous;\r
60         }\r
61 \r
62         public void setAnonymous(boolean anon) {\r
63                 anonymous = anon;\r
64         }\r
65 \r
66         public boolean getAnonymous() {\r
67                 return anonymous;\r
68         }\r
69 \r
70         /* (non-Javadoc)\r
71          * @see org.apache.cassandra.auth.AuthenticatedUser#isSuper()\r
72          */\r
73         @Override\r
74         public boolean isSuper() {\r
75                 return supr;\r
76         }\r
77 \r
78         public void setSuper(boolean supr) {\r
79                 this.supr = supr;\r
80         }\r
81 \r
82         public boolean getSuper() {\r
83                 return supr;\r
84         }\r
85 \r
86         /**\r
87          * We check Local so we can compare with the right Lur.  This is AAF Plugin only.\r
88          * @return\r
89          */\r
90         public boolean isLocal() {\r
91                 return local;\r
92         }\r
93         \r
94         public void setLocal(boolean val) {\r
95                 local = val;\r
96         }\r
97 \r
98         @Override\r
99           public boolean equals(Object o) {\r
100                   if (this == o) return true;\r
101               if (!(o instanceof AAFAuthenticatedUser)) return false;\r
102               return ((AuthenticatedUser)o).getName().equals(this.getName());\r
103           }\r
104 \r
105           @Override\r
106           public int hashCode() {\r
107                   //access.log(Level.DEBUG, "AAFAuthentication hashcode ",getName().hashCode());\r
108               return getName().hashCode();\r
109           }  \r
110 }\r