8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: EntityObjectImpl.java,v 1.3 2008/06/25 05:43:26 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Implementation class for the interface EntityObjectIF
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class EntityObjectImpl implements EntityObjectIF {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Creates entities.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param ssotoken
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * String representing user's SSO Token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityName
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Name of this entity.eg.cn=websphereAgent
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityType
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Type of entity being created. eg. Agent The types supported by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * SDK are configured in the list of Managed Objects in the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>DAI</code> service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityLocation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Location of the entity creation.eg.www.abc.com
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param attributes
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Map to represent Attribute-Value Pairs
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return Returns a set of Entity DNs created.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws EntityException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if there is an internal error in the AM Store
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the sign on is no longer valid
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Set createEntity(String ssotoken, String entityName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String entityType, String entityLocation, Map attributes)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set entityObjs = entity.createEntities(type, input);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.error("EntityObjectImpl.createEntity() : "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Deletes entities.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param ssoToken User's Single Sign On Token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityName Name of this entity. example
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>cn=websphereAgent</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityType Type of entity being created. eg. Agent The types
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * supported by SDK are configured in the list of Managed Objects
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * in the <code>DAI</code> service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityLocation Location of the entity creation. example
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>www.abc.com</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws EntityException if there is an internal error in the AM Store.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if the sign on is no longer valid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String entDN = getEntityDN(entityName, type, entityLocation);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.error("EntityObjectImpl.deleteEntity() : "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns the entity object for each entity given the entityType and
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * entityName(s) in that particular organization.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param ssoToken User's Single Sign On Token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityName Name of this entity. example
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>cn=websphereAgent</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityType Type of entity being created. eg. Agent The types
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * supported by SDK are configured in the list of Managed Objects
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * in the <code>DAI</code> service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityLocation Location of the entity creation. example
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>www.abc.com</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return Set of Entity objects.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws EntityException if there is an internal error in the AM Store.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if the sign on is no longer valid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws RemoteException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ) throws EntityException, SSOException, RemoteException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns a set of Entity Names given the Entity Type for that particular
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * organization.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param ssoToken User's Single Sign On Token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityType Type of entity being created. eg. Agent The types
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * supported by SDK are configured in the list of Managed Objects
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * in the <code>DAI</code> service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityLocation Location of the entity creation. example
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>www.abc.com</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityFilter
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return Set of Entity Names.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws EntityException if there is an internal error in the AM Store.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if the sign on is no longer valid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws RemoteException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ) throws EntityException, SSOException, RemoteException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Sets or replaces attribute values with the new values supplied and Stores
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * the changes to directory server.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param ssoToken User's Single Sign Token.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityName Name of this entity. example
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>cn=websphereAgent</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityType Type of entity being created. eg. Agent The types
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * supported by SDK are configured in the list of Managed Objects
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * in the <code>DAI</code> service.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param entityLocation Location of the entity creation. example
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>www.abc.com</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws EntityException if there is an internal error in the AM Store.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws SSOException if the sign on is no longer valid.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws RemoteException
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ) throws EntityException, SSOException, RemoteException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AMEntity amEntity = getAMEntity(ssoToken, entityName, entityType,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.error("EntityObjectImpl.modifyEntity() : "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to get the token manager handle.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected static void checkInitialization() throws SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster synchronized (lock) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "EntityObjectImpl:checkInitialization() " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ": Unable to get SSOTokenManager",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to get the AMEntity object from the storeconnection.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected AMEntity getAMEntity(String ssoToken, String entityName,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String entityType, String entityLocation) throws EntityException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String entDN = getEntityDN(entityName, type, entityLocation);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.error("EntityObjectImpl.getAMEntity(): "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "Unable to convert SSOToken: " + ssoToken, ssoe);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to initialize the object. The AMStoreConnection handle is obtained
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * by creating a valid SSOToken.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected void initializeObject(String ssoToken, String entityLocation)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String orgDN = amsc.getOrganizationDN(entityLocation, null);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.error("EntityObjectImpl.initializeObject() : "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.error("EntityObjectImpl.initializeObject() : "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "Unable to convert SSOToken: " + ssoToken, ssoe);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.message("EntityObjectImpl.getAMEntity(): "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.message("EntityObjectImpl.getAMEntity(): "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "Obtained AMSToreConnection object for SSOToken: "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to convert the entity type from string to integer recognizable by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private int getIntTypeFromStr(String entityType) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AMEntityType amEntityType = (AMEntityType) iter.next();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (amEntityType.getName().equalsIgnoreCase(entityType)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Method to get the DN of the entity based on the search results for the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * entityName from the entityLocation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private String getEntityDN(String entityName, int entityType,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String entityLocation) throws EntityException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set entityResults = entity.searchEntities(entityType, "*",
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster EntityUtils.debug.error("EntityObjectImpl.getEntityDN() : "