use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.
the class MongoDbMultifactorAuthenticationTrustConfiguration method mongoMfaTrustedAuthnTemplate.
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@Bean
public MongoOperations mongoMfaTrustedAuthnTemplate(final CasConfigurationProperties casProperties, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
val mongo = casProperties.getAuthn().getMfa().getTrusted().getMongo();
val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
val mongoTemplate = factory.buildMongoTemplate(mongo);
MongoDbConnectionFactory.createCollection(mongoTemplate, mongo.getCollection(), mongo.isDropCollection());
return mongoTemplate;
}
use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.
the class CasMongoAuthenticationConfiguration method mongoAuthenticationHandler.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "mongoAuthenticationHandler")
public AuthenticationHandler mongoAuthenticationHandler(final CasConfigurationProperties casProperties, final ConfigurableApplicationContext applicationContext, @Qualifier("mongoPrincipalFactory") final PrincipalFactory mongoPrincipalFactory, @Qualifier(ServicesManager.BEAN_NAME) final ServicesManager servicesManager, @Qualifier(CasSSLContext.BEAN_NAME) final CasSSLContext casSslContext) {
val mongo = casProperties.getAuthn().getMongo();
val factory = new MongoDbConnectionFactory(casSslContext.getSslContext());
val mongoTemplate = factory.buildMongoTemplate(mongo);
val handler = new MongoDbAuthenticationHandler(mongo.getName(), servicesManager, mongoPrincipalFactory, mongo, mongoTemplate);
handler.setPasswordEncoder(PasswordEncoderUtils.newPasswordEncoder(mongo.getPasswordEncoder(), applicationContext));
handler.setPrincipalNameTransformer(PrincipalNameTransformerUtils.newPrincipalNameTransformer(mongo.getPrincipalTransformation()));
return handler;
}
use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.
the class MongoDbAuthenticationHandlerTests method initialize.
@BeforeEach
public void initialize() {
val mongo = casProperties.getAuthn().getMongo();
val factory = new MongoDbConnectionFactory();
try (val mongoClient = factory.buildMongoDbClient(mongo)) {
val database = mongoClient.getDatabase(mongo.getDatabaseName());
database.drop();
val col = database.getCollection(mongo.getCollection());
var account = new Document();
account.append(mongo.getUsernameAttribute(), "u1");
account.append(mongo.getPasswordAttribute(), "p1");
account.append("loc", "Apereo");
account.append("state", "California");
col.insertOne(account);
account = new Document();
account.append(mongo.getUsernameAttribute(), "userPlain");
col.insertOne(account);
}
}
use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.
the class MongoDbConnectionFactoryTests method verifyClient.
@Test
public void verifyClient() {
val props = new SingleCollectionMongoDbProperties();
props.setClientUri(URI);
val factory = new MongoDbConnectionFactory();
val client = factory.buildMongoDbClient(props);
assertNotNull(client);
}
use of org.apereo.cas.mongo.MongoDbConnectionFactory in project cas by apereo.
the class MongoDbConnectionFactoryTests method verifyProps.
@Test
public void verifyProps() {
val factory = new MongoDbConnectionFactory();
val props = new SingleCollectionMongoDbProperties();
props.setClientUri(URI);
val template = factory.buildMongoTemplate(props);
assertNotNull(template);
factory.createCollection(template, getClass().getSimpleName(), true);
}
Aggregations