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;
}
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;
}
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;
}
Aggregations