本文整理汇总了Java中org.springframework.data.authentication.UserCredentials类的典型用法代码示例。如果您正苦于以下问题:Java UserCredentials类的具体用法?Java UserCredentials怎么用?Java UserCredentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserCredentials类属于org.springframework.data.authentication包,在下文中一共展示了UserCredentials类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDb
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
@Override
public DB getDb(String dbName) throws DataAccessException {
Assert.hasText(dbName, "Database name must not be empty.");
MongoClientURI mongoURI = determineTargetDataSource();
return MongoDbUtils.getDB(getMongo(mongoURI), dbName, new UserCredentials(mongoURI.getUsername(), parseChars(mongoURI.getPassword())), mongoURI.getDatabase());
}
示例2: createMongoTemplate
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
@Bean(name = "mongoTemplate")
public MongoTemplate createMongoTemplate() throws UnknownHostException {
MongoClient mongoClient = new MongoClient(host, port);
//TODO Configure additional MongoDB mongoClient settings if needed
MongoDbFactory factory = new SimpleMongoDbFactory(mongoClient, database, new UserCredentials(username, password));
MappingMongoConverter converter = new MappingMongoConverter(new DefaultDbRefResolver(factory), new MongoMappingContext());
converter.setTypeMapper(new DefaultMongoTypeMapper(null));
return new MongoTemplate(factory, converter);
}
示例3: mongoTemplate
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
@Bean
@ConditionalOnProperty(value = APPLICATION_DATA_TYPE, havingValue = APPLICATION_DATA_TYPE_MONGO)
@Autowired
public MongoTemplate mongoTemplate(MongoProperties properties,
@Value("${spring.data.mongodb.password}") String password) throws Exception {
MongoClient client = new MongoClient(new ServerAddress(
properties.getHost(), properties.getPort()));
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(client, properties.getDatabase(),
new UserCredentials(properties.getUsername(), password));
return new MongoTemplate(mongoDbFactory);
}
示例4: getUserCredentials
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
public UserCredentials getUserCredentials() {
if (StringUtils.hasLength(dbUser)) {
return new UserCredentials(dbUser, dbPassword);
} else {
return null;
}
}
示例5: mongoDbFactory
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
public @Bean MongoDbFactory mongoDbFactory() throws MongoException, UnknownHostException {
UserCredentials userCredentials = new UserCredentials(USER, PASSWORD);
//return new SimpleMongoDbFactory(new MongoURI("mongodb://<user>:<pass>@<url>"));
return new SimpleMongoDbFactory(new MongoClient(HOST,PORT), DATABASE, userCredentials);
}
示例6: mongoDbFactory
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
@Bean
public MongoDbFactory mongoDbFactory() throws Exception {
return new SimpleMongoDbFactory(mongo, dbname, new UserCredentials(username, password));
}
示例7: mongoDbFactory
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
@Bean
public MongoDbFactory mongoDbFactory() throws Exception {
UserCredentials userCredentials = new UserCredentials(env.getProperty("dbUser"), env.getProperty("dbPassword"));
return new SimpleMongoDbFactory(new Mongo(mongoURI()), "pubanywhere", userCredentials);
}
示例8: mongoDbFactory
import org.springframework.data.authentication.UserCredentials; //导入依赖的package包/类
@Override
public SimpleMongoDbFactory mongoDbFactory() throws Exception {
UserCredentials userCredentials = new UserCredentials(user, password);
return new SimpleMongoDbFactory(mongo(), getDatabaseName(), userCredentials);
}