1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\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
11 * * http://www.apache.org/licenses/LICENSE-2.0
\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
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package com.osaaf.defOrg;
\r
25 import java.io.IOException;
\r
26 import java.util.List;
\r
28 import com.att.authz.env.AuthzTrans;
\r
29 import com.att.authz.local.AbsData.Reuse;
\r
30 import com.att.authz.org.Organization;
\r
31 import com.att.authz.org.Organization.Identity;
\r
32 import com.att.authz.org.OrganizationException;
\r
33 import com.att.cadi.config.Config;
\r
34 import com.osaaf.defOrg.Identities.Data;
\r
37 * Org Users are essential representations of Identities within the Org. Since this is a highly individual
\r
38 * thing for most Orgs, i.e. some use LDAP, some need feed, some use something else, this object will allow
\r
39 * the Organization to connect to their own Identity systems...
\r
43 public class DefaultOrgIdentity implements Identity {
\r
44 private final static int TIMEOUT = Integer.parseInt(Config.AAF_CONN_TIMEOUT_DEF);
\r
46 private DefaultOrg org;
\r
47 private Data identity;
\r
48 private Identity owner;
\r
50 public DefaultOrgIdentity(AuthzTrans trans, String key, DefaultOrg dorg) throws OrganizationException {
\r
54 org.identities.open(trans, TIMEOUT);
\r
56 Reuse r = org.identities.reuse();
\r
57 identity = org.identities.find(key, r);
\r
58 if(identity==null) {
\r
59 identity = Identities.NO_DATA;
\r
61 if("a".equals(identity.status)) {
\r
62 owner = new DefaultOrgIdentity(trans,identity.responsibleTo,org);
\r
68 org.identities.close(trans);
\r
70 } catch (IOException e) {
\r
71 throw new OrganizationException(e);
\r
76 public boolean equals(Object b) {
\r
77 if(b instanceof DefaultOrgIdentity) {
\r
78 return identity.id.equals(((DefaultOrgIdentity)b).identity.id);
\r
84 public String id() {
\r
89 public String fullID() {
\r
90 return identity.id+'@'+org.getDomain();
\r
94 public String type() {
\r
95 switch(identity.status) {
\r
96 case "e": return DefaultOrg.Types.Employee.name();
\r
97 case "c": return DefaultOrg.Types.Contractor.name();
\r
98 case "a": return DefaultOrg.Types.Application.name();
\r
99 case "n": return DefaultOrg.Types.NotActive.name();
\r
106 public String responsibleTo() {
\r
107 return identity.responsibleTo;
\r
111 public List<String> delegate() {
\r
112 //NOTE: implement Delegate system, if desired
\r
113 return DefaultOrg.NULL_DELEGATES;
\r
117 public String email() {
\r
118 return identity.email;
\r
122 public String fullName() {
\r
123 return identity.name;
\r
127 public boolean isResponsible() {
\r
128 return "e".equals(identity.status); // Assume only Employees are responsible for Resources.
\r
132 public boolean isFound() {
\r
133 return identity!=null;
\r
137 public Identity owner() throws OrganizationException {
\r
142 public Organization org() {
\r