Search in sources :

Example 1 with CipherExecutor

use of org.apereo.cas.util.crypto.CipherExecutor in project cas by apereo.

the class BeanSupplierTests method verifyBeanProxiedWithSupplier.

@Test
public void verifyBeanProxiedWithSupplier() throws Exception {
    val noOp = BeanSupplier.of(CipherExecutor.class).neverMatch().otherwise(CipherExecutor::noOp).get();
    assertEquals(noOp.getClass(), CipherExecutor.noOp().getClass());
}
Also used : lombok.val(lombok.val) CipherExecutor(org.apereo.cas.util.crypto.CipherExecutor) Test(org.junit.jupiter.api.Test)

Example 2 with CipherExecutor

use of org.apereo.cas.util.crypto.CipherExecutor in project cas by apereo.

the class BeanSupplierTests method verifyBeanSupplied.

@Test
public void verifyBeanSupplied() throws Exception {
    val noOp = BeanSupplier.of(CipherExecutor.class).alwaysMatch().supply(CipherExecutor::noOp).get();
    assertEquals(noOp.getClass(), CipherExecutor.noOp().getClass());
}
Also used : lombok.val(lombok.val) CipherExecutor(org.apereo.cas.util.crypto.CipherExecutor) Test(org.junit.jupiter.api.Test)

Example 3 with CipherExecutor

use of org.apereo.cas.util.crypto.CipherExecutor in project cas by apereo.

the class BeanSupplierTests method verifyBeanSuppliedWithMultipleConditions.

@Test
public void verifyBeanSuppliedWithMultipleConditions() throws Exception {
    val noOp = BeanSupplier.of(CipherExecutor.class).alwaysMatch().supply(CipherExecutor::noOp).get();
    assertEquals(noOp.getClass(), CipherExecutor.noOp().getClass());
}
Also used : lombok.val(lombok.val) CipherExecutor(org.apereo.cas.util.crypto.CipherExecutor) Test(org.junit.jupiter.api.Test)

Example 4 with CipherExecutor

use of org.apereo.cas.util.crypto.CipherExecutor in project cas by apereo.

the class SamlIdPGitIdPMetadataConfiguration method samlIdPMetadataGeneratorCipherExecutor.

@Bean
@ConditionalOnMissingBean(name = "gitSamlIdPMetadataCipherExecutor")
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public CipherExecutor samlIdPMetadataGeneratorCipherExecutor(final ConfigurableApplicationContext applicationContext, final CasConfigurationProperties casProperties) {
    return BeanSupplier.of(CipherExecutor.class).when(CONDITION_ENABLED.given(applicationContext.getEnvironment())).and(CONDITION_URL.given(applicationContext.getEnvironment())).supply(() -> {
        val idp = casProperties.getAuthn().getSamlIdp();
        val crypto = idp.getMetadata().getGit().getCrypto();
        if (crypto.isEnabled()) {
            return CipherExecutorUtils.newStringCipherExecutor(crypto, GitSamlIdPMetadataCipherExecutor.class);
        }
        LOGGER.info("Git SAML IdP metadata encryption/signing is turned off and MAY NOT be safe in a production environment. " + "Consider using other choices to handle encryption, signing and verification of metadata artifacts");
        return CipherExecutor.noOp();
    }).otherwise(CipherExecutor::noOp).get();
}
Also used : lombok.val(lombok.val) CipherExecutor(org.apereo.cas.util.crypto.CipherExecutor) GitSamlIdPMetadataCipherExecutor(org.apereo.cas.support.saml.idp.metadata.GitSamlIdPMetadataCipherExecutor) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

lombok.val (lombok.val)4 CipherExecutor (org.apereo.cas.util.crypto.CipherExecutor)4 Test (org.junit.jupiter.api.Test)3 GitSamlIdPMetadataCipherExecutor (org.apereo.cas.support.saml.idp.metadata.GitSamlIdPMetadataCipherExecutor)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)1 Bean (org.springframework.context.annotation.Bean)1