Search in sources :

Example 1 with JwkException

use of org.apache.cxf.rs.security.jose.jwk.JwkException in project cxf by apache.

the class KeyManagementUtils method loadPersistKeyStore.

public static KeyStore loadPersistKeyStore(Message m, Properties props) {
    KeyStore keyStore = null;
    if (props.containsKey(JoseConstants.RSSEC_KEY_STORE)) {
        keyStore = (KeyStore) props.get(JoseConstants.RSSEC_KEY_STORE);
    }
    if (keyStore == null) {
        if (!props.containsKey(JoseConstants.RSSEC_KEY_STORE_FILE)) {
            LOG.warning("No keystore file has been configured");
            throw new JoseException("No keystore file has been configured");
        }
        if (m != null) {
            Object keyStoreProp = m.getExchange().get(props.get(JoseConstants.RSSEC_KEY_STORE_FILE));
            if (keyStoreProp != null && !(keyStoreProp instanceof KeyStore)) {
                throw new JwkException("Unexpected key store class: " + keyStoreProp.getClass().getName());
            } else {
                keyStore = (KeyStore) keyStoreProp;
            }
        }
    }
    if (keyStore == null) {
        Bus bus = m != null ? m.getExchange().getBus() : null;
        keyStore = loadKeyStore(props, bus);
        if (m != null) {
            m.getExchange().put((String) props.get(JoseConstants.RSSEC_KEY_STORE_FILE), keyStore);
        }
    }
    return keyStore;
}
Also used : Bus(org.apache.cxf.Bus) JwkException(org.apache.cxf.rs.security.jose.jwk.JwkException) KeyStore(java.security.KeyStore)

Aggregations

KeyStore (java.security.KeyStore)1 Bus (org.apache.cxf.Bus)1 JwkException (org.apache.cxf.rs.security.jose.jwk.JwkException)1