Package org.springframework.data.authentication

Examples of org.springframework.data.authentication.UserCredentials


    logger.info("MongoDB:");
    createService(VCAP_MONGO_SERVICE, "mongodb", "1.8");
    int tunnelPort = LOCAL_PORT + 2;
    createTunnelServer(VCAP_MONGO_SERVICE, tunnelPort);
    Mongo mongo = new Mongo(LOCAL_HOST, tunnelPort);
    MongoDbFactory mdbf = new SimpleMongoDbFactory(mongo, svc_dbname, new UserCredentials(svc_username, svc_passwd));
    MongoTemplate mongoTemplate = new MongoTemplate(mdbf);
    // Test data
    ObjectMapper objectMapper = new ObjectMapper();
    Map<String,Object> dataMap = null;
    try {
View Full Code Here


    MongoDbFactory dbf = (MongoDbFactory) ctx.getBean("secondMongoDbFactory");

    Mongo mongo = (Mongo) getField(dbf, "mongo");
    assertEquals("localhost", mongo.getAddress().getHost());
    assertEquals(27017, mongo.getAddress().getPort());
    assertEquals(new UserCredentials("joe", "secret"), getField(dbf, "credentials"));
    assertEquals("database", getField(dbf, "databaseName"));
  }
View Full Code Here

    MongoDbFactory dbf = (MongoDbFactory) ctx.getBean("thirdMongoDbFactory");
    Mongo mongo = (Mongo) getField(dbf, "mongo");

    assertEquals("localhost", mongo.getAddress().getHost());
    assertEquals(27017, mongo.getAddress().getPort());
    assertEquals(new UserCredentials("joe", "secret"), getField(dbf, "credentials"));
    assertEquals("database", getField(dbf, "databaseName"));
    assertEquals("admin", getField(dbf, "authenticationDatabaseName"));
  }
View Full Code Here

   * @throws UnknownHostException
   * @see MongoURI
   */
  @SuppressWarnings("deprecation")
  public SimpleMongoDbFactory(MongoURI uri) throws MongoException, UnknownHostException {
    this(new Mongo(uri), uri.getDatabase(), new UserCredentials(uri.getUsername(), parseChars(uri.getPassword())),
        true, uri.getDatabase());
  }
View Full Code Here

  public void setAuthenticationDatabaseName(String authenticationDatabaseName) {
    this.authenticationDatabaseName = authenticationDatabaseName;
  }

  DB getDB(String databaseName) {
    return MongoDbUtils.getDB(mongo, databaseName, new UserCredentials(username, password), authenticationDatabaseName);
  }
View Full Code Here

    }
    return result;
  }

  public DB getDb(String databaseName) {
    return MongoDbUtils.getDB(mongo, databaseName, new UserCredentials(username, password));
  }
View Full Code Here

  public void mongoUriConstructor() throws UnknownHostException {

    MongoURI mongoURI = new MongoURI("mongodb://myUsername:myPassword@localhost/myDatabase.myCollection");
    MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongoURI);

    assertThat(ReflectionTestUtils.getField(mongoDbFactory, "credentials"), is((Object) new UserCredentials(
        "myUsername", "myPassword")));
    assertThat(ReflectionTestUtils.getField(mongoDbFactory, "databaseName").toString(), is("myDatabase"));
    assertThat(ReflectionTestUtils.getField(mongoDbFactory, "databaseName").toString(), is("myDatabase"));
  }
View Full Code Here

    expect(uri.getPassword()).andReturn(pass);
    expect(uri.getDatabase()).andReturn(database);

    Mongo mongo = createMock(Mongo.class);

    UserCredentials credentials =
        new UserCredentials(user, String.valueOf(pass));
    MongoDbFactory mongoDbFactory =
        PowerMock
            .createMockAndExpectNew(SimpleMongoDbFactory.class, mongo,
                database, credentials);
View Full Code Here

    char[] password = uri.getPassword();
    if (Strings.isNullOrEmpty(username)) {
      return new SimpleMongoDbFactory(mongo, uri.getDatabase());
    }
    return new SimpleMongoDbFactory(mongo, uri.getDatabase(),
        new UserCredentials(username, password == null ? null
            : String.valueOf(password)));
  }
View Full Code Here

            }

            MongoURI uri = new MongoURI(mongoUri);
            return new MongoTemplate(new SimpleMongoDbFactory(mongo, uri.getDatabase(),
                    new UserCredentials(uri.getUsername(), parseChars(uri.getPassword()))));

        } catch (Exception e) {
            logger.error("mongo db error ,uri={}", mongoUri, e);
            return null;
        }
View Full Code Here

TOP

Related Classes of org.springframework.data.authentication.UserCredentials

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.