本文整理汇总了Java中com.google.api.services.admin.directory.model.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于com.google.api.services.admin.directory.model包,在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: fetchGooUser
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
public User fetchGooUser(String userKey) {
User user = GoogleCacheManager.googleUsers().get(userKey);
if (user == null) {
try {
user = GoogleAppsSdkUtils.retrieveUser(directoryClient, userKey);
} catch (IOException e) {
LOG.warn("Google Apps Consume '{}' - Error fetching user ({}) from Google: {}", new Object[]{consumerName, userKey, e.getMessage()});
}
if (user != null) {
GoogleCacheManager.googleUsers().put(user);
}
}
return user;
}
示例4: updateGooMember
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
public void updateGooMember(edu.internet2.middleware.grouper.Group group, Subject subject, String role) throws IOException {
User user = fetchGooUser(addressFormatter.qualifySubjectAddress(subject.getId()));
Group gooGroup = fetchGooGroup(addressFormatter.qualifyGroupAddress(group.getName()));
recentlyManipulatedObjectsList.delayIfNeeded(gooGroup.getEmail());
Member member = GoogleAppsSdkUtils.retrieveGroupMember(directoryClient, gooGroup.getEmail(), user.getPrimaryEmail());
if (member == null) {
createGooMember(gooGroup, user, role);
return;
}
if (member.getRole() != role) {
member.setRole(role);
GoogleAppsSdkUtils.updateGroupMember(directoryClient, gooGroup.getEmail(), user.getPrimaryEmail(), member);
recentlyManipulatedObjectsList.add(user.getPrimaryEmail());
}
}
示例5: 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;
}
示例6: 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();
}
示例7: 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);
}
}
示例8: updateUser
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
/**
* Update user in your domain.
*
* @param userKey Key to identify User to update
* @param user User with updated properties
* @throws GoogleGroupsIOException When API call fails.
*/
private void updateUser(String userKey, User user) throws GoogleGroupsIOException {
try {
service.users().update(userKey, user).execute();
log.debug("Updating user: {}", user);
} catch (IOException ex) {
throw new GoogleGroupsIOException("Something went wrong while updating user " + user.getPrimaryEmail() + " in Google Groups", ex);
}
}
示例9: getUser
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
/**
* Retrieves the requested username from Google Apps.
*
* @param username Username without domain.
* @return Whether it is not found, it returns null
*/
private User getUser(String username) {
try {
return directory.users().get(getEmail(username)).execute();
} catch (IOException e) {
return null;
}
}
示例10: 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();
}
示例11: testCreateUser
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
/**
* Test method for
* {@link apps.provisioning.server.apis.GoogleDirectory#createUser(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}
* .
*
* @throws Exception
* @throws IOException
*/
@Test
public final void testCreateUser() throws IOException, Exception {
String firstname = "Carlos";
String lastname = "Alvares";
String password = "12345678";
User user = googleDirectory.createUser(NOT_EXISTING_USERNAME, firstname, lastname, password);
if (user == null) {
fail("User hasn't been created.");
} else {
googleDirectory.remove(NOT_EXISTING_USERNAME);
}
}
示例12: createUser
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
protected String createUser(ProvisioningEntity provisioningEntity)
throws IdentityProvisioningException {
boolean isDebugEnabled = log.isDebugEnabled();
if (isDebugEnabled) {
log.debug("Triggering create operation for Google Provisioning Connector");
}
User createdUser = null;
try {
User newUser = new User();
newUser = buildGoogleUser(provisioningEntity);
Directory.Users.Insert request = getDirectoryService().users().insert(newUser);
createdUser = request.execute();
} catch (IOException e) {
throw new IdentityProvisioningException("Error while creating user : "
+ provisioningEntity.getEntityName(), e);
}
if (isDebugEnabled) {
log.debug("Returning created user's email : " + createdUser.getPrimaryEmail());
}
if (log.isTraceEnabled()) {
log.trace("Ending createUser() of " + GoogleProvisioningConnector.class);
}
return createdUser.getPrimaryEmail();
}
示例13: getId
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
private String getId(T item) {
if (item.getClass().equals(User.class)) {
return ((User) item).getPrimaryEmail();
} else if (item.getClass().equals(Group.class)) {
return ((Group) item).getEmail();
} else if (item.getClass().equals(Subject.class)) {
return ((Subject) item).getSourceId() + "__" + ((Subject) item).getId();
} else if (item.getClass().equals(edu.internet2.middleware.grouper.Group.class)) {
return ((edu.internet2.middleware.grouper.Group) item).getName();
} else {
return item.toString();
}
}
示例14: createGooMember
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
public void createGooMember(Group group, User user, String role) throws IOException {
final Member gMember = new Member();
gMember.setEmail(user.getPrimaryEmail())
.setRole(role);
recentlyManipulatedObjectsList.delayIfNeeded(gMember.getEmail());
GoogleAppsSdkUtils.addGroupMember(directoryClient, group.getEmail(), gMember);
recentlyManipulatedObjectsList.add(gMember.getEmail());
}
示例15: 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);
}