javax.naming.event.EventDirContext Java Examples

The following examples show how to use javax.naming.event.EventDirContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JndiLdapAdditionalSignature.java    From Android_Code_Arbiter with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void ldapInjectionSunApi(String input) throws NamingException {
    //Stub instances
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    props.put(Context.PROVIDER_URL, "ldap://ldap.example.com");
    props.put(Context.REFERRAL, "ignore");

    SearchControls ctrls = new SearchControls();
    ctrls.setReturningAttributes(new String[]{"givenName", "sn"});
    ctrls.setSearchScope(SearchControls.SUBTREE_SCOPE);

    //Two context instances mostly usable with sun specific API
    LdapCtx            context5 = null;
    EventDirContext    context6 = null; //LdapCtx is the only known class to implements to this interface

    NamingEnumeration<SearchResult> answers;
    answers = context5.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", ctrls);
    answers = context5.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", new Object[0], ctrls);
    answers = context5.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", ctrls);
    answers = context5.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", new Object[0], ctrls);

    answers = context6.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", ctrls);
    answers = context6.search(new LdapName("dc=People,dc=example,dc=com"), "(uid=" + input + ")", new Object[0], ctrls);
    answers = context6.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", ctrls);
    answers = context6.search("dc=People,dc=example,dc=com", "(uid=" + input + ")", new Object[0], ctrls);
}
 
Example #2
Source File: LegacyLDAPSecuritySettingPlugin.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void open() throws NamingException {
   if (isContextAlive()) {
      return;
   }

   context = createContext();
   eventContext = ((EventDirContext) context.lookup(""));

   SearchControls searchControls = new SearchControls();
   searchControls.setReturningAttributes(new String[]{roleAttribute});
   searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);

   if (enableListener) {
      eventContext.addNamingListener(destinationBase, filter, searchControls, new LDAPNamespaceChangeListener());
   }
}
 
Example #3
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private EventDirContext getEventDirContext(String name) throws NamingException {
    EventContext eventContext = getEventContext(name);
    if (eventContext instanceof EventDirContext) {
        return (EventDirContext) eventContext;
    }
    throw new NamingException("The given Context is not an instance of "
                              + EventDirContext.class.getName());
}
 
Example #4
Source File: CarbonContextDataHolder.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private EventDirContext getEventDirContext(Name name) throws NamingException {
    return getEventDirContext(name.get(0));
}