@Override public void close() { try { this.dnsContext.close(); } catch (NamingException e) { log.warn(e.getLocalizedMessage(), e); } }
private String findUserDN(final String userName, final LdapContextFactory ldapContextFactory) { LdapContext systemLdapCtx = null; try { systemLdapCtx = ldapContextFactory.getSystemLdapContext(); final NamingEnumeration<SearchResult> usersFound = systemLdapCtx.search(searchBase, dnSearchFilter.replace(USERDN_SUBSTITUTION_TOKEN, userName), SUBTREE_SCOPE); return usersFound.hasMore() ? usersFound.next().getNameInNamespace() : null; } catch (final AuthenticationException ex) { log.info("LDAP authentication exception='{}'", ex.getLocalizedMessage()); throw new IllegalArgumentException(ex); } catch (final NamingException e) { log.info("LDAP exception='{}'", e.getLocalizedMessage()); throw new IllegalArgumentException(e); } finally { LdapUtils.closeContext(systemLdapCtx); } }
jndiPath + " - " + ne.getLocalizedMessage());
public SearchResult nextElement() { try { return next(); } catch ( NamingException e ) { throw new NoSuchElementException( e.getLocalizedMessage() ); } } }
@Override public void close() { try { this.dnsContext.close(); } catch (NamingException e) { log.warn(e.getLocalizedMessage(), e); } }
public DirContext createContext(String userDN, String userPassword) { if(!options.containsKey(KEY_LDAP) || !options.containsKey(KEY_LDAP_PORT)) { logger.debug("No LDAP url configured, skipping LDAP authentication"); return null; } DirContext ctx = null; Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); String providerUrl = MessageFormat.format("ldap://{0}:{1}/{2}", options.get(KEY_LDAP), options.get(KEY_LDAP_PORT), options.get(KEY_ROOT_DN)); env.put(Context.PROVIDER_URL, providerUrl); if(userDN!=null) env.put(Context.SECURITY_PRINCIPAL, userDN); env.put(Context.SECURITY_AUTHENTICATION, "simple"); if(userPassword!=null) env.put(Context.SECURITY_CREDENTIALS, userPassword); try { ctx = new InitialDirContext(env); } catch (NamingException e) { logger.warn("Cannot bind user with userDN = " + userDN + " with exception " + e.getLocalizedMessage()); } return ctx; }
object = initialContext.lookup( jndiName ); } catch ( NamingException e ) { String msg = "Error retrieving JNDI DataSource '" + jndiName + "': " + e.getLocalizedMessage(); LOG.error( msg, e ); throw e;
private void findDataSource() { if (injecteddatasource == null) { if (jndiName == null) { throw new IllegalStateException("No jndiName has been configured"); } try { datasource = (DataSource) new InitialContext().lookup(jndiName); getLogger().debug("DataSource found at " + jndiName); } catch (NamingException e) { throw new IllegalStateException("Caught NamingException looking up DataSource at " + jndiName + " -- " + e .getLocalizedMessage()); } } else { datasource = injecteddatasource; } }
public Object doMap(Object input, Map param) throws MapperException { try { if(log.isDebugEnabled()) log.debug("["+getName()+"] deleting "+_root); directory.destroySubcontext(_root); if(log.isDebugEnabled()) log.debug("["+getName()+"] done"); return input; } catch (NamingException e) { throw new MapperException("Exception in JNDI deleting " + e.getLocalizedMessage(), e); } }
public void setAlias(String newAlias) { if ( newAlias != null && newAlias.equals(alias ) ){ return ; } this.alias = newAlias ; try { save() ; } catch (NamingException ne) { // should never be here. RuntimeException ree = new RuntimeException(ne.getLocalizedMessage()) ; ree.fillInStackTrace() ; throw ree ; } } public String getAlias() {
private InitialContext newContext() { Properties properties = new Properties(); InitialContext newContext; Map env; try { env = context.getEnvironment(); Object o = env.get(NAMING_FACTORY_INITIAL); if (o != null) { properties.put(NAMING_FACTORY_INITIAL, o); } o = env.get(CONNECTION_STRING); if (o != null) { properties.put(CONNECTION_STRING, o); } o = env.get(PROVIDER_URL); if (o != null) { properties.put(PROVIDER_URL, o); } properties.put(QUEUE_PREFIX + destination, destination); newContext = new InitialContext(properties); } catch (NamingException e) { logger.info(nameString() + " could not create a new Context. Message:" + e.getLocalizedMessage()); return null; } if (logger.isDebugEnabled()) { logger.debug(nameString() + " Created a new Context."); } return newContext; }
jndiPath + " - " + ne.getLocalizedMessage());
private String findUserDN(final String userName, final LdapContextFactory ldapContextFactory) { LdapContext systemLdapCtx = null; try { systemLdapCtx = ldapContextFactory.getSystemLdapContext(); final NamingEnumeration<SearchResult> usersFound = systemLdapCtx.search(searchBase, dnSearchFilter.replace(USERDN_SUBSTITUTION_TOKEN, userName), SUBTREE_SCOPE); return usersFound.hasMore() ? usersFound.next().getNameInNamespace() : null; } catch (final AuthenticationException ex) { log.info("LDAP authentication exception='{}'", ex.getLocalizedMessage()); throw new IllegalArgumentException(ex); } catch (final NamingException e) { log.info("LDAP exception='{}'", e.getLocalizedMessage()); throw new IllegalArgumentException(e); } finally { LdapUtils.closeContext(systemLdapCtx); } }
LOG.debug(e.getLocalizedMessage(), e);
throw new LoginException("login failed caused by " + ne.getLocalizedMessage()); }finally{ closeQuietly(ctx);
protected Object doMap(Object input, Map env) throws MapperException { if(attributesFromInput == null) throw new MapperException(getName()+": Undefined transformation mapper"); try { if (log.isDebugEnabled()) log.debug("[" + getName() + "] adding root=" + _root + " with attributes=" + input); /* transform */ Attributes attrs = (Attributes) attributesFromInput.map(input,env); directory.createSubcontext(_root, attrs); if (log.isDebugEnabled()) log.debug("[" + getName() + "] done"); } catch (NamingException e) { throw new MapperException("Exception in JNDI adding " + e.getLocalizedMessage(), e); } return input; }
} catch (NamingException e) { throw new MapperException("Exception in JNDI mapping " + e.getLocalizedMessage(), e);
if (logger.isDebugEnabled()) { logger.debug(nameString() + ". Could not lookup destination [" + destination + "]. Message: " + e.getLocalizedMessage());
public Set<ResourceRecord> getRecords( QuestionRecord question ) throws DnsException { try { GetRecords getRecords = new GetRecords( question ); String baseDn = catalog.getBaseDn( question.getDomainName() ); CoreSession session = directoryService.getSession(); DirContext dirContext = new ServerLdapContext( directoryService, session, new LdapName( baseDn ) ); return getRecords.execute( dirContext, null ); } catch ( LdapNoSuchObjectException lnnfe ) { LOG.debug( "Name for DNS record search does not exist.", lnnfe ); throw new DnsException( ResponseCode.NAME_ERROR ); } catch ( NamingException ne ) { LOG.error( ne.getLocalizedMessage(), ne ); String message = I18n.err( I18n.ERR_157, question.getDomainName() ); throw new ServiceConfigurationException( message, ne ); } catch ( Exception e ) { LOG.debug( "Unexpected error retrieving DNS records.", e ); throw new DnsException( ResponseCode.SERVER_FAILURE ); } } }
} catch (NamingException e) { report.setMessage(localStrings.getLocalString("list.jndi.entries.namingexception", "Naming Exception caught.") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e);