本文整理汇总了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();
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
}
示例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;
}