Search in sources :

Example 1 with MailNonceModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl in project midpoint by Evolveum.

the class MailNonceModuleFactory method createEmptyModuleAuthentication.

@Override
protected ModuleAuthenticationImpl createEmptyModuleAuthentication(AbstractAuthenticationModuleType moduleType, ModuleWebSecurityConfiguration configuration) {
    MailNonceModuleAuthenticationImpl moduleAuthentication = new MailNonceModuleAuthenticationImpl();
    moduleAuthentication.setPrefix(configuration.getPrefixOfModule());
    moduleAuthentication.setCredentialName(((AbstractCredentialAuthenticationModuleType) moduleType).getCredentialName());
    moduleAuthentication.setCredentialType(supportedClass());
    moduleAuthentication.setNameOfModule(configuration.getNameOfModule());
    return moduleAuthentication;
}
Also used : MailNonceModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl)

Example 2 with MailNonceModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl in project midpoint by Evolveum.

the class MailNonceProvider method illegalAuthentication.

private boolean illegalAuthentication() {
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (!(authentication instanceof MidpointAuthentication)) {
        LOGGER.debug("Actual authentication isn't MidpointAuthentication");
        return true;
    }
    ModuleAuthentication moduleAuth = ((MidpointAuthentication) authentication).getProcessingModuleAuthentication();
    if (!(moduleAuth instanceof MailNonceModuleAuthenticationImpl)) {
        LOGGER.debug("Actual processing authentication module isn't MailNonceModuleAuthentication");
        return true;
    }
    String nameOfCredential = ((MailNonceModuleAuthenticationImpl) moduleAuth).getCredentialName();
    if (nameOfCredential == null) {
        LOGGER.debug("Name of credential in processing module is null");
        return true;
    }
    return false;
}
Also used : MailNonceModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Example 3 with MailNonceModuleAuthenticationImpl

use of com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl in project midpoint by Evolveum.

the class MailNonceProvider method getNoncePolicy.

private NonceCredentialsPolicyType getNoncePolicy(String username) {
    if (StringUtils.isBlank(username)) {
        throw new UsernameNotFoundException("web.security.provider.invalid.credentials");
    }
    if (illegalAuthentication()) {
        return null;
    }
    UserType user = AuthSequenceUtil.searchUserPrivileged(username, securityContextManager, manager, modelService, prismContext);
    if (user == null) {
        throw new UsernameNotFoundException("web.security.provider.invalid.credentials");
    }
    SecurityPolicyType securityPolicy = AuthSequenceUtil.resolveSecurityPolicy(user.asPrismObject(), securityContextManager, manager, modelInteractionService);
    if (illegalPolicy(securityPolicy)) {
        return null;
    }
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    ModuleAuthentication moduleAuth = ((MidpointAuthentication) authentication).getProcessingModuleAuthentication();
    String nameOfCredential = ((MailNonceModuleAuthenticationImpl) moduleAuth).getCredentialName();
    for (NonceCredentialsPolicyType noncePolicy : securityPolicy.getCredentials().getNonce()) {
        if (noncePolicy != null && nameOfCredential.equals(noncePolicy.getName())) {
            return noncePolicy;
        }
    }
    LOGGER.debug("Couldn't find nonce credential by name " + nameOfCredential);
    return null;
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) MailNonceModuleAuthenticationImpl(com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) ModuleAuthentication(com.evolveum.midpoint.authentication.api.config.ModuleAuthentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication) Authentication(org.springframework.security.core.Authentication) MidpointAuthentication(com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)

Aggregations

MailNonceModuleAuthenticationImpl (com.evolveum.midpoint.authentication.impl.module.authentication.MailNonceModuleAuthenticationImpl)3 MidpointAuthentication (com.evolveum.midpoint.authentication.api.config.MidpointAuthentication)2 ModuleAuthentication (com.evolveum.midpoint.authentication.api.config.ModuleAuthentication)2 Authentication (org.springframework.security.core.Authentication)2 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1