Search in sources :

Example 1 with PFAuth

use of net.phonefactor.pfsdk.PFAuth in project cas by apereo.

the class AzureAuthenticatorAuthenticationEventExecutionPlanConfiguration method azureAuthenticatorInstance.

@Bean
public PFAuth azureAuthenticatorInstance() {
    try {
        final MultifactorAuthenticationProperties.Azure azure = casProperties.getAuthn().getMfa().getAzure();
        final File cfg = new File(azure.getConfigDir());
        if (!cfg.exists() || !cfg.isDirectory()) {
            throw new FileNotFoundException(cfg.getAbsolutePath() + " does not exist or is not a directory");
        }
        final PFAuth pf = new PFAuth();
        pf.setDebug(true);
        pf.setAllowInternationalCalls(azure.isAllowInternationalCalls());
        final String dir = StringUtils.appendIfMissing(azure.getConfigDir(), "/");
        pf.initialize(dir, azure.getPrivateKeyPassword());
        return pf;
    } catch (final Exception e) {
        throw new BeanCreationException(e.getMessage(), e);
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) PFAuth(net.phonefactor.pfsdk.PFAuth) FileNotFoundException(java.io.FileNotFoundException) MultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties) File(java.io.File) BeanCreationException(org.springframework.beans.factory.BeanCreationException) FileNotFoundException(java.io.FileNotFoundException) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 PFAuth (net.phonefactor.pfsdk.PFAuth)1 MultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.MultifactorAuthenticationProperties)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1