List of usage examples for javax.naming Context SECURITY_PRINCIPAL
String SECURITY_PRINCIPAL
To view the source code for javax.naming Context SECURITY_PRINCIPAL.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "ldap://localhost/o=JNDITutorial"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); DirContext ctx = new InitialDirContext(env); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "ldap://localhost/o=JNDITutorial"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); // Create connection controls to use Control[] connectCtls = new Control[] { null }; LdapContext ctx = new InitialLdapContext(env, connectCtls); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "ldap://localhost/o=JNDITutorial"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); LdapContext ctx = new InitialLdapContext(env, null); NamingEnumeration answer = ctx.search("ou=People", "(cn=*)", null); System.out.println(ctx.getResponseControls()); while (answer.hasMore()) { SearchResult si = (SearchResult) answer.next(); if (si instanceof HasControls) { System.out.println(((HasControls) si).getControls()); }//www. j a v a2 s . com } System.out.println(ctx.getResponseControls()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "YourURL"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); EventContext ctx = (EventContext) (new InitialContext(env).lookup("ou=People")); NamingListener listener = new SampleNCListener(); ctx.addNamingListener("cn=John", EventContext.ONELEVEL_SCOPE, listener); }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "ldap://localhost/o=JNDITutorial"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); Control[] connectCtls = new Control[] { null }; LdapContext ctx = new InitialLdapContext(env, null); Control[] ctxCtls = new Control[] { new SortControl(new String[] { "cn" }, Control.CRITICAL) }; ctx.setRequestControls(ctxCtls);/*from w ww. ja va2 s . c o m*/ NamingEnumeration answer = ctx.list(""); while (answer.hasMore()) { NameClassPair item = (NameClassPair) answer.next(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { String url = "ldap://localhost/o=JNDITutorial"; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "userDN"); env.put(Context.SECURITY_CREDENTIALS, "secret"); EventDirContext ctx = (EventDirContext) (new InitialContext(env).lookup("ou=People")); NamingListener listener = new SampleObjListener(); SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); String filter = "(mail=*)"; ctx.addNamingListener("cn=YourName", filter, ctls, listener); }
From source file:Main.java
public static void main(String args[]) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); env.put(Context.PROVIDER_URL, MY_HOST); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, MGR_DN); env.put(Context.SECURITY_CREDENTIALS, MGR_PW); DirContext ctx = new InitialDirContext(env); Person p = new Person(); ctx.bind("uid=mewilcox, ou=People, o=airius.com", p); }
From source file:Main.java
public static void main(String args[]) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); env.put(Context.PROVIDER_URL, MY_HOST); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, MGR_DN); env.put(Context.SECURITY_CREDENTIALS, MGR_PW); DirContext ctx = new InitialDirContext(env); ctx.destroySubcontext(MY_ENTRY);/*from w w w.j av a2 s .com*/ }
From source file:Main.java
public static void main(String args[]) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX); env.put(Context.PROVIDER_URL, MY_HOST); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, MGR_DN); env.put(Context.SECURITY_CREDENTIALS, MGR_PW); DirContext ctx = new InitialDirContext(env); ModificationItem[] mods = new ModificationItem[2]; Attribute mod0 = new BasicAttribute("number", "555-555-5555"); Attribute mod1 = new BasicAttribute("1", "AAA"); mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, mod0); mods[1] = new ModificationItem(DirContext.ADD_ATTRIBUTE, mod1); ctx.modifyAttributes("uid=mewilcox, ou=People, o=airius.com", mods); }
From source file:org.overlord.sramp.performance.BasicPerformanceTest.java
public static void main(String[] args) { try {/*w w w. ja va 2 s . co m*/ Properties jndiProps = new Properties(); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080"); // jndiProps.put(Context.PROVIDER_URL, "remote://localhost:4447"); jndiProps.put(Context.SECURITY_PRINCIPAL, "admin"); jndiProps.put(Context.SECURITY_CREDENTIALS, "artificer1!"); jndiProps.put("jboss.naming.client.ejb.context", true); Context context = new InitialContext(jndiProps); final ArtifactService artifactService = (ArtifactService) context .lookup("artificer-server/ArtifactService!" + ArtifactService.class.getName()); artifactService.login("artificer", "artificer1!"); final BatchService batchService = (BatchService) context .lookup("artificer-server/BatchService!" + BatchService.class.getName()); batchService.login("artificer", "artificer1!"); final QueryService queryService = (QueryService) context .lookup("artificer-server/QueryService!" + QueryService.class.getName()); queryService.login("artificer", "artificer1!"); xsdTest(artifactService); xsdBatchTest(batchService); queryTest(artifactService, queryService); fullTextSearchTest(queryService); } catch (Exception e) { e.printStackTrace(); } }