本文整理汇总了Java中com.google.api.services.admin.directory.model.User.setPassword方法的典型用法代码示例。如果您正苦于以下问题:Java User.setPassword方法的具体用法?Java User.setPassword怎么用?Java User.setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.admin.directory.model.User
的用法示例。
在下文中一共展示了User.setPassword方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changerMotDePasse
import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
public static String changerMotDePasse(String email, String password) throws IOException, GeneralSecurityException {
String mess;
try {
Directory d = initDirectory();
User user = d.users().get(email).execute();
user.setPassword(password); //minimum 8 caractères pour un mot de passe dans gmail
d.users().update(email, user).execute();
mess = "La modification du mot de passe a eu lieu avec succès.";
} catch (Exception exception) {
String erreur = exception.getMessage();
if (erreur.substring(0, 3).equals("403")) {
mess = "ATTENTION: ECHEC - La modification du mot de passe 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 modification du mot de passe n'a pas eu lieu.";
}
}
return mess;
}
示例2: 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();
}
示例3: 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;
}
示例4: modifyPassword
import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
public static void modifyPassword(Directory d) throws IOException {
String emailVoulu="[email protected]"; //L’email qu’on veut modifier son password
User user=d.users().get(emailVoulu).execute();
user.setPassword("newPassword"); //minimum 8 caractères pour un mot de passe dans gmail
d.users().update(emailVoulu, user).execute();
}
示例5: insertUser
import com.google.api.services.admin.directory.model.User; //导入方法依赖的package包/类
/**
* Insert new user to your domain.
*
* @param user User to be created in your domain.
* @throws GoogleGroupsIOException When API call fails.
*/
private void insertUser(User user) throws GoogleGroupsIOException {
try {
// give users random passwords needed for creation
char[] possibleCharacters = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~`[email protected]#$%^&*()-_=+[{]}\\|;:\'\",<.>/?").toCharArray();
String randomStr = RandomStringUtils.random( 40, 0, possibleCharacters.length-1, false, false, possibleCharacters, new SecureRandom());
user.setPassword(randomStr);
service.users().insert(user).execute();
log.debug("Creating user: {}", user);
} catch (IOException ex) {
throw new GoogleGroupsIOException("Something went wrong while inserting user " + user.getPrimaryEmail() + " to Google Groups", ex);
}
}
示例6: 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();
}
示例7: 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);
}
示例8: 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;
}