8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
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 *
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 * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
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 *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: AMEntityImpl.java,v 1.5 2008/06/25 05:41:20 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.iplanet.am.sdk;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Map;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.Set;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.HashSet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.sso.SSOException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.sso.SSOToken;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @deprecated As of Sun Java System Access Manager 7.1.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster*/
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class AMEntityImpl extends AMObjectImpl implements AMEntity {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected AMEntityImpl(SSOToken ssotoken, String dn) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super(ssotoken, dn, AMObject.UNDETERMINED_OBJECT_TYPE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected AMEntityImpl(SSOToken ssotoken, String dn, int type) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super(ssotoken, dn, type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void delete(boolean recursive) throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.delete(recursive);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Map getAttributes() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return super.getAttributes();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getDN() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return super.getDN();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getOrganizationDN() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return super.getOrganizationDN();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getParentDN() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return super.getParentDN();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isExists() throws SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return super.isExists();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void purge(boolean recursive, int graceperiod) throws AMException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.purge(recursive, graceperiod);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void removeAttributes(Set attributes) throws AMException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.removeAttributes(attributes);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void setAttributes(Map attributes) throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.setAttributes(attributes);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void delete() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster delete(false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void store() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.store();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * This method is used to create the entity (so far only in memory)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * in the LDAP data store. A string identifying the type of entry being
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * created, has to be passed. The types supported are the ones defined
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * in the configuration of DAI service. Some examples are: "user", "agent".
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void create(String stype) throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String type = (String) AMCommonUtils.supportedTypes.get(stype
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .toLowerCase());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (type != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = Integer.parseInt(type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super.create();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new AMException(AMSDKBundle.getString("156", super.locale),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "156");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void activate() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String stype = Integer.toString(type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String stAttrName = (String) AMCommonUtils.statusAttributeMap
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .get(stype);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (stAttrName != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setStringAttribute(stAttrName, "active");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void deactivate() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String stype = Integer.toString(type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String stAttrName = (String) AMCommonUtils.statusAttributeMap
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .get(stype);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (stAttrName != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster setStringAttribute(stAttrName, "inactive");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster store();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isActivated() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String stype = Integer.toString(type);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String stAttrName = (String) AMCommonUtils.statusAttributeMap
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster .get(stype);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String stAttrValue = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (stAttrName != null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster stAttrValue = getStringAttribute(stAttrName);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (stAttrValue == null || stAttrValue.length() == 0
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster || stAttrValue.equalsIgnoreCase("active")) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (true);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return (false);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public Map getAttributes(Set attributeNames) throws AMException,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster int type = dsServices.getObjectType(token, entryDN);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster profileType = type;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return super.getAttributes(attributeNames);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected Set getRoleDNs() throws AMException, SSOException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set nsroleDNSet = new HashSet();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster nsroleDNSet.add("nsroledn");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Map nsrolesMap = super.getAttributesFromDataStore(nsroleDNSet);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Set answer = (Set) nsrolesMap.get("nsroledn");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return ((answer == null) ? java.util.Collections.EMPTY_SET : answer);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}