01: /**
02: * $Id: CMCUserImpl.java,v 1.3 2007/01/26 03:47:51 portalbld Exp $
03: * Copyright 2005 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.community.mc.impl.am.org;
14:
15: import com.sun.portal.community.mc.CMCException;
16: import com.sun.portal.community.mc.CMCPrincipal;
17: import com.sun.portal.community.mc.CMCUser;
18: import com.sun.portal.community.mc.CMCNode;
19: import com.sun.portal.community.mc.ConfigTable;
20: import com.sun.portal.community.mc.ConfigTable.ConfigKey;
21: import com.sun.portal.community.mc.CMCRolePrincipal;
22: import com.sun.portal.community.mc.impl.Debug;
23: import com.sun.portal.community.mc.CMCFactory;
24: import com.sun.portal.community.mc.impl.am.CMCUserImplBase;
25: import java.io.File;
26: import java.util.HashSet;
27: import java.util.Iterator;
28: import java.util.Properties;
29: import java.util.Set;
30: import java.util.Collections;
31: import com.iplanet.am.sdk.AMUser;
32: import com.iplanet.am.sdk.AMRole;
33: import com.iplanet.am.sdk.AMObject;
34: import com.iplanet.am.sdk.AMFilteredRole;
35: import com.iplanet.am.sdk.AMOrganization;
36: import com.iplanet.sso.SSOException;
37: import com.iplanet.am.sdk.AMException;
38: import com.iplanet.am.util.SystemProperties;
39:
40: /**
41: * AM organization community user contributor
42: */
43: public class CMCUserImpl extends CMCUserImplBase implements CMCUser {
44: public static String getStaticType() {
45: return "am-org";
46: }
47:
48: public String getType() {
49: return getStaticType();
50: }
51:
52: public Set getMembershipByName() throws CMCException {
53: Set membership = new HashSet();
54:
55: try {
56: //
57: // walk the LDAP node tree to get the organizations /
58: // sub organizations the user belongs to
59: //
60:
61: String orgDN = getAMUser().getOrganizationDN();
62: String rootDN = getRootDN();
63:
64: if (orgDN != null && orgDN.length() > 0) {
65: while (!orgDN.equalsIgnoreCase(rootDN)) {
66: AMOrganization org = adminConnection
67: .getOrganization(orgDN);
68: if (getAMObjectType(orgDN) == AMObject.ORGANIZATION) {
69: //
70: // skip all types other than org, specifically,
71: // organizational units. only proper orgs
72: // can have templates created
73: //
74: ConfigKey ck = new ConfigKey(new CMCPrincipal(
75: getType(), orgDN),
76: CMCRolePrincipal.MEMBER_ROLE);
77: membership.add(ck);
78: }
79: orgDN = org.getParentDN();
80: }
81: }
82: // add root DN
83: membership.add(new ConfigKey(new CMCPrincipal(getType(),
84: rootDN), CMCRolePrincipal.MEMBER_ROLE));
85: } catch (SSOException ssoe) {
86: throw new CMCException(ssoe);
87: } catch (AMException ame) {
88: throw new CMCException(ame);
89: }
90:
91: return membership;
92: }
93:
94: private static String getRootDN() {
95: return SystemProperties.get("com.iplanet.am.rootsuffix");
96: }
97: }
|