本文整理汇总了Java中com.google.api.services.admin.directory.model.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于com.google.api.services.admin.directory.model包,在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ljug,项目名称:java-tutorials,代码行数:23,代码来源:GestionDomaine.java
示例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();
}
开发者ID:ljug,项目名称:java-tutorials,代码行数:17,代码来源:OperationBase.java
示例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;
}
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:17,代码来源:GoogleGrouperConnector.java
示例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());
}
}
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:19,代码来源:GoogleGrouperConnector.java
示例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;
}
开发者ID:ljug,项目名称:java-tutorials,代码行数:34,代码来源:GestionDomaine.java
示例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();
}
开发者ID:ljug,项目名称:java-tutorials,代码行数:8,代码来源:OperationBase.java
示例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);
}
}
开发者ID:CESNET,项目名称:google-group-connector,代码行数:21,代码来源:GoogleGroupsServiceImpl.java
示例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);
}
}
开发者ID:CESNET,项目名称:google-group-connector,代码行数:16,代码来源:GoogleGroupsServiceImpl.java
示例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;
}
}
开发者ID:google,项目名称:account-provisioning-for-google-apps,代码行数:14,代码来源:GoogleDirectory.java
示例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();
}
开发者ID:google,项目名称:account-provisioning-for-google-apps,代码行数:40,代码来源:GoogleDirectory.java
示例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);
}
}
开发者ID:google,项目名称:account-provisioning-for-google-apps,代码行数:21,代码来源:GoogleDirectoryTest.java
示例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();
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:31,代码来源:GoogleProvisioningConnector.java
示例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();
}
}
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:14,代码来源:Cache.java
示例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());
}
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:10,代码来源:GoogleGrouperConnector.java
示例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);
}
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:10,代码来源:GoogleAppsChangeLogConsumerTest.java
示例16: main
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
ArrayList<String> scopes = new ArrayList<String>();
scopes.add(com.google.api.services.admin.directory.DirectoryScopes.ADMIN_DIRECTORY_USER);
scopes.add(com.google.api.services.admin.directory.DirectoryScopes.ADMIN_DIRECTORY_ORGUNIT);
GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId("[email protected]ccount.com")
.setServiceAccountScopes(scopes)
.setServiceAccountUser("[email protected]")
.setServiceAccountPrivateKeyFromP12File(new File("/Users/mlb/Downloads/TestMyVD-0cf017d369c9.p12"))
.build();
Directory service = new Directory.Builder(httpTransport, jsonFactory, credential)
.setApplicationName("TestMyVD")
.build();
List<User> allUsers = new ArrayList<User>();
Directory.Users.List request = service.users().list().setCustomer("my_customer");
System.out.println(request);
do {
try {
Users currentPage = request.execute();
allUsers.addAll(currentPage.getUsers());
request.setPageToken(currentPage.getNextPageToken());
} catch (IOException e) {
System.out.println("An error occurred: " + e);
request.setPageToken(null);
}
} while (request.getPageToken() != null &&
request.getPageToken().length() > 0 );
// Print all users
for (User currentUser : allUsers) {
System.out.println(currentUser);
}
List<User> searchRes = new ArrayList<User>();
}
开发者ID:TremoloSecurity,项目名称:OpenUnison,代码行数:52,代码来源:Test.java
示例17: 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
示例18: 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
示例19: processMembershipAdd
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
/**
* Add a membership.
*
* @param consumer the change log consumer
* @param changeLogEntry the change log entry
*/
protected void processMembershipAdd(GoogleAppsChangeLogConsumer consumer, ChangeLogEntry changeLogEntry) {
LOG.debug("Google Apps Consumer '{}' - Change log entry '{}' Processing membership add.", consumerName,
toString(changeLogEntry));
final String groupName = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.groupName);
final String memberId = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.memberId);
final edu.internet2.middleware.grouper.Group grouperGroup = connector.fetchGrouperGroup(groupName);
final Member member = MemberFinder.findByUuid(GrouperSession.staticGrouperSession(), memberId, false);
if (!connector.shouldSyncGroup(grouperGroup)) {
LOG.debug("Google Apps Consumer '{}' - Change log entry '{}' Skipping membership add, nothing to do cause the group is not flagged or is gone.", consumerName,
toString(changeLogEntry));
return;
}
final String subjectId = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.subjectId);
final String sourceId = changeLogEntry.retrieveValueForLabel(ChangeLogLabels.MEMBERSHIP_ADD.sourceId);
final Subject lookupSubject = connector.fetchGrouperSubject(sourceId, subjectId);
final SubjectType subjectType = lookupSubject.getType();
try {
Group group = connector.fetchGooGroup(connector.getAddressFormatter().qualifyGroupAddress(groupName));
if (group == null) {
connector.createGooGroupIfNecessary(grouperGroup);
group = connector.fetchGooGroup(connector.getAddressFormatter().qualifyGroupAddress(groupName));
}
//For nested groups, ChangeLogEvents fire when the group is added, and also for each indirect user added,
//so we only need to handle PERSON events.
if (subjectType == SubjectTypeEnum.PERSON) {
User user = connector.fetchGooUser(connector.getAddressFormatter().qualifySubjectAddress(subjectId));
if (user == null) {
user = connector.createGooUser(lookupSubject);
}
if (user != null) {
connector.createGooMember(group, user, connector.determineRole(member, grouperGroup));
}
}
} catch (IOException e) {
LOG.debug("Google Apps Consumer '{}' - Change log entry '{}' Error processing membership add failed: {}", new Object[] {consumerName,
toString(changeLogEntry), e});
}
}
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:53,代码来源:GoogleAppsChangeLogConsumer.java
示例20: googleUsers
import com.google.api.services.admin.directory.model.User; //导入依赖的package包/类
/**
*
* @return a Google User cache
*/
public static Cache<User> googleUsers() {
synchronized (usersLock) {
return googleUsers;
}
}
开发者ID:Unicon,项目名称:googleapps-grouper-provisioner,代码行数:10,代码来源:GoogleCacheManager.java
注:本文中的com.google.api.services.admin.directory.model.User类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论