Search in sources :

Example 1 with RSAKeySecret

use of org.springframework.security.oauth.common.signature.RSAKeySecret in project spring-security-oauth by spring-projects.

the class ConsumerDetailsFactoryBean method getObject.

public ConsumerDetails getObject() throws Exception {
    if ("rsa-cert".equals(typeOfSecret)) {
        try {
            Certificate cert = CertificateFactory.getInstance("X.509").generateCertificate(resourceLoader.getResource(secret).getInputStream());
            consumer.setSignatureSecret(new RSAKeySecret(cert.getPublicKey()));
        } catch (IOException e) {
            throw new BeanCreationException("RSA certificate not found at " + secret + ".", e);
        } catch (CertificateException e) {
            throw new BeanCreationException("Invalid RSA certificate at " + secret + ".", e);
        } catch (NullPointerException e) {
            throw new BeanCreationException("Could not load RSA certificate at " + secret + ".", e);
        }
    } else {
        consumer.setSignatureSecret(new SharedConsumerSecretImpl(secret));
    }
    return consumer;
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) SharedConsumerSecretImpl(org.springframework.security.oauth.common.signature.SharedConsumerSecretImpl) RSAKeySecret(org.springframework.security.oauth.common.signature.RSAKeySecret) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) Certificate(java.security.cert.Certificate)

Aggregations

IOException (java.io.IOException)1 Certificate (java.security.cert.Certificate)1 CertificateException (java.security.cert.CertificateException)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 RSAKeySecret (org.springframework.security.oauth.common.signature.RSAKeySecret)1 SharedConsumerSecretImpl (org.springframework.security.oauth.common.signature.SharedConsumerSecretImpl)1