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