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


Java User.setPrimaryEmail方法代码示例

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


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

示例1: createUser

import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
public static void createUser(Directory d) throws IOException {
    User user = new User();
   
    UserName name = new UserName();
    name.setGivenName("aa");
    name.setFamilyName("bb");
    user.setName(name);
    
    user.setPrimaryEmail("[email protected]");
    user.setPassword("premuierPassachanger"); 
    user.setOrgUnitPath("/Etudiants");

    // requires DirectoryScopes.ADMIN_DIRECTORY_USER scope  
    d.users().insert(user).execute();
   
}
 
开发者ID:ljug,项目名称:java-tutorials,代码行数:17,代码来源:OperationBase.java

示例2: creerUtilisateur

import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
public static String creerUtilisateur(String email, String prenom, String nom, String password, String chemin) throws IOException, GeneralSecurityException {
    String mess;

    try {
        Directory d = initDirectory();
        User user = new User();

        UserName name = new UserName();
        name.setGivenName(prenom);
        name.setFamilyName(nom);
        user.setName(name);

        user.setPrimaryEmail(email);
        user.setPassword(password);
        user.setOrgUnitPath(chemin);
        user.setChangePasswordAtNextLogin(true);

        d.users().insert(user).execute();
        mess = "La création de l'email a eu lieu avec succès.";

    } catch (Exception exception) {
        String erreur = exception.getMessage();
        if (erreur.substring(0, 3).equals("409")) {
            mess = "ATTENTION: ECHEC - La création n'a pas eu lieu car cet email existe déjà. Définir un nouveau email en changeant le suffixe.";
        } else if (erreur.substring(0, 3).equals("404")) {
            mess = "ATTENTION: ECHEC - La création n'a pas eu lieu car le domaine n'existe pas.";
        } else {
            //Erreur 400: Directory non trouver ou le mot de passe doit être au moins 8 caractères ou il ya des parametres vides ou autre raison d'echec
            mess = "ATTENTION: ECHEC - La création n'a pas eu lieu.";
        }
    }
    return mess;
}
 
开发者ID:ljug,项目名称:java-tutorials,代码行数:34,代码来源:GestionDomaine.java

示例3: createUser

import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
/**
 * Creates a user in Google Apps Diretory.
 *
 * @param username Username without domain.
 * @param firstname First name
 * @param lastname Last name
 * @param password Password with 8 characters or longer.
 * @return The created user.
 * @throws IOException
 * @throws Exception When values are null, empty, shorter or longer than allowed.
 */
public User createUser(String username, String firstname, String lastname, String password)
    throws IOException, Exception {
  if (username == null || firstname == null || lastname == null || password == null) {
    throw new Exception("Null values are not allowed.");
  }
  if (username.isEmpty() || firstname.isEmpty() || lastname.isEmpty() || password.isEmpty()) {
    throw new Exception("All the parameters must be filled.");
  }
  if (username.length() > UsernameManager.MAX_USERNAME_LENGTH
      || firstname.length() > UsernameManager.MAX_NAME_LENGTH
      || lastname.length() > UsernameManager.MAX_NAME_LENGTH
      || password.length() > UsernameManager.MAX_PASSWORD_LENGTH) {
    throw new Exception(
        "One of the fields exceds the maximum length. 60 (firstname,lastname), 64 (username),"
            + " 100 (password)");
  }
  if (password.length() < UsernameManager.MIN_PASSWORD_LENGTH) {
    throw new Exception("Password must have at least 8 characters.");
  }
  User user = new User();
  UserName name = new UserName();
  name.setGivenName(firstname);
  name.setFamilyName(lastname);
  user.setName(name);
  user.setPrimaryEmail(getEmail(username));
  user.setPassword(password);
  return directory.users().insert(user).execute();
}
 
开发者ID:google,项目名称:account-provisioning-for-google-apps,代码行数:40,代码来源:GoogleDirectory.java

示例4: createTestUser

import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
private User createTestUser(String email, String givenName, String surname) throws IOException {
    User user = new User();
    user.setPrimaryEmail(email);
    user.setName(new UserName());
    user.getName().setFamilyName(surname);
    user.getName().setGivenName(givenName);
    user.setPassword(new BigInteger(130, new SecureRandom()).toString(32));
    return GoogleAppsSdkUtils.addUser(directory, user);
}
 
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:10,代码来源:GoogleAppsChangeLogConsumerTest.java

示例5: deleteUser

import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
/**
 * Delete provisioned user from google account
 *
 * @param provisioningEntity
 * @throws IdentityProvisioningException
 */
protected void deleteUser(ProvisioningEntity provisioningEntity)
        throws IdentityProvisioningException {
    boolean isDebugEnabled = log.isDebugEnabled();
    if (isDebugEnabled) {
        log.debug("Triggering delete operation for Google Provisioning Connector");
    }

    ProvisionedIdentifier provisionedIdentifier = provisioningEntity.getIdentifier();
    if (provisionedIdentifier != null && provisionedIdentifier.getIdentifier() != null) {
        User deletingUser = new User();
        deletingUser.setPrimaryEmail(provisionedIdentifier.getIdentifier());

        Directory.Users.Delete request;
        try {
            request = getDirectoryService().users().delete(
                    provisionedIdentifier.getIdentifier());
            request.execute();

        } catch (IOException e) {
            if (((GoogleJsonResponseException) e).getStatusCode() == 404) {
                log.warn("Exception while deleting user from google. User may be already deleted from google");
                if (log.isDebugEnabled()) {
                    log.debug("Exception while deleting user from google. User may be already deleted from google", e);
                }
            } else {
                throw new IdentityProvisioningException("Error while deleting Google user : "
                                                        + provisioningEntity.getEntityName(), e);
            }
        }

        if (isDebugEnabled) {
            log.debug("Deleted user :" + provisioningEntity.getEntityName()
                      + " with the primaryEmail : " + provisionedIdentifier.getIdentifier());
        }
    } else {
        throw new IdentityProvisioningException(
                "Cannot delete Google user, provisionedIdentifier is invalide.");
    }

    if (log.isTraceEnabled()) {
        log.trace("Ending deleteUser() of " + GoogleProvisioningConnector.class);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:50,代码来源:GoogleProvisioningConnector.java

示例6: updateGoogleUser

import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
/**
 * Buld Google user object to provision
 *
 * @param provisioningEntity
 * @return
 */
protected User updateGoogleUser(ProvisioningEntity provisioningEntity) {

    User updateUser = new User();
    updateUser.setPrimaryEmail(provisioningEntity.getIdentifier().getIdentifier());
    UserName username = new UserName();

    String defaultFamilyNameKey = "google_prov_familyname";
    String defaultGivenNameKey = "google_prov_givenname";

    String familyNameClaimKey = "google_prov_familyname_claim_dropdown";
    String givenNameClaimKey = "google_prov_givenname_claim_dropdown";

    Map<String, String> requiredAttributes = getSingleValuedClaims(provisioningEntity
                                                                           .getAttributes());

    if (MapUtils.isEmpty(requiredAttributes)) {
        return null;
    }

    // Set given name
    String givenNameClaim = this.configHolder.getValue(givenNameClaimKey);
    String givenNameValue = requiredAttributes.get(givenNameClaim);
    if (StringUtils.isBlank(givenNameValue)) {
        String defaultGivenNameValue = this.configHolder.getValue(defaultGivenNameKey);
        if (StringUtils.isNotBlank(defaultGivenNameValue)) {
            givenNameValue = defaultGivenNameValue;
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("New Google user given name : " + givenNameValue);
    }
    username.setGivenName(givenNameValue);

    // Set family name
    String familyNameClaim = this.configHolder.getValue(familyNameClaimKey);
    String familyNameValue = requiredAttributes.get(familyNameClaim);
    if (StringUtils.isBlank(familyNameValue)) {
        String defaultFamilyNameValue = this.configHolder.getValue(defaultFamilyNameKey);
        if (StringUtils.isNotBlank(defaultFamilyNameValue)) {
            familyNameValue = defaultFamilyNameValue;
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("New Google user family name : " + familyNameValue);
    }
    username.setFamilyName(familyNameValue);

    updateUser.setName(username);
    updateUser.setPassword(generatePassword());

    return updateUser;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:59,代码来源:GoogleProvisioningConnector.java


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