public void setNextFilesystemReference(String next) throws ConfigurationException { if (next != null && next.equals(this.id)) { throw new ConfigurationException("Next filesystem must not reference itself!"); } this.nextFilesystemReference = next; }
private static Properties loadProperties(URL url) throws ConfigurationException { Properties p = new Properties(); try (InputStream stream = url.openStream()) { p.load(stream); } catch (IOException e) { LOG.error("Failed to load LDAP configuration from '{}' " + "- you may change the sub-directory name by System Property '{}'", url, APP_NAME_PROPERTY); throw new ConfigurationException(e); } return p; }
private static Properties loadProperties(URL url) throws ConfigurationException { Properties p = new Properties(); try (InputStream stream = url.openStream()) { p.load(stream); } catch (IOException e) { LOG.error("Failed to load LDAP configuration from '{}' " + "- you may change the sub-directory name by System Property '{}'", url, APP_NAME_PROPERTY); throw new ConfigurationException(e); } return p; }
@Override public synchronized void persistCertificates(String dn, X509Certificate... certs) throws ConfigurationException { try { storeCertificates(dn, certs); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } catch (CertificateEncodingException e) { throw new ConfigurationException(e); } }
@Override public synchronized X509Certificate[] findCertificates(String dn) throws ConfigurationException { try { return loadCertificates(dn); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } catch (CertificateException e) { throw new ConfigurationException(e); } }
@Override public synchronized void persistCertificates(String dn, X509Certificate... certs) throws ConfigurationException { try { storeCertificates(dn, certs); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } catch (CertificateEncodingException e) { throw new ConfigurationException(e); } }
@Override public synchronized X509Certificate[] findCertificates(String dn) throws ConfigurationException { try { return loadCertificates(dn); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } catch (CertificateException e) { throw new ConfigurationException(e); } }
private FilesystemGroup getFilesystemGroupCfg(String groupID) throws ConfigurationException { FilesystemGroup grp = cfg == null ? null : cfg.getFilesystemGroup(groupID); if (grp == null) { throw new ConfigurationException("Filesystem group with ID "+groupID+" not found!"); } return grp; }
@SuppressWarnings("unchecked") public LdapDicomConfiguration(Hashtable<?,?> env) throws ConfigurationException { Hashtable<String,String> map = new Hashtable(); for (Map.Entry<?, ?> entry : env.entrySet()) map.put((String) entry.getKey(), StringUtils.replaceSystemProperties((String) entry.getValue())); try { // split baseDN from LDAP URL String s = map.get(Context.PROVIDER_URL); int end = s.lastIndexOf('/'); map.put(Context.PROVIDER_URL, s.substring(0, end)); this.baseDN = s.substring(end+1); this.ctx = new ReconnectDirContext(map); } catch (Exception e) { throw new ConfigurationException(e); } }
private Properties ldapEnv() throws ConfigurationException { String url = System.getProperty(LDAP_PROPERTIES_PROPERTY); url = StringUtils.replaceSystemProperties(url); Properties p = new Properties(); try (InputStream in = StreamUtils.openFileOrURL(url);) { p.load(in); } catch (IOException e) { throw new ConfigurationException(e); } return p; }
@SuppressWarnings("unchecked") public LdapDicomConfiguration(Hashtable<?,?> env) throws ConfigurationException { Hashtable<String,String> map = new Hashtable(); for (Map.Entry<?, ?> entry : env.entrySet()) map.put((String) entry.getKey(), StringUtils.replaceSystemProperties((String) entry.getValue())); try { // split baseDN from LDAP URL String s = map.get(Context.PROVIDER_URL); int end = s.lastIndexOf('/'); map.put(Context.PROVIDER_URL, s.substring(0, end)); this.baseDN = s.substring(end+1); this.ctx = new ReconnectDirContext(map); } catch (Exception e) { throw new ConfigurationException(e); } }
public synchronized String[] list(String dn, String filter, String attrID) throws ConfigurationException { ArrayList<String> values = new ArrayList<String>(); NamingEnumeration<SearchResult> ne = null; try { ne = search(dn, filter, attrID ); while (ne.hasMore()) { SearchResult sr = ne.next(); Attributes attrs = sr.getAttributes(); values.add(LdapUtils.stringValue(attrs.get(attrID), null)); } } catch (NamingException e) { throw new ConfigurationException(e); } finally { LdapUtils.safeClose(ne); } return values.toArray(new String[values.size()]); }
public static Properties getInitialEnvironment() throws ConfigurationException { ClassLoader cl = getContextClassLoader(); synchronized (propertiesCache) { Properties props = propertiesCache.get(cl); if (props != null) return props; props = new Properties(); InputStream is = getResourceAsStream(cl, APP_RESOURCE_FILE_NAME); if (is == null) { throw new ConfigurationException( "Failed to access resource: " + APP_RESOURCE_FILE_NAME); } try { props.load(is); } catch (IOException e) { throw new ConfigurationException( "Failed to parse resource: " + APP_RESOURCE_FILE_NAME); } finally { SafeClose.close(is); } propertiesCache.put(cl, props); return props; } }
public synchronized String[] list(String dn, String filter, String attrID) throws ConfigurationException { ArrayList<String> values = new ArrayList<String>(); NamingEnumeration<SearchResult> ne = null; try { ne = search(dn, filter, attrID ); while (ne.hasMore()) { SearchResult sr = ne.next(); Attributes attrs = sr.getAttributes(); values.add(LdapUtils.stringValue(attrs.get(attrID), null)); } } catch (NamingException e) { throw new ConfigurationException(e); } finally { LdapUtils.safeClose(ne); } return values.toArray(new String[values.size()]); }
@Override public synchronized boolean purgeConfiguration() throws ConfigurationException { if (!configurationExists()) return false; try { destroySubcontextWithChilds(configurationDN); LOG.info("Purge DICOM Configuration at {}", configurationDN); clearConfigurationDN(); } catch (NamingException e) { throw new ConfigurationException(e); } return true; }
@Override public synchronized boolean purgeConfiguration() throws ConfigurationException { if (!configurationExists()) return false; try { destroySubcontextWithChilds(configurationDN); LOG.info("Purge DICOM Configuration at {}", configurationDN); clearConfigurationDN(); } catch (NamingException e) { throw new ConfigurationException(e); } return true; }
@Override public synchronized void unregisterAETitle(String aet) throws ConfigurationException { if (configurationExists()) try { ctx.destroySubcontext(aetDN(aet, aetsRegistryDN)); } catch (NameNotFoundException e) { } catch (NamingException e) { throw new ConfigurationException(e); } }
private void removeDeviceWithDN(String deviceDN, boolean unregister) throws ConfigurationException { try { ArrayList<String> destroyDNs = new ArrayList<>(); if (unregister) markForUnregister(deviceDN, destroyDNs); destroySubcontextWithChilds(deviceDN); unregister(destroyDNs); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } }
@Override public void unregisterHL7Application(String name) throws ConfigurationException { if (appNamesRegistryExists()) try { config.destroySubcontext(hl7appDN(name, appNamesRegistryDN)); } catch (NameNotFoundException e) { } catch (NamingException e) { throw new ConfigurationException(e); } }
private void removeDeviceWithDN(String deviceDN, boolean unregister) throws ConfigurationException { try { ArrayList<String> destroyDNs = new ArrayList<>(); if (unregister) markForUnregister(deviceDN, destroyDNs); destroySubcontextWithChilds(deviceDN); unregister(destroyDNs); } catch (NameNotFoundException e) { throw new ConfigurationNotFoundException(e); } catch (NamingException e) { throw new ConfigurationException(e); } }