Class DelegatingLdapContext
- java.lang.Object
-
- org.wildfly.security.auth.realm.ldap.DelegatingLdapContext
-
- All Implemented Interfaces:
Context
,DirContext
,LdapContext
class DelegatingLdapContext extends Object implements LdapContext
DelegatingLdapContext
allowing redefine close and reconnect operations. Used bySimpleDirContextFactoryBuilder
to ensure context returning instead of close. If the context is copied usingnewInstance(Control[])
, close handler will not used by the copy. On the other hand, reconnect handler will used by both of them. If non-Ldap context is obtained, LdapContext specific methods throwsUnsupportedOperationException
.- Author:
- Jan Kalina
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
DelegatingLdapContext.CloseHandler
-
Field Summary
Fields Modifier and Type Field Description private DelegatingLdapContext.CloseHandler
closeHandler
private DirContext
delegating
private SocketFactory
socketFactory
-
Fields inherited from interface javax.naming.Context
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES
-
Fields inherited from interface javax.naming.directory.DirContext
ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE
-
Fields inherited from interface javax.naming.ldap.LdapContext
CONTROL_FACTORIES
-
-
Constructor Summary
Constructors Modifier Constructor Description private
DelegatingLdapContext(DirContext delegating, SocketFactory socketFactory)
(package private)
DelegatingLdapContext(DirContext delegating, DelegatingLdapContext.CloseHandler closeHandler, SocketFactory socketFactory)
-
Method Summary
-
-
-
Field Detail
-
delegating
private final DirContext delegating
-
closeHandler
private final DelegatingLdapContext.CloseHandler closeHandler
-
socketFactory
private final SocketFactory socketFactory
-
-
Constructor Detail
-
DelegatingLdapContext
DelegatingLdapContext(DirContext delegating, DelegatingLdapContext.CloseHandler closeHandler, SocketFactory socketFactory) throws NamingException
- Throws:
NamingException
-
DelegatingLdapContext
private DelegatingLdapContext(DirContext delegating, SocketFactory socketFactory) throws NamingException
- Throws:
NamingException
-
-
Method Detail
-
newInitialLdapContext
public LdapContext newInitialLdapContext(Hashtable<?,?> environment, Control[] connCtls) throws NamingException
- Throws:
NamingException
-
close
public void close() throws NamingException
- Specified by:
close
in interfaceContext
- Throws:
NamingException
-
wrap
private NamingEnumeration<SearchResult> wrap(NamingEnumeration<SearchResult> delegating)
-
wrapReferralContextObtaining
public DelegatingLdapContext wrapReferralContextObtaining(ReferralException e) throws NamingException
- Throws:
NamingException
-
extendedOperation
public ExtendedResponse extendedOperation(ExtendedRequest request) throws NamingException
- Specified by:
extendedOperation
in interfaceLdapContext
- Throws:
NamingException
-
newInstance
public LdapContext newInstance(Control[] requestControls) throws NamingException
- Specified by:
newInstance
in interfaceLdapContext
- Throws:
NamingException
-
reconnect
public void reconnect(Control[] controls) throws NamingException
- Specified by:
reconnect
in interfaceLdapContext
- Throws:
NamingException
-
getConnectControls
public Control[] getConnectControls() throws NamingException
- Specified by:
getConnectControls
in interfaceLdapContext
- Throws:
NamingException
-
setRequestControls
public void setRequestControls(Control[] requestControls) throws NamingException
- Specified by:
setRequestControls
in interfaceLdapContext
- Throws:
NamingException
-
getRequestControls
public Control[] getRequestControls() throws NamingException
- Specified by:
getRequestControls
in interfaceLdapContext
- Throws:
NamingException
-
getResponseControls
public Control[] getResponseControls() throws NamingException
- Specified by:
getResponseControls
in interfaceLdapContext
- Throws:
NamingException
-
bind
public void bind(String name, Object obj, Attributes attrs) throws NamingException
- Specified by:
bind
in interfaceDirContext
- Throws:
NamingException
-
getAttributes
public Attributes getAttributes(Name name) throws NamingException
- Specified by:
getAttributes
in interfaceDirContext
- Throws:
NamingException
-
getAttributes
public Attributes getAttributes(String name) throws NamingException
- Specified by:
getAttributes
in interfaceDirContext
- Throws:
NamingException
-
getAttributes
public Attributes getAttributes(Name name, String[] attrIds) throws NamingException
- Specified by:
getAttributes
in interfaceDirContext
- Throws:
NamingException
-
getAttributes
public Attributes getAttributes(String name, String[] attrIds) throws NamingException
- Specified by:
getAttributes
in interfaceDirContext
- Throws:
NamingException
-
modifyAttributes
public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException
- Specified by:
modifyAttributes
in interfaceDirContext
- Throws:
NamingException
-
modifyAttributes
public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException
- Specified by:
modifyAttributes
in interfaceDirContext
- Throws:
NamingException
-
modifyAttributes
public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException
- Specified by:
modifyAttributes
in interfaceDirContext
- Throws:
NamingException
-
modifyAttributes
public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException
- Specified by:
modifyAttributes
in interfaceDirContext
- Throws:
NamingException
-
bind
public void bind(Name name, Object obj, Attributes attrs) throws NamingException
- Specified by:
bind
in interfaceDirContext
- Throws:
NamingException
-
rebind
public void rebind(Name name, Object obj, Attributes attrs) throws NamingException
- Specified by:
rebind
in interfaceDirContext
- Throws:
NamingException
-
rebind
public void rebind(String name, Object obj, Attributes attrs) throws NamingException
- Specified by:
rebind
in interfaceDirContext
- Throws:
NamingException
-
createSubcontext
public DirContext createSubcontext(Name name, Attributes attrs) throws NamingException
- Specified by:
createSubcontext
in interfaceDirContext
- Throws:
NamingException
-
createSubcontext
public DirContext createSubcontext(String name, Attributes attrs) throws NamingException
- Specified by:
createSubcontext
in interfaceDirContext
- Throws:
NamingException
-
getSchema
public DirContext getSchema(Name name) throws NamingException
- Specified by:
getSchema
in interfaceDirContext
- Throws:
NamingException
-
getSchema
public DirContext getSchema(String name) throws NamingException
- Specified by:
getSchema
in interfaceDirContext
- Throws:
NamingException
-
getSchemaClassDefinition
public DirContext getSchemaClassDefinition(Name name) throws NamingException
- Specified by:
getSchemaClassDefinition
in interfaceDirContext
- Throws:
NamingException
-
getSchemaClassDefinition
public DirContext getSchemaClassDefinition(String name) throws NamingException
- Specified by:
getSchemaClassDefinition
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes, String[] attributesToReturn) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes, String[] attributesToReturn) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(String name, Attributes matchingAttributes) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(Name name, String filter, SearchControls cons) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(String name, String filter, SearchControls cons) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(Name name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
search
public NamingEnumeration<SearchResult> search(String name, String filterExpr, Object[] filterArgs, SearchControls cons) throws NamingException
- Specified by:
search
in interfaceDirContext
- Throws:
NamingException
-
lookup
public Object lookup(Name name) throws NamingException
- Specified by:
lookup
in interfaceContext
- Throws:
NamingException
-
lookup
public Object lookup(String name) throws NamingException
- Specified by:
lookup
in interfaceContext
- Throws:
NamingException
-
bind
public void bind(Name name, Object obj) throws NamingException
- Specified by:
bind
in interfaceContext
- Throws:
NamingException
-
bind
public void bind(String name, Object obj) throws NamingException
- Specified by:
bind
in interfaceContext
- Throws:
NamingException
-
rebind
public void rebind(Name name, Object obj) throws NamingException
- Specified by:
rebind
in interfaceContext
- Throws:
NamingException
-
rebind
public void rebind(String name, Object obj) throws NamingException
- Specified by:
rebind
in interfaceContext
- Throws:
NamingException
-
unbind
public void unbind(Name name) throws NamingException
- Specified by:
unbind
in interfaceContext
- Throws:
NamingException
-
unbind
public void unbind(String name) throws NamingException
- Specified by:
unbind
in interfaceContext
- Throws:
NamingException
-
rename
public void rename(Name oldName, Name newName) throws NamingException
- Specified by:
rename
in interfaceContext
- Throws:
NamingException
-
rename
public void rename(String oldName, String newName) throws NamingException
- Specified by:
rename
in interfaceContext
- Throws:
NamingException
-
list
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException
- Specified by:
list
in interfaceContext
- Throws:
NamingException
-
list
public NamingEnumeration<NameClassPair> list(String name) throws NamingException
- Specified by:
list
in interfaceContext
- Throws:
NamingException
-
listBindings
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException
- Specified by:
listBindings
in interfaceContext
- Throws:
NamingException
-
listBindings
public NamingEnumeration<Binding> listBindings(String name) throws NamingException
- Specified by:
listBindings
in interfaceContext
- Throws:
NamingException
-
destroySubcontext
public void destroySubcontext(Name name) throws NamingException
- Specified by:
destroySubcontext
in interfaceContext
- Throws:
NamingException
-
destroySubcontext
public void destroySubcontext(String name) throws NamingException
- Specified by:
destroySubcontext
in interfaceContext
- Throws:
NamingException
-
createSubcontext
public Context createSubcontext(Name name) throws NamingException
- Specified by:
createSubcontext
in interfaceContext
- Throws:
NamingException
-
createSubcontext
public Context createSubcontext(String name) throws NamingException
- Specified by:
createSubcontext
in interfaceContext
- Throws:
NamingException
-
lookupLink
public Object lookupLink(Name name) throws NamingException
- Specified by:
lookupLink
in interfaceContext
- Throws:
NamingException
-
lookupLink
public Object lookupLink(String name) throws NamingException
- Specified by:
lookupLink
in interfaceContext
- Throws:
NamingException
-
getNameParser
public NameParser getNameParser(Name name) throws NamingException
- Specified by:
getNameParser
in interfaceContext
- Throws:
NamingException
-
getNameParser
public NameParser getNameParser(String name) throws NamingException
- Specified by:
getNameParser
in interfaceContext
- Throws:
NamingException
-
composeName
public Name composeName(Name name, Name prefix) throws NamingException
- Specified by:
composeName
in interfaceContext
- Throws:
NamingException
-
composeName
public String composeName(String name, String prefix) throws NamingException
- Specified by:
composeName
in interfaceContext
- Throws:
NamingException
-
addToEnvironment
public Object addToEnvironment(String propName, Object propVal) throws NamingException
- Specified by:
addToEnvironment
in interfaceContext
- Throws:
NamingException
-
removeFromEnvironment
public Object removeFromEnvironment(String propName) throws NamingException
- Specified by:
removeFromEnvironment
in interfaceContext
- Throws:
NamingException
-
getEnvironment
public Hashtable<?,?> getEnvironment() throws NamingException
- Specified by:
getEnvironment
in interfaceContext
- Throws:
NamingException
-
getNameInNamespace
public String getNameInNamespace() throws NamingException
- Specified by:
getNameInNamespace
in interfaceContext
- Throws:
NamingException
-
setSocketFactory
private ClassLoader setSocketFactory()
-
unsetSocketFactory
private void unsetSocketFactory(ClassLoader previous)
-
getSocketFactoryClassLoader
private ClassLoader getSocketFactoryClassLoader()
-
setClassLoaderTo
private ClassLoader setClassLoaderTo(ClassLoader targetClassLoader)
-
doPrivileged
private static <T> T doPrivileged(PrivilegedAction<T> action)
-
-