use of org.apereo.cas.configuration.model.support.mongo.MongoAuthenticationProperties in project cas by apereo.
the class CasMongoAuthenticationConfiguration method mongoAuthenticatorProfileService.
@ConditionalOnMissingBean(name = "mongoAuthenticatorProfileService")
@Bean
public MongoProfileService mongoAuthenticatorProfileService() {
final MongoAuthenticationProperties mongo = casProperties.getAuthn().getMongo();
final MongoClientURI uri = new MongoClientURI(mongo.getMongoHostUri());
final MongoClient client = new MongoClient(uri);
LOGGER.info("Connected to MongoDb instance @ [{}] using database [{}]", uri.getHosts(), uri.getDatabase());
final SpringSecurityPasswordEncoder encoder = new SpringSecurityPasswordEncoder(PasswordEncoderUtils.newPasswordEncoder(mongo.getPasswordEncoder()));
final MongoProfileService auth = new MongoProfileService(client, mongo.getAttributes());
auth.setUsersCollection(mongo.getCollectionName());
auth.setUsersDatabase(uri.getDatabase());
auth.setUsernameAttribute(mongo.getUsernameAttribute());
auth.setPasswordAttribute(mongo.getPasswordAttribute());
auth.setPasswordEncoder(encoder);
return auth;
}
use of org.apereo.cas.configuration.model.support.mongo.MongoAuthenticationProperties in project cas by apereo.
the class CasMongoAuthenticationConfiguration method mongoAuthenticationHandler.
@Bean
@RefreshScope
public AuthenticationHandler mongoAuthenticationHandler() {
final MongoAuthenticationProperties mongo = casProperties.getAuthn().getMongo();
final MongoDbAuthenticationHandler handler = new MongoDbAuthenticationHandler(mongo.getName(), servicesManager, mongoPrincipalFactory());
handler.setAuthenticator(mongoAuthenticatorProfileService());
handler.setPrincipalNameTransformer(PrincipalNameTransformerUtils.newPrincipalNameTransformer(mongo.getPrincipalTransformation()));
return handler;
}
Aggregations