001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.security.model.v1;
009:
010: //base classes
011:
012: //project specific classes
013: import org.jfolder.common.UnexpectedSystemException;
014: import org.jfolder.common.entity.InitializeSystemEntityTagContext;
015: import org.jfolder.common.entity.SystemEntityTag;
016: import org.jfolder.common.tagging.AppraiseConceptTagContext;
017: import org.jfolder.common.tagging.ConceptTag;
018: import org.jfolder.common.tagging.ConceptTagCharacteristic;
019: import org.jfolder.common.tagging.ConceptTagCharacteristicHolder;
020: import org.jfolder.common.tagging.ConceptTagConstraint;
021: import org.jfolder.common.tagging.ConceptTagConstraintHolder;
022: import org.jfolder.common.tagging.ConceptTagPreferences;
023: import org.jfolder.common.tagging.DynamicConceptTagConstraintContext;
024: import org.jfolder.common.tagging.InitializeConceptTagContext;
025: import org.jfolder.common.tagging.RootConceptTagHolder;
026: import org.jfolder.common.tagging.StaticConceptTagConstraintContext;
027: import org.jfolder.common.tagging.StudioConceptTagInstanceInfoContext;
028: import org.jfolder.common.tagging.StudioConceptTagTypeInfoContext;
029: import org.jfolder.common.utils.misc.MiscHelper;
030: import org.jfolder.security.model.UserHolder;
031: import org.jfolder.security.model.UserIdentity;
032: import org.jfolder.security.model.UserIdentityHelper;
033:
034: //other classes
035:
036: public class UserIdentityTag implements UserIdentity, SystemEntityTag {
037:
038: //
039: private ConceptTagCharacteristic nameCtchar = null;
040: //private ConceptTagCharacteristic securityTypePresentCtchar = null;
041: private ConceptTagCharacteristic securityTypeCtchar = null;
042: //private ConceptTagCharacteristic securityClassCtchar = null;
043: private ConceptTagCharacteristic validCtchar = null;
044: private ConceptTagCharacteristic anonymousCtchar = null;
045:
046: //name details
047: private final static String NAME_CTCON = "name";
048: private final static String NAME_TITLE = "Name";
049: private final static String NAME_SHORT_DESCRIPTION = "Name";
050:
051: ////security-type-present details
052: //private final static String SECURITY_TYPE_PRESENT_CTCON =
053: // "security-type-present";
054: //private final static String SECURITY_TYPE_PRESENT_TITLE =
055: // "Security Type Present";
056: //private final static String SECURITY_TYPE_PRESENT_SHORT_DESCRIPTION =
057: // "Security Type Present";
058:
059: //security-type details
060: private final static String SECURITY_TYPE_CTCON = "security-type";
061: private final static String SECURITY_TYPE_TITLE = "Security Type";
062: private final static String SECURITY_TYPE_SHORT_DESCRIPTION = "Security Type";
063:
064: ////security-class details
065: //private final static String SECURITY_CLASS_CTCON = "security-class";
066: //private final static String SECURITY_CLASS_TITLE = "Security Class";
067: //private final static String SECURITY_CLASS_SHORT_DESCRIPTION =
068: // "Security Class";
069:
070: //valid details
071: private final static String VALID_CTCON = "valid";
072: private final static String VALID_TITLE = "Valid";
073: private final static String VALID_SHORT_DESCRIPTION = "Valid";
074:
075: //anonymous details
076: private final static String ANONYMOUS_CTCON = "anonymous";
077: private final static String ANONYMOUS_TITLE = "Anonymous";
078: private final static String ANONYMOUS_SHORT_DESCRIPTION = "Anonymous";
079:
080: //
081: public UserIdentityTag() {
082: }
083:
084: //
085: public final static UserIdentityTag newInstance(
086: ConceptTagCharacteristic inCtchar, int inIndex,
087: String inName, String inSecurityType, boolean inValid,
088: boolean inAnonymous) {
089:
090: UserIdentityTag outValue = new UserIdentityTag();
091:
092: //
093: ConceptTagCharacteristicHolder ctcharh = inCtchar.addValue(
094: inIndex, outValue, true);
095:
096: InitializeSystemEntityTagContext isetc = new InitializeSystemEntityTagContext(
097: ctcharh);
098:
099: outValue.initialize(isetc);
100:
101: //
102: outValue.nameCtchar.addValue(0, inName);
103: //outValue.securityTypePresentCtchar.addValue(
104: // 0, inSecurityTypePresent + "");
105: //if (inSecurityType != null) {
106: outValue.securityTypeCtchar.addValue(0, inSecurityType);
107: //}
108: //if (inSecurityClass != null) {
109: // outValue.securityClassCtchar.addValue(0, inSecurityClass);
110: //}
111: outValue.validCtchar.addValue(0, inValid + "");
112: outValue.anonymousCtchar.addValue(0, inAnonymous + "");
113:
114: return outValue;
115: }
116:
117: //
118: public void initialize(InitializeConceptTagContext inIctc) {
119:
120: //
121: ConceptTagConstraintHolder rootCtconh = ConceptTagConstraintHolder
122: .newInstance(inIctc);
123:
124: //constrain "name"
125: ConceptTagConstraint nameCtcon = ConceptTagConstraint
126: .newInstance(NAME_CTCON, rootCtconh);
127: //
128: StaticConceptTagConstraintContext nameSctcc = StaticConceptTagConstraintContext
129: .newInstance(nameCtcon);
130:
131: ////constrain "security-type-present"
132: //ConceptTagConstraint securityTypePresentCtcon =
133: // ConceptTagConstraint.newInstance(
134: // SECURITY_TYPE_PRESENT_CTCON, rootCtconh);
135: ////
136: //StaticConceptTagConstraintContext securityTypePresentSctcc =
137: // StaticConceptTagConstraintContext.newInstance(
138: // securityTypePresentCtcon);
139:
140: //constrain "security-type"
141: ConceptTagConstraint securityTypeCtcon = ConceptTagConstraint
142: .newInstance(SECURITY_TYPE_CTCON, rootCtconh);
143: //
144: StaticConceptTagConstraintContext securityTypeSctcc = StaticConceptTagConstraintContext
145: .newInstance(securityTypeCtcon);
146:
147: ////constrain "security-class"
148: //ConceptTagConstraint securityClassCtcon =
149: // ConceptTagConstraint.newInstance(
150: // SECURITY_CLASS_CTCON, rootCtconh);
151: ////
152: //StaticConceptTagConstraintContext securityClassSctcc =
153: // StaticConceptTagConstraintContext.newInstance(securityClassCtcon);
154:
155: //constrain "valid"
156: ConceptTagConstraint validCtcon = ConceptTagConstraint
157: .newInstance(VALID_CTCON, rootCtconh);
158: //
159: StaticConceptTagConstraintContext validSctcc = StaticConceptTagConstraintContext
160: .newInstance(validCtcon);
161:
162: //constrain "anonymous"
163: ConceptTagConstraint anonymousCtcon = ConceptTagConstraint
164: .newInstance(ANONYMOUS_CTCON, rootCtconh);
165: //
166: StaticConceptTagConstraintContext anonymousSctcc = StaticConceptTagConstraintContext
167: .newInstance(anonymousCtcon);
168:
169: //
170: inIctc.initialize();
171:
172: //
173: this .nameCtchar = nameCtcon.getCharacteristic();
174: //this.securityTypePresentCtchar =
175: // securityTypePresentCtcon.getCharacteristic();
176: this .securityTypeCtchar = securityTypeCtcon.getCharacteristic();
177: //this.securityClassCtchar = securityClassCtcon.getCharacteristic();
178: this .validCtchar = validCtcon.getCharacteristic();
179: this .anonymousCtchar = anonymousCtcon.getCharacteristic();
180: }
181:
182: //
183: public void appraise(AppraiseConceptTagContext inCtic) {
184: if (inCtic instanceof StudioConceptTagInstanceInfoContext) {
185: StudioConceptTagInstanceInfoContext sctiic = (StudioConceptTagInstanceInfoContext) inCtic;
186: sctiic.setInstanceTitle("User Identity");
187: sctiic.setInstanceDescription("User Identity");
188: } else if (inCtic instanceof StudioConceptTagTypeInfoContext) {
189: StudioConceptTagTypeInfoContext scttic = (StudioConceptTagTypeInfoContext) inCtic;
190: scttic.setTypeTitle("User Identity");
191: scttic.setTypeDescription("User Identity");
192: }
193: }
194:
195: //
196: public String getName() {
197:
198: String outValue = null;
199:
200: if (this .nameCtchar.getValueLength() > 0) {
201: outValue = this .nameCtchar.getValueAsString(0, null);
202: }
203:
204: return outValue;
205: }
206:
207: //
208: //public boolean isSecurityTypePresent() {
209: //
210: // boolean outValue = false;
211: //
212: // if (this.securityTypePresentCtchar.getValueLength() > 0) {
213: // String value = this.securityTypePresentCtchar.getValueAsString(0);
214: // outValue = (new Boolean(value)).booleanValue();
215: // }
216: //
217: // return outValue;
218: //}
219: public String getSecurityType() {
220:
221: String outValue = null;
222:
223: if (this .securityTypeCtchar.getValueLength() > 0) {
224: outValue = this .securityTypeCtchar
225: .getValueAsString(0, null);
226: }
227:
228: return outValue;
229: }
230:
231: //public String getSecurityClass() {
232: //
233: // String outValue = null;
234: //
235: // if (this.securityClassCtchar.getValueLength() > 0) {
236: // outValue = this.securityClassCtchar.getValueAsString(0);
237: // }
238: //
239: // return outValue;
240: //}
241:
242: //
243: public boolean isValid() {
244:
245: boolean outValue = false;
246:
247: if (this .validCtchar.getValueLength() > 0) {
248: String value = this .validCtchar.getValueAsString(0, null);
249: outValue = (new Boolean(value)).booleanValue();
250: }
251:
252: return outValue;
253: }
254:
255: public boolean isAnonymous() {
256:
257: boolean outValue = false;
258:
259: if (this .anonymousCtchar.getValueLength() > 0) {
260: String value = this .anonymousCtchar.getValueAsString(0,
261: null);
262: outValue = (new Boolean(value)).booleanValue();
263: }
264:
265: return outValue;
266: }
267:
268: //
269: public int hashCode() {
270: return UserIdentityHelper.getUserIdentityHashCode(this );
271: }
272:
273: public boolean equals(Object inObject) {
274:
275: boolean outValue = false;
276:
277: if (inObject instanceof UserIdentity) {
278: outValue = UserIdentityHelper.isSameUserIdentity(this ,
279: (UserIdentity) inObject);
280: }
281:
282: return outValue;
283: }
284: }
|