use of org.pac4j.mongo.profile.service.MongoProfileService in project cas by apereo.
the class MongoDbAuthenticationHandler method close.
@PreDestroy
@Override
public void close() {
try {
final MongoProfileService service = MongoProfileService.class.cast(authenticator);
service.getMongoClient().close();
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.pac4j.mongo.profile.service.MongoProfileService 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;
}
Aggregations