Search in sources :

Example 16 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class NonJavaKeyStoreImpl method validateKeyStoreAttributes.

private void validateKeyStoreAttributes(NonJavaKeyStore<?> keyStore) {
    try {
        SSLUtil.readPrivateKey(getUrlFromString(keyStore.getPrivateKeyUrl()));
        SSLUtil.readCertificates(getUrlFromString(keyStore.getCertificateUrl()));
        if (keyStore.getIntermediateCertificateUrl() != null) {
            SSLUtil.readCertificates(getUrlFromString(keyStore.getIntermediateCertificateUrl()));
        }
    } catch (IOException | GeneralSecurityException e) {
        throw new IllegalConfigurationException("Cannot validate private key or certificate(s):" + e, e);
    }
}
Also used : GeneralSecurityException(java.security.GeneralSecurityException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IOException(java.io.IOException)

Example 17 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class NonJavaTrustStoreImpl method updateTrustManagers.

@SuppressWarnings("unused")
private void updateTrustManagers() {
    try {
        if (_certificatesUrl != null) {
            X509Certificate[] certs = SSLUtil.readCertificates(getUrlFromString(_certificatesUrl));
            java.security.KeyStore inMemoryKeyStore = java.security.KeyStore.getInstance(java.security.KeyStore.getDefaultType());
            inMemoryKeyStore.load(null, null);
            int i = 1;
            for (Certificate cert : certs) {
                inMemoryKeyStore.setCertificateEntry(String.valueOf(i++), cert);
            }
            TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tmf.init(inMemoryKeyStore);
            _trustManagers = tmf.getTrustManagers();
            _certificates = certs;
        }
    } catch (IOException | GeneralSecurityException e) {
        throw new IllegalConfigurationException("Cannot load certificate(s) :" + e, e);
    }
}
Also used : TrustManagerFactory(javax.net.ssl.TrustManagerFactory) GeneralSecurityException(java.security.GeneralSecurityException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IOException(java.io.IOException) X509Certificate(java.security.cert.X509Certificate) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Example 18 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class SiteSpecificTrustStoreImpl method generateTrustManagers.

private void generateTrustManagers() {
    try {
        java.security.KeyStore inMemoryKeyStore = java.security.KeyStore.getInstance(java.security.KeyStore.getDefaultType());
        inMemoryKeyStore.load(null, null);
        inMemoryKeyStore.setCertificateEntry("1", _x509Certificate);
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        tmf.init(inMemoryKeyStore);
        _trustManagers = tmf.getTrustManagers();
    } catch (IOException | GeneralSecurityException e) {
        throw new IllegalConfigurationException("Cannot load certificate(s) :" + e, e);
    }
}
Also used : TrustManagerFactory(javax.net.ssl.TrustManagerFactory) GeneralSecurityException(java.security.GeneralSecurityException) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) IOException(java.io.IOException)

Example 19 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class ManagementModeStoreHandler method remove.

@Override
public synchronized UUID[] remove(final ConfiguredObjectRecord... records) {
    assertState(StoreState.OPEN);
    synchronized (_store) {
        UUID[] idsToRemove = new UUID[records.length];
        for (int i = 0; i < records.length; i++) {
            idsToRemove[i] = records[i].getId();
        }
        for (UUID id : idsToRemove) {
            if (_cliEntries.containsKey(id)) {
                throw new IllegalConfigurationException("Cannot change configuration for command line entry:" + _cliEntries.get(id));
            }
        }
        UUID[] result = _store.remove(records);
        for (UUID id : idsToRemove) {
            if (_quiescedEntriesOriginalState.containsKey(id)) {
                _quiescedEntriesOriginalState.remove(id);
            }
        }
        for (ConfiguredObjectRecord record : records) {
            _records.remove(record.getId());
        }
        return result;
    }
}
Also used : IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 20 with IllegalConfigurationException

use of org.apache.qpid.server.configuration.IllegalConfigurationException in project qpid-broker-j by apache.

the class ManagementModeStoreHandler method update.

@Override
public void update(final boolean createIfNecessary, final ConfiguredObjectRecord... records) throws StoreException {
    assertState(StoreState.OPEN);
    synchronized (_store) {
        Collection<ConfiguredObjectRecord> actualUpdates = new ArrayList<ConfiguredObjectRecord>();
        for (ConfiguredObjectRecord record : records) {
            if (_cliEntries.containsKey(record.getId())) {
                throw new IllegalConfigurationException("Cannot save configuration provided as command line argument:" + record);
            } else if (_quiescedEntriesOriginalState.containsKey(record.getId())) {
                // save entry with the original state
                record = createEntryWithState(record, _quiescedEntriesOriginalState.get(record.getId()));
            }
            actualUpdates.add(record);
        }
        _store.update(createIfNecessary, actualUpdates.toArray(new ConfiguredObjectRecord[actualUpdates.size()]));
    }
    for (ConfiguredObjectRecord record : records) {
        _records.put(record.getId(), record);
    }
}
Also used : ArrayList(java.util.ArrayList) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Aggregations

IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)87 HashMap (java.util.HashMap)31 IOException (java.io.IOException)25 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)20 File (java.io.File)15 UUID (java.util.UUID)12 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)12 GeneralSecurityException (java.security.GeneralSecurityException)10 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)9 LinkedHashMap (java.util.LinkedHashMap)7 Map (java.util.Map)7 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)7 AccessControlException (java.security.AccessControlException)6 ArrayList (java.util.ArrayList)6 Protocol (org.apache.qpid.server.model.Protocol)5 UnknownAlternateBindingException (org.apache.qpid.server.virtualhost.UnknownAlternateBindingException)5 MalformedURLException (java.net.MalformedURLException)4 URL (java.net.URL)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 HashSet (java.util.HashSet)4