001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.security.ejb.project.support;
023:
024: import java.util.Hashtable;
025: import javax.naming.CompositeName;
026: import javax.naming.Context;
027: import javax.naming.Name;
028: import javax.naming.NamingEnumeration;
029: import javax.naming.NamingException;
030: import javax.naming.NameParser;
031: import javax.naming.directory.Attribute;
032: import javax.naming.directory.Attributes;
033: import javax.naming.directory.BasicAttributes;
034: import javax.naming.directory.DirContext;
035: import javax.naming.directory.ModificationItem;
036: import javax.naming.directory.SearchControls;
037:
038: /** An abstract implementation of DirContext that simply takes every DirContext
039: method that accepts the String form of a Name and invokes the corresponding
040: method that accecpts a Name.
041:
042: @author Scott_Stark@displayscape.com
043: @version $Id: DirContextStringImpl.java 57211 2006-09-26 12:39:46Z dimitris@jboss.org $
044: */
045: public abstract class DirContextStringImpl implements DirContext {
046: private NameParser nameParser;
047:
048: /** Creates new DirContextStringImpl */
049: public DirContextStringImpl(NameParser nameParser) {
050: this .nameParser = nameParser;
051: }
052:
053: public DirContextStringImpl() {
054: this (DefaultName.getNameParser());
055: }
056:
057: // --- Begin DirContext interface methods that accept a String name
058: public void bind(java.lang.String name, Object obj)
059: throws NamingException {
060: bind(nameParser.parse(name), obj);
061: }
062:
063: public String composeName(String name, String name1)
064: throws NamingException {
065: return null;
066: }
067:
068: public Context createSubcontext(java.lang.String name)
069: throws NamingException {
070: return createSubcontext(nameParser.parse(name));
071: }
072:
073: public void destroySubcontext(java.lang.String name)
074: throws NamingException {
075: destroySubcontext(nameParser.parse(name));
076: }
077:
078: public NameParser getNameParser(java.lang.String name)
079: throws NamingException {
080: return getNameParser(nameParser.parse(name));
081: }
082:
083: public NamingEnumeration list(java.lang.String name)
084: throws NamingException {
085: return list(nameParser.parse(name));
086: }
087:
088: public NamingEnumeration listBindings(java.lang.String name)
089: throws NamingException {
090: return listBindings(nameParser.parse(name));
091: }
092:
093: public java.lang.Object lookup(String name) throws NamingException {
094: return lookup(nameParser.parse(name));
095: }
096:
097: public java.lang.Object lookupLink(String name)
098: throws NamingException {
099: return lookupLink(nameParser.parse(name));
100: }
101:
102: public void rebind(String name, Object obj) throws NamingException {
103: rebind(nameParser.parse(name), obj);
104: }
105:
106: public void rename(String name, String name1)
107: throws NamingException {
108: rename(nameParser.parse(name), nameParser.parse(name1));
109: }
110:
111: public void unbind(String name) throws NamingException {
112: unbind(nameParser.parse(name));
113: }
114:
115: public void bind(String name, Object obj, Attributes attributes)
116: throws NamingException {
117: bind(nameParser.parse(name), obj, attributes);
118: }
119:
120: public DirContext createSubcontext(String name,
121: Attributes attributes) throws NamingException {
122: return createSubcontext(nameParser.parse(name), attributes);
123: }
124:
125: public Attributes getAttributes(String name) throws NamingException {
126: return getAttributes(nameParser.parse(name));
127: }
128:
129: public Attributes getAttributes(String name, String[] attrNames)
130: throws NamingException {
131: return getAttributes(nameParser.parse(name), attrNames);
132: }
133:
134: public DirContext getSchema(String name) throws NamingException {
135: return getSchema(nameParser.parse(name));
136: }
137:
138: public DirContext getSchemaClassDefinition(String name)
139: throws NamingException {
140: return getSchemaClassDefinition(nameParser.parse(name));
141: }
142:
143: public void modifyAttributes(String name,
144: ModificationItem[] modificationItem) throws NamingException {
145: modifyAttributes(nameParser.parse(name), modificationItem);
146: }
147:
148: public void modifyAttributes(String name, int index,
149: Attributes attributes) throws NamingException {
150: modifyAttributes(nameParser.parse(name), index, attributes);
151: }
152:
153: public void rebind(String name, Object obj, Attributes attributes)
154: throws NamingException {
155: rebind(nameParser.parse(name), obj, attributes);
156: }
157:
158: public NamingEnumeration search(String name, Attributes attributes)
159: throws NamingException {
160: return search(nameParser.parse(name), attributes);
161: }
162:
163: public NamingEnumeration search(String name, String name1,
164: SearchControls searchControls) throws NamingException {
165: return search(nameParser.parse(name), name1, searchControls);
166: }
167:
168: public NamingEnumeration search(String name, Attributes attributes,
169: String[] str2) throws NamingException {
170: return search(nameParser.parse(name), attributes, str2);
171: }
172:
173: public NamingEnumeration search(String name, String name1,
174: Object[] obj, SearchControls searchControls)
175: throws NamingException {
176: return null;
177: }
178:
179: // --- End DirContext interface methods
180:
181: }
|