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.File;
\r
26 import java.io.IOException;
\r
28 import com.att.authz.local.AbsData;
\r
29 import com.att.authz.local.DataFile.Token.Field;
\r
32 * Example User Data file, which can be modified for many different kinds of Data Feeds.
\r
34 * Note: This has shown to be extremely effective in AT&T, an acknowledged very large organizations,
\r
35 * because there is no need to synchronize records. AAF simply receives a Data Feed in Organization
\r
36 * defined intervals. (You might want to check for validity, such as size, etc), then is copied into
\r
37 * Data Directory. You will want to do so first creating a "lock" file. Assuming the File name is "users.dat",
\r
38 * the Lock File is "users.lock".
\r
40 * After the movement of the Datafile into place, it is best to remove the Index File, then remove the lock file.
\r
42 * Note, Any AAF Programs needing this data WILL wait on the Lock file, so you should get fresh Data files
\r
43 * in a "stage" directory, from WEB, or wherever, and then, after it is correct, do the following as fast as feasible.
\r
46 * b) copy from stage
\r
50 * If the Index File is either non-existent or out of date from the Data File, it will be reindexed, which
\r
51 * has proven to be a very quick function, even with large numbers of entries.
\r
53 * This Sample Feed is set for a file with delimiter of "|". 512 is maximum expected line length. The "0" is the
\r
54 * field offset for the "key" to the record, which, for user, should be the unique Organization Identity.
\r
57 public class Identities extends AbsData {
\r
58 public final static Data NO_DATA = new Data();
\r
60 public Identities(File users) {
\r
61 super(users,'|',512,0);
\r
65 * Example Field Layout. note, in this example, Application IDs and People IDs are mixed. You may want to split
\r
66 * out AppIDs, choose your own status indicators, or whatever you use.
\r
72 * 5 - official email
\r
73 * 6 - employment status e=employee, c=contractor, a=application, n=no longer with company
\r
74 * 7 - responsible to (i.e Supervisor for People, or AppOwner, if it's an App ID)
\r
76 public static class Data {
\r
77 public final String id;
\r
78 public final String name;
\r
79 public final String fname;
\r
80 public final String lname;
\r
81 public final String phone;
\r
82 public final String email;
\r
83 public final String status;
\r
84 public final String responsibleTo;
\r
86 private Data(Field f) {
\r
95 responsibleTo =f.next();
\r
99 id = name = fname = lname =
\r
100 phone = email = status = responsibleTo
\r
104 public String toString() {
\r
115 // Here, make up your own Methods which help you easily determine your Organization's structure
\r
116 // in your Organization Object
\r
117 public boolean hasStatus(String possible) {
\r
118 return possible.contains(status);
\r
121 public boolean isEmployee() {
\r
122 return "e".equals(status);
\r
125 public boolean isContractor() {
\r
126 return "c".equals(status);
\r
129 public boolean isApplication() {
\r
130 return "a".equals(status);
\r
134 public Data find(Object key,Reuse r) throws IOException {
\r
135 r.getFieldData().reset();
\r
136 // These are new, to allow for Thread Safety
\r
137 int rec = ti.find(key,r.getTokenData(),r.getFieldData(),0);
\r
141 r.getTokenData().pos(rec);
\r
142 return new Data(r.getFieldData());
\r