src/share/classes/com/sun/jndi/ldap/LdapAttribute.java

Print this page

        

*** 24,35 **** */ package com.sun.jndi.ldap; import java.io.IOException; - import java.io.Serializable; - import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; import javax.naming.*; import javax.naming.directory.*; --- 24,33 ----
*** 48,62 **** private Name rdn = new CompositeName(); // these two are used to reconstruct the baseCtx if this attribute has // been serialized ( private String baseCtxURL; ! private Hashtable baseCtxEnv; public Object clone() { LdapAttribute attr = new LdapAttribute(this.attrID, baseCtx, rdn); ! attr.values = (Vector)values.clone(); return attr; } /** * Adds a new value to this attribute. --- 46,61 ---- private Name rdn = new CompositeName(); // these two are used to reconstruct the baseCtx if this attribute has // been serialized ( private String baseCtxURL; ! private Hashtable<String, ? super String> baseCtxEnv; + @SuppressWarnings("unchecked") // clone() public Object clone() { LdapAttribute attr = new LdapAttribute(this.attrID, baseCtx, rdn); ! attr.values = (Vector<Object>)values.clone(); return attr; } /** * Adds a new value to this attribute.
*** 110,120 **** * to which calls are made. */ private DirContext getBaseCtx() throws NamingException { if(baseCtx == null) { if (baseCtxEnv == null) { ! baseCtxEnv = new Hashtable(3); } baseCtxEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); baseCtxEnv.put(Context.PROVIDER_URL,baseCtxURL); baseCtx = (new InitialDirContext(baseCtxEnv)); --- 109,119 ---- * to which calls are made. */ private DirContext getBaseCtx() throws NamingException { if(baseCtx == null) { if (baseCtxEnv == null) { ! baseCtxEnv = new Hashtable<String, String>(3); } baseCtxEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); baseCtxEnv.put(Context.PROVIDER_URL,baseCtxURL); baseCtx = (new InitialDirContext(baseCtxEnv));
*** 142,173 **** /** * sets the information needed to reconstruct the baseCtx if * we are serialized. This must be called _before_ the object is * serialized!!! */ private void setBaseCtxInfo() { ! Hashtable realEnv = null; ! Hashtable secureEnv = null; if (baseCtx != null) { realEnv = ((LdapCtx)baseCtx).envprops; this.baseCtxURL = ((LdapCtx)baseCtx).getURL(); } if(realEnv != null && realEnv.size() > 0 ) { // remove any security credentials - otherwise the serialized form // would store them in the clear ! Enumeration keys = realEnv.keys(); ! while(keys.hasMoreElements()) { ! String key = (String)keys.nextElement(); if (key.indexOf("security") != -1 ) { //if we need to remove props, we must do it to a clone //of the environment. cloning is expensive, so we only do //it if we have to. if(secureEnv == null) { ! secureEnv = (Hashtable)realEnv.clone(); } secureEnv.remove(key); } } } --- 141,171 ---- /** * sets the information needed to reconstruct the baseCtx if * we are serialized. This must be called _before_ the object is * serialized!!! */ + @SuppressWarnings("unchecked") // clone() private void setBaseCtxInfo() { ! Hashtable<String, Object> realEnv = null; ! Hashtable<String, Object> secureEnv = null; if (baseCtx != null) { realEnv = ((LdapCtx)baseCtx).envprops; this.baseCtxURL = ((LdapCtx)baseCtx).getURL(); } if(realEnv != null && realEnv.size() > 0 ) { // remove any security credentials - otherwise the serialized form // would store them in the clear ! for (String key : realEnv.keySet()){ if (key.indexOf("security") != -1 ) { //if we need to remove props, we must do it to a clone //of the environment. cloning is expensive, so we only do //it if we have to. if(secureEnv == null) { ! secureEnv = (Hashtable<String, Object>)realEnv.clone(); } secureEnv.remove(key); } } }