List of usage examples for javax.naming NamingException getMessage
public String getMessage()
From source file:ldap.UserAccountImpl.java
public String getUserID() { try {/* w w w . j av a 2s . c om*/ //return get(Config.USER_NAMING_ATT).get().toString(); return get(LdapConstants.ldapDnAttrType).get().toString(); } catch (NamingException e) { logger.info("Unexpected Internal error in UserAccountImple: error was: " + e.getMessage()); return "Unexpected Internal error in UserAcountImple: error was" + e.getMessage(); } }
From source file:org.openhie.openempi.service.impl.KeyServerServiceImpl.java
public void authenticate(String username, String password) { KeyServiceLocator keyServiceLocator = Context.getKeyServiceLocator(); SecurityService securityService;/*from w w w . j a v a 2 s.c om*/ try { securityService = keyServiceLocator.getSecurityService(); sessionKey = securityService.authenticate(username, password); isAuthenticated = true; } catch (NamingException e) { e.printStackTrace(); log.error(e.getMessage()); } }
From source file:de.highbyte_le.weberknecht.request.taglibs.SiteBaseLinkTag.java
protected String getBaseUrl() throws JspException { if (!(pageContext.getRequest() instanceof HttpServletRequest)) throw new JspException("unable to get a HttpServletRequest"); StringBuilder baseUrl = new StringBuilder(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); try {/*from w w w.ja v a 2 s . c o m*/ ContextConfig conf = new ContextConfig(); baseUrl.append(conf.getValue("webapp_base_url")); if (baseUrl.charAt(baseUrl.length() - 1) != '/') baseUrl.append("/"); } catch (NamingException e) { logger.error("getTokenUrl() - naming exception while fetching webapp_base_url: " + e.getMessage()); //$NON-NLS-1$ logger.warn("automatically generating base URL"); String contextPath = request.getContextPath(); String localHost = request.getLocalName(); int localPort = request.getLocalPort(); if (baseUrl.length() > 0) //just to be sure baseUrl = new StringBuilder(); baseUrl.append("http://").append(localHost).append(":").append(localPort + contextPath).append("/"); } return baseUrl.toString(); }
From source file:org.overlord.sramp.governance.services.NotificationResource.java
/** * Constructor./* ww w . j av a2s. co m*/ * @throws NamingException */ public NotificationResource() { InitialContext context; try { String jndiEmailRef = governance.getJNDIEmailName(); context = new InitialContext(); mailSession = (Session) context.lookup(jndiEmailRef); if (mailSession == null) { logger.error(Messages.i18n.format("NotificationResource.JndiLookupFailed", jndiEmailRef)); //$NON-NLS-1$ } } catch (NamingException e) { logger.error(e.getMessage(), e); } }
From source file:ldap.UserAccountImpl.java
public String toString() { StringBuffer buffer = new StringBuffer(); String name = null;/*www. j a va 2 s. c o m*/ try { NamingEnumeration attList = getAll(); while (attList.hasMore()) { Attribute att = (Attribute) attList.next(); //if (att.getID().equals(Config.USER_NAMING_ATT)) if (att.getID().equals(LdapConstants.ldapAttrUid)) name = att.get().toString() + "\n"; buffer.append(" ").append(att.getID()).append(": "); if (att.size() == 1) buffer.append(att.get().toString()).append("\n"); else { NamingEnumeration values = att.getAll(); buffer.append("\n"); while (values.hasMore()) buffer.append(" ").append(values.next()).append("\n"); } } if (name != null) buffer.insert(0, name); } catch (NamingException e) { return "Unexpected Internal Error dumping UserAccount to text.\nError was: " + e.getMessage(); } return buffer.toString(); }
From source file:py.una.pol.karaku.util.LDAPUtil.java
private DirContext createInitialDirContext() { Map<Object, String> env = new HashMap<Object, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, propertiesUtil.get(LDAP_SERVER_KEY) + "/" + propertiesUtil.get(LDAP_DN_KEY)); env.put(Context.SECURITY_PRINCIPAL, propertiesUtil.get(LDAP_ADMIN_KEY)); env.put(Context.SECURITY_CREDENTIALS, propertiesUtil.get(LDAP_ADMIN_PASS_KEY)); try {//from w ww. ja v a 2s .c o m return new InitialDirContext(new Hashtable<Object, String>(env)); } catch (NamingException e) { throw new KarakuRuntimeException(e.getMessage(), e); } }
From source file:org.openhie.openempi.service.impl.KeyServerServiceImpl.java
public List<byte[]> getKeys(long keyId) { // TODO: if (!isAuthenticated) KeyServiceLocator keyServiceLocator = Context.getKeyServiceLocator(); List<byte[]> keyParts = null; try {/*from w w w . j a va 2 s .co m*/ KeyManagerService keyManagerService = keyServiceLocator.getKeyManagerService(); Key key = keyManagerService.getKey(sessionKey, keyId); keyParts = new ArrayList<byte[]>(); byte[] publicKeyPart1 = key.getPublicKeyPart1().clone(); keyParts.add(publicKeyPart1); byte[] publicKeyPart2 = key.getPublicKeyPart2().clone(); keyParts.add(publicKeyPart2); byte[] publicKeyPart3 = key.getPublicKeyPart3().clone(); keyParts.add(publicKeyPart3); byte[] privateKeyPart1 = key.getPrivateKeyPart1().clone(); keyParts.add(privateKeyPart1); byte[] privateKeyPart2 = key.getPrivateKeyPart2().clone(); keyParts.add(privateKeyPart2); byte[] privateKeyPart3 = key.getPrivateKeyPart3().clone(); keyParts.add(privateKeyPart3); } catch (NamingException e) { e.printStackTrace(); log.error(e.getMessage()); } catch (ApplicationException e) { e.printStackTrace(); log.error(e.getMessage()); } return keyParts; }
From source file:org.wso2.carbon.identity.agent.onprem.userstore.manager.ldap.LDAPConnectionContext.java
/** * @return Connection context of the LDAP userstore. * @throws UserStoreException If an error occurs while connecting to th userstore. *//*from w ww . java 2 s . com*/ DirContext getContext() throws UserStoreException { DirContext context; try { context = new InitialDirContext(environment); } catch (NamingException e) { log.error("Error obtaining connection. " + e.getMessage(), e); log.error("Trying again to get connection."); try { context = new InitialDirContext(environment); } catch (Exception e1) { log.error("Error obtaining connection for the second time" + e.getMessage(), e); throw new UserStoreException("Error obtaining connection. " + e.getMessage(), e); } } return (context); }
From source file:org.openhie.openempi.service.impl.KeyServerServiceImpl.java
public List<byte[]> getSalts(int numberOfSalts) { // TODO: if (!isAuthenticated) synchronized (salts) { if (salts == null || salts.size() <= 0) { PrivacySettings privacySettings = (PrivacySettings) Context.getConfiguration() .lookupConfigurationEntry(ConfigurationRegistry.RECORD_LINKAGE_PROTOCOL_SETTINGS); KeyServerSettings keyServerSettings = privacySettings.getComponentSettings().getKeyServerSettings(); KeyServiceLocator keyServiceLocator = Context.getKeyServiceLocator(); try { if (salts == null) salts = new ArrayList<byte[]>(); SaltManagerService saltManagerService = keyServiceLocator.getSaltManagerService(); List<Salt> slts = saltManagerService.getSalts(sessionKey, keyServerSettings.getSaltIdStart(), keyServerSettings.getSaltIdStart() + keyServerSettings.getNumberOfSalts() - 1); for (Salt s : slts) { salts.add(s.getSalt()); }/*from www. j a va 2s . co m*/ } catch (NamingException e) { e.printStackTrace(); log.error(e.getMessage()); } catch (ApplicationException e) { e.printStackTrace(); log.error(e.getMessage()); } } } return salts.subList(0, numberOfSalts); }
From source file:py.una.pol.karaku.util.LDAPUtil.java
/** * Recupera los usuarios de LDAP//from www. j a va 2 s .co m * * @return Una lista con los usuarios de LDAP */ public List<User> getUsers() { List<User> users = new ArrayList<User>(); try { DirContext ctx = createInitialDirContext(); Attributes matchAttrs = new BasicAttributes(true); matchAttrs.put(new BasicAttribute("uid")); NamingEnumeration<SearchResult> answer = ctx.search("ou=users", matchAttrs); while (answer.hasMore()) { SearchResult sr = answer.next(); String uid = sr.getName().substring(4); // No se retornan los usuarios especiales if (!uid.startsWith(LDAP_SPECIAL_USER_PREFIX) && !ListHelper.contains(EXCLUDED_USERS, uid)) { User user = new User(); user.setUid(uid); Attributes atributos = sr.getAttributes(); String cn = atributos.get("cn").toString().substring(4); user.setCn(cn); users.add(user); } } } catch (NamingException e) { throw new KarakuRuntimeException(e.getMessage(), e); } return users; }