001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: AMEntityType.java,v 1.6 2008/06/25 05:41:20 qcheng Exp $
026 *
027 */
028
029/**
030 * Portions Copyrighted [2011] [ForgeRock AS]
031 */
032package com.iplanet.am.sdk;
033
034import com.iplanet.sso.SSOException;
035import com.iplanet.sso.SSOToken;
036import com.sun.identity.shared.debug.Debug;
037import com.sun.identity.sm.SMSException;
038import com.sun.identity.sm.ServiceSchemaManager;
039
040
041/**
042 * This class defines a supported managed object type by <code> AM SDK </code>
043 * It defines the name, type, service name of the object. A set of the supported
044 * types can be obtained by using the class <code>AMStoreConnection</code>:
045 * <p>
046 * 
047 * <PRE>
048 * 
049 *        AMStoreConnection amsc = new AMStoreConnection(ssotoken); 
050 *        Set supportedTypes = amsc.getSupportedTypes(); 
051 *        Iterator it = supportedTypes.iterator(); 
052 *        while (it.hasNext()) { 
053 *            AMEntityType thisType = (AMEntityType) it.next(); 
054 *            // Do stuff with AMEntityType 
055 *        }
056 * 
057 * </PRE>
058 *
059 * @deprecated  As of Sun Java System Access Manager 7.1.
060 * @supported.all.api
061 */
062public final class AMEntityType {
063
064    private String name;
065
066    private int type;
067
068    private String serviceName;
069
070    private String searchTemplateName;
071
072    private String creationTemplateName;
073
074    private String containerRDN;
075
076    private int containerType;
077
078    private String stAttribute;
079
080    private String namingAttribute;
081
082    private String objectClass;
083
084    private Debug debug = AMCommonUtils.debug;
085
086    /**
087     * 
088     * @param name
089     *            Name of entity
090     * @param type
091     *            The integer type of entity
092     * @param serviceName
093     *            Name of service to be used to display the entity profile
094     * @param searchTemplate
095     *            Name of search template to be used to search for this entity
096     * @param creationTemplate
097     *            Name of creation template to be used
098     * @param containerDN
099     *            Relative Distinguished Name of the container in which this
100     *            entity shoould be created.
101     * @param containerType
102     *            The integer type of the container.
103     * @param nAttr
104     *            Naming attribute of this entity
105     * @param stAttr
106     *            Status attribute of this entity, if any. Not all entities have
107     *            status attributes.
108     * @param oc
109     *            Objectclass used to identify this entry.
110     */
111    protected AMEntityType(String name, int type, String serviceName,
112            String searchTemplate, String creationTemplate, String containerDN,
113            int containerType, String nAttr, String stAttr, String oc) {
114        this.name = name;
115        this.type = type;
116        this.serviceName = serviceName;
117        this.containerRDN = containerDN;
118        this.containerType = containerType;
119        this.stAttribute = stAttr;
120        this.namingAttribute = nAttr;
121        this.objectClass = oc;
122        this.searchTemplateName = searchTemplate;
123        this.creationTemplateName = creationTemplate;
124        if (debug.messageEnabled()) {
125            debug.message("AMEntityType:Constructor-> created type "
126                    + toString());
127        }
128    }
129
130    /**
131     * Returns a string representation of this Entity.
132     * 
133     * @return a string representation of this Entity.
134     */
135    public String toString() {
136        StringBuilder sb = new StringBuilder();
137        sb.append("Entity Name=\t").append(name).append("\n").append(
138                "Entity type=\t").append(type).append("\n").append(
139                "Object Class=\t").append(objectClass).append("\n").append(
140                "Service Name=\t").append(serviceName).append("\n").append(
141                "Creation Template=\t").append(creationTemplateName).append(
142                "\n").append("Search Template=\t").append(searchTemplateName)
143                .append("\n").append("Naming Attribute=\t").append(
144                        namingAttribute).append("\n").append(
145                        "Status Attribute=\t").append(stAttribute).append("\n")
146                .append("Container RDN=\t").append(containerRDN).append("\n")
147                .append("Container Type=\t").append(containerType).append("\n");
148        return sb.toString();
149    }
150
151    /**
152     * Returns the name of the entity
153     * 
154     * @return Name
155     */
156    public String getName() {
157        return name;
158    }
159
160    /**
161     * Returns the integer type of the entity
162     * 
163     * @return type
164     */
165    public int getType() {
166        return type;
167    }
168
169    /**
170     * Returns the service name to be used to display entity profile
171     * 
172     * @return service Name
173     */
174    public String getServiceName() {
175        return serviceName;
176    }
177
178    /**
179     * Returns the schema manager for the service defined to display this
180     * profile in the console. If the service is not defined then an exception
181     * is thrown.
182     * 
183     * @param token
184     *            Single sign on token of the user
185     * @return com.sun.identity.sm.ServiceSchemaManager
186     * @throws AMException
187     *             If unable to obtain the service schema, or if schema is not
188     *             defined.
189     * @throws SSOException
190     *             if the single sign on token of user is invalid.
191     */
192    public ServiceSchemaManager getServiceSchemaManager(SSOToken token)
193            throws AMException, SSOException {
194        if (serviceName == null || serviceName.length() == 0) {
195            Object args[] = { name };
196            throw new AMException(AMSDKBundle.getString("978", args), "978",
197                    args);
198        } else {
199            try {
200                return new ServiceSchemaManager(serviceName, token);
201            } catch (SMSException smse) {
202                debug.error("AMEntityType.getServiceSchemaManager: "
203                        + "SM Exception", smse);
204                Object args[] = { name };
205                throw new AMException(AMSDKBundle.getString("978", args),
206                        "978", args);
207            }
208        }
209    }
210
211    /**
212     * Returns the naming attribute
213     * 
214     * @return value of naming attribute.
215     */
216    protected String getNamingAttribute() {
217        return namingAttribute;
218    }
219
220    /**
221     * Returns the objectclass
222     * 
223     * @return objectclass used to identify this entry.
224     */
225    protected String getObjectClass() {
226        return objectClass;
227    }
228
229    /**
230     * Returns the creation template name
231     * 
232     * @return name of creation template used
233     */
234    protected String getCreationTemplate() {
235        return creationTemplateName;
236    }
237
238    /**
239     * Returns the search template name
240     * 
241     * @return returns the name of the search template for this entity type
242     */
243    public String getSearchTemplate() {
244        return searchTemplateName;
245    }
246
247    /**
248     * Returns the parent container RDN
249     * 
250     * @return relative distinguished name of the container in which this
251     * entity shoould be created.
252
253     */
254    protected String getContainerRDN() {
255        return containerRDN;
256    }
257
258    /**
259     * Returns the parent container type
260     * 
261     * @return the integer type of the container.
262     */
263    protected int getContainerType() {
264        return containerType;
265    }
266}




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.