当前位置: 首页>>代码示例>>Java>>正文


Java MongoCredential.createGSSAPICredential方法代码示例

本文整理汇总了Java中com.mongodb.MongoCredential.createGSSAPICredential方法的典型用法代码示例。如果您正苦于以下问题:Java MongoCredential.createGSSAPICredential方法的具体用法?Java MongoCredential.createGSSAPICredential怎么用?Java MongoCredential.createGSSAPICredential使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.MongoCredential的用法示例。


在下文中一共展示了MongoCredential.createGSSAPICredential方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findMongoCredential

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
private MongoCredential findMongoCredential(String user, String database, char[] pwd, String mechanism) {
    MongoCredential credential = null;
    switch (mechanism) {
        case "scram-sha-1":
            credential = MongoCredential.createScramSha1Credential(user, database, pwd);
            break;
        case "x509":
            credential = MongoCredential.createMongoX509Credential(user);
            break;
        case "cr":
            credential = MongoCredential.createMongoCRCredential(user, database, pwd);
            break;
        case "plain":
            credential = MongoCredential.createPlainCredential(user, database, pwd);
            break;
        case "gssapi":
            credential = MongoCredential.createGSSAPICredential(user);
            break;
        default:
            credential = MongoCredential.createCredential(user, database, pwd);
            break;
    }
    return credential;
}
 
开发者ID:ozlerhakan,项目名称:mongolastic,代码行数:25,代码来源:MongoConfiguration.java

示例2: convert

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
@Override
public MongoCredential convert(MongoCredentialRepresentation value) {
    MongoCredential credential;
    switch (value.getType()) {
        case PLAIN:
            credential = MongoCredential.createPlainCredential(value.getUsername(), value.getSource(), value.getPassword().toCharArray());
            break;
        case GSSAPI:
            credential = MongoCredential.createGSSAPICredential(value.getUsername());
            break;
        case X509:
            credential = MongoCredential.createMongoX509Credential(value.getUsername());
            break;
        case CR:
        default:
            credential = MongoCredential.createMongoCRCredential(value.getUsername(), value.getDatabase(), value.getPassword().toCharArray());
    }
    for (Map.Entry<String,Object> entry : value.getProperties().entrySet()) {
        credential = credential.withMechanismProperty(entry.getKey(), entry.getValue());
    }
    return credential;
}
 
开发者ID:acu-dev,项目名称:dropwizard-mongodb,代码行数:23,代码来源:MongoCredentialConverter.java

示例3: createCredentials

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
private MongoCredential createCredentials(Map<String, Object> map) {
  final String authMechanismName = (String) map.get("authMechanism");
  final AuthenticationMechanism authenticationMechanism =
      AuthenticationMechanism.fromMechanismName(authMechanismName);
  final String username = (String) map.get("username");
  final String authDatabase = (String) map.get("authDatabase");
  final String password = (String) map.get("password");

  switch (authenticationMechanism) {
  case PLAIN:
    return MongoCredential.createPlainCredential(username, authDatabase,
        password.toCharArray());
  case SCRAM_SHA_1:
    return MongoCredential.createScramSha1Credential(username, authDatabase,
        password.toCharArray());
  case GSSAPI:
    return MongoCredential.createGSSAPICredential(username);
  case MONGODB_CR:
    return MongoCredential.createMongoCRCredential(username, authDatabase,
        password.toCharArray());
  case MONGODB_X509:
    return MongoCredential.createMongoX509Credential(username);
  }
  throw new IllegalArgumentException("Unsupported authentication mechanism "
      + authMechanismName);
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:MongoSchemaFactory.java

示例4: createCredentials

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
private static MongoCredential createCredentials(MongoDataSourceConfiguration fileConfig) {
    MongoCredential credential;
    switch (fileConfig.getAuthenticationMethodEnum()) {
    case SCRAM_SHA_1:
        credential = MongoCredential.createScramSha1Credential(fileConfig.getUsername(), fileConfig.getDatabase(),
                fileConfig.getPassword().toCharArray());
        break;
    case MONGODB_CR:
        credential = MongoCredential.createMongoCRCredential(fileConfig.getUsername(), fileConfig.getDatabase(),
                fileConfig.getPassword().toCharArray());
    case LDAP_PLAIN:
        credential = MongoCredential.createPlainCredential(fileConfig.getUsername(), fileConfig.getAuthSource(),
                fileConfig.getPassword().toCharArray());
    case X_509:
        credential = MongoCredential.createMongoX509Credential(fileConfig.getUsername());
    case GSSAPI:
        credential = MongoCredential.createGSSAPICredential(fileConfig.getUsername());
    case DEFAULT:
    default:
        credential = MongoCredential.createCredential(fileConfig.getUsername(), fileConfig.getDatabase(),
                fileConfig.getPassword().toCharArray());
    }
    return credential;
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:25,代码来源:MongoDataSourceReaderUtil.java

示例5: CredentialState

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
public CredentialState(Resource parent, ResourceState resourceState) throws Exception {
    super(parent);

    String username = resourceState.getProperty(USERNAME, false, String.class);
    String password = resourceState.getProperty(PASSWORD, false, String.class);
    String mechanism = resourceState.getProperty(MECHANISM, false, String.class);
    String database = resourceState.getProperty(DB, false, String.class);

    if (username != null && !username.isEmpty()) {

        MongoCredential credential;
        if (mechanism.equals(MongoCredential.MONGODB_CR_MECHANISM)) {
            credential = MongoCredential.createMongoCRCredential(username, database, password.toCharArray());
        } else {
            credential = MongoCredential.createGSSAPICredential(username);
        }

        this.mongoCredential = credential;
    } else {
        this.mongoCredential = null;
    }
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:23,代码来源:CredentialState.java

示例6: createCredential

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
private MongoCredential createCredential(Map<String, String> properties) throws DataServiceFault {
    MongoCredential credential = null;
    String authenticationType = properties.get(DBConstants.MongoDB.AUTHENTICATION_TYPE);
    String username = properties.get(DBConstants.MongoDB.USERNAME);
    String password = properties.get(DBConstants.MongoDB.PASSWORD);
    String database = properties.get(DBConstants.MongoDB.DATABASE);
    if (authenticationType != null) {
        switch (authenticationType) {
            case DBConstants.MongoDB.MongoAuthenticationTypes.PLAIN:
                credential = MongoCredential.createPlainCredential(username, database, password.toCharArray());
                break;
            case DBConstants.MongoDB.MongoAuthenticationTypes.SCRAM_SHA_1:
                credential = MongoCredential.createScramSha1Credential(username, database, password.toCharArray());
                break;
            case DBConstants.MongoDB.MongoAuthenticationTypes.MONGODB_CR:
                credential = MongoCredential.createMongoCRCredential(username, database, password.toCharArray());
                break;
            case DBConstants.MongoDB.MongoAuthenticationTypes.GSSAPI:
                credential = MongoCredential.createGSSAPICredential(username);
                break;
            case DBConstants.MongoDB.MongoAuthenticationTypes.MONGODB_X509:
                credential = MongoCredential.createMongoX509Credential(username);
                break;
            default:
                throw new DataServiceFault("Invalid Authentication type. ");
        }
        return credential;
    } else {
        return null;
    }
}
 
开发者ID:wso2,项目名称:carbon-data,代码行数:32,代码来源:MongoConfig.java

示例7: credentialFromJson

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
public static MongoCredential credentialFromJson(ObjectNode node) {
    String userName = null;
    String password = null;
    String source = null;

    JsonNode xnode = node.get("mechanism");
    if (xnode == null) {
        throw new IllegalArgumentException("mechanism is required in credentials");
    }
    String mech = xnode.asText();
    xnode = node.get("userName");
    if (xnode != null) {
        userName = xnode.asText();
    }
    xnode = node.get("password");
    if (xnode != null) {
        password = xnode.asText();
    }
    xnode = node.get("source");
    if (xnode != null) {
        source = xnode.asText();
    }

    MongoCredential cr = null;
    if (null != mech) {
        switch (mech) {
        case "GSSAPI_MECHANISM":
            cr = MongoCredential.createGSSAPICredential(userName);
            break;
        case "MONGODB_CR_MECHANISM":
            cr = MongoCredential.createMongoCRCredential(userName, source,
                                                         password == null ? null : password.toCharArray());
            break;
        case "MONGODB_X509_MECHANISM":
            cr = MongoCredential.createMongoX509Credential(userName);
            break;
        case "PLAIN_MECHANISM":
            cr = MongoCredential.createPlainCredential(userName, source,
                                                       password == null ? null : password.toCharArray());
            break;
        case "SCRAM_SHA_1_MECHANISM":
            cr = MongoCredential.createScramSha1Credential(userName,source,
                                                           password==null?null:password.toCharArray());
            break;
        default:
            throw new IllegalArgumentException("invalid mechanism:" + mech + ", must be one of "
                                               + "GSSAPI_MECHANISM, MONGODB_CR_MECHANISM, "
                                               + "MONGODB_X5090_MECHANISM, SCRAM_SHA_1_MECHANISM or PLAIN_MECHANISM");
        }
    }
    return cr;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:53,代码来源:MongoConfiguration.java

示例8: CredentialListParser

import com.mongodb.MongoCredential; //导入方法依赖的package包/类
public CredentialListParser(ConnectionString connectionString, JsonObject config) {
  List<MongoCredential> connStringCredentials = null;
  if (connectionString != null) {
    connStringCredentials = connectionString.getCredentialList();
  }
  if (connStringCredentials != null && !connStringCredentials.isEmpty()) {
    credentials = connStringCredentials;
  } else {
    String username = config.getString("username");
    if (username == null) {
      credentials = Collections.emptyList();
    } else {
      credentials = new ArrayList<>();
      String passwd = config.getString("password");
      char[] password = (passwd == null) ? null : passwd.toCharArray();
      // See https://github.com/vert-x3/vertx-mongo-client/issues/46 - 'admin' as default is a security
      // concern, use  the 'db_name' if none is set.
      String authSource = config.getString("authSource",
          config.getString("db_name", MongoClientImpl.DEFAULT_DB_NAME));

      // AuthMechanism
      AuthenticationMechanism mechanism = null;
      String authMechanism = config.getString("authMechanism");
      if (authMechanism != null) {
        mechanism = getAuthenticationMechanism(authMechanism);
      }

      // MongoCredential
      String gssapiServiceName = config.getString("gssapiServiceName");
      MongoCredential credential;
      if (mechanism == GSSAPI) {
        credential = MongoCredential.createGSSAPICredential(username);
        credential = getMongoCredential(gssapiServiceName, credential);
      } else if (mechanism == PLAIN) {
        credential = MongoCredential.createPlainCredential(username, authSource, password);
      } else if (mechanism == MONGODB_CR) {
        credential = MongoCredential.createMongoCRCredential(username, authSource, password);
      } else if (mechanism == MONGODB_X509) {
        credential = MongoCredential.createMongoX509Credential(username);
      } else if (mechanism == SCRAM_SHA_1) {
        credential = MongoCredential.createScramSha1Credential(username, authSource, password);
      } else if (mechanism == null) {
        credential = MongoCredential.createCredential(username, authSource, password);
      } else {
        throw new IllegalArgumentException("Unsupported authentication mechanism " + mechanism);
      }

      credentials.add(credential);
    }
  }
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:52,代码来源:CredentialListParser.java


注:本文中的com.mongodb.MongoCredential.createGSSAPICredential方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。