001: /**
002: * $Id: CMCNodeImpl.java,v 1.2 2005/07/25 23:02:35 jtb Exp $
003: * Copyright 2005 Sun Microsystems, Inc. All
004: * rights reserved. Use of this product is subject
005: * to license terms. Federal Acquisitions:
006: * Commercial Software -- Government Users
007: * Subject to Standard License Terms and
008: * Conditions.
009: *
010: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011: * are trademarks or registered trademarks of Sun Microsystems,
012: * Inc. in the United States and other countries.
013: */package com.sun.portal.community.mc.impl.am.frole;
014:
015: import com.iplanet.am.sdk.AMException;
016: import com.iplanet.am.sdk.AMFilteredRole;
017: import com.iplanet.am.sdk.AMObject;
018: import com.iplanet.sso.SSOException;
019: import com.sun.portal.community.mc.CMCException;
020: import com.sun.portal.community.mc.CMCNode;
021: import com.sun.portal.community.mc.CMCPrincipal;
022: import com.sun.portal.community.mc.ConfigTable;
023: import com.sun.portal.community.mc.ConfigTable.ConfigKey;
024: import com.sun.portal.community.mc.CMCRolePrincipal;
025: import com.sun.portal.community.mc.impl.am.CMCNodeImplBase;
026: import java.util.HashSet;
027: import java.util.Iterator;
028: import java.util.Properties;
029: import java.util.Set;
030:
031: public class CMCNodeImpl extends CMCNodeImplBase implements CMCNode {
032: public static String getStaticType() {
033: return "am-frole";
034: }
035:
036: public String getType() {
037: return getStaticType();
038: }
039:
040: public void init(Properties p, CMCPrincipal cp) throws CMCException {
041: super .init(p, cp);
042:
043: String dn = getCMCPrincipal().getName();
044: try {
045: int type = getAMObjectType(dn);
046: if (!(type == AMObject.FILTERED_ROLE)) {
047: throw new CMCException(
048: "name was not a filtered role DN: " + dn);
049: }
050: } catch (SSOException ssoe) {
051: throw new CMCException(ssoe);
052: } catch (AMException ame) {
053: throw new CMCException(ame);
054: }
055:
056: }
057:
058: public Set getUsers() throws CMCException {
059: Set users;
060:
061: try {
062: String name = getCMCPrincipal().getName();
063: users = getFilteredRoleUsers(name);
064: } catch (AMException ame) {
065: throw new CMCException(ame);
066: } catch (SSOException ssoe) {
067: throw new CMCException(ssoe);
068: }
069:
070: return users;
071: }
072:
073: private Set getFilteredRoleUsers(String roleDn)
074: throws SSOException, AMException {
075: AMFilteredRole amRole = adminConnection.getFilteredRole(roleDn);
076: return amRole.getUserDNs();
077: }
078:
079: public boolean exists() throws CMCException {
080: return isValidEntry(getCMCPrincipal().getName());
081: }
082:
083: public ConfigTable getDPDocuments() throws CMCException {
084: ConfigTable dpDocuments;
085:
086: try {
087: String name = getCMCPrincipal().getName();
088: dpDocuments = getTemplateDPDocuments(name);
089: } catch (AMException ame) {
090: throw new CMCException(ame);
091: } catch (SSOException ssoe) {
092: throw new CMCException(ssoe);
093: }
094:
095: return dpDocuments;
096: }
097:
098: public ConfigTable getDPDocumentsLastModified() throws CMCException {
099: ConfigTable lastModifieds;
100:
101: try {
102: String name = getCMCPrincipal().getName();
103: lastModifieds = getTemplateDPDocumentsLastModified(name);
104: } catch (AMException ame) {
105: throw new CMCException(ame);
106: } catch (SSOException ssoe) {
107: throw new CMCException(ssoe);
108: }
109:
110: return lastModifieds;
111: }
112: }
|