com.google.api.services.admin.directory.model.User Java Examples

The following examples show how to use com.google.api.services.admin.directory.model.User. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DirectoryFacade.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a user in the Cloud Identity service.
 *
 * The mandatory fields password, first, and last name are set to the user's email.
 */
private void createUser(String userEmail) throws IOException {
  User user = new User()
      .setPrimaryEmail(userEmail)
      .setPassword(userEmail)
      .setName(new UserName()
          .setGivenName("Fake Given Name")
          .setFamilyName("Fake Family Name"));
  logger.info("Creating user " + userEmail);
  user = directory
      .users()
      .insert(user)
      .execute();
  verify(user != null);
  logger.fine("Created user " + user.toPrettyString());
}
 
Example #2
Source File: IdentityUserTest.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testSyncAliasMatch() throws IOException, InterruptedException, ExecutionException {
  IdentityUser user =
      new IdentityUser.Builder()
          .setUserIdentity("user1")
          .setSchema("schema")
          .setAttribute("attrib")
          .setGoogleIdentity("[email protected]")
          .build();
  when(mockIdentityService.updateUserMapping(
          "[email protected]", "schema", "attrib", Optional.of("user1")))
      .thenReturn(
          Futures.immediateFuture(
              new User()
                  .setPrimaryEmail("[email protected]")
                  .setAliases(ImmutableList.of("[email protected]"))));
  ListenableFuture<IdentityUser> sync = user.sync(null, mockIdentityService);
  assertEquals(user, sync.get());
}
 
Example #3
Source File: UsersServiceImplTest.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateUserMappingWithoutValue() throws Exception {
  String userId = "[email protected]";
  Users.Update updateRequest = mock(Users.Update.class);
  Map<String, Map<String, Object>> schema =
      Collections.singletonMap("schema", Collections.singletonMap("attribute", ""));
  when(users.update(userId, new User().setCustomSchemas(schema))).thenReturn(updateRequest);
  User toReturn = new User().setPrimaryEmail(userId);
  doAnswer(
          invocation -> {
            AsyncRequest<User> input = invocation.getArgument(0);
            setAsyncRequestResponse(input, toReturn);
            return null;
          })
      .when(batchRequestService)
      .add(any());
  ListenableFuture<User> user =
      usersService.updateUserMapping(userId, "schema", "attribute", Optional.empty());
  assertEquals(toReturn, user.get());
}
 
Example #4
Source File: UsersServiceImplTest.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testUpdateUserMappingWithValue() throws Exception {
  String userId = "[email protected]";
  Users.Update updateRequest = mock(Users.Update.class);
  Map<String, Map<String, Object>> schema =
      Collections.singletonMap("schema", Collections.singletonMap("attribute", "value"));
  when(users.update(userId, new User().setCustomSchemas(schema))).thenReturn(updateRequest);
  User toReturn = new User().setPrimaryEmail(userId);
  doAnswer(
          invocation -> {
            AsyncRequest<User> input = invocation.getArgument(0);
            setAsyncRequestResponse(input, toReturn);
            return null;
          })
      .when(batchRequestService)
      .add(any());
  ListenableFuture<User> user =
      usersService.updateUserMapping(userId, "schema", "attribute", Optional.of("value"));
  assertEquals(toReturn, user.get());
}
 
Example #5
Source File: UsersServiceImplTest.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetUser() throws Exception {
  String userId = "[email protected]";
  Users.Get getRequest = mock(Users.Get.class);
  when(getRequest.setProjection("full")).thenReturn(getRequest);
  when(users.get(userId)).thenReturn(getRequest);
  User toReturn = new User().setPrimaryEmail(userId);
  doAnswer(
          invocation -> {
            AsyncRequest<User> input = invocation.getArgument(0);
            setAsyncRequestResponse(input, toReturn);
            return null;
          })
      .when(batchRequestService)
      .add(any());
  ListenableFuture<User> user = usersService.getUserMapping(userId);
  assertEquals(toReturn, user.get());
}
 
Example #6
Source File: IdentityUser.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
/**
 * Unmaps {@link IdentityUser}, by clearing out {@link IdentityUser#getAttribute}, using Google
 * Admin SDK API.
 */
@Override
public ListenableFuture<Boolean> unmap(IdentityService service) throws IOException {
  logger.log(Level.FINE, "Unmapping user {0}", this);
  ListenableFuture<User> updateUserMapping =
      service.updateUserMapping(googleIdentity, schema, attribute, Optional.empty());
  return Futures.transform(
      updateUserMapping,
      new Function<User, Boolean>() {
        @Override
        @Nullable
        public Boolean apply(@Nullable User input) {
          checkNotNull(input, "updated user can not be null");
          checkArgument(
              isSameUser(googleIdentity, input),
              "unexpected user object. expected %s got %s",
              googleIdentity,
              input);
          return true;
        }
      },
      getExecutor());
}
 
Example #7
Source File: IdentityUser.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
/** Syncs {@link IdentityUser} with Google Admin SDK API using {@code service} */
@Override
public ListenableFuture<IdentityUser> sync(
    @Nullable IdentityUser previouslySynced, IdentityService service) throws IOException {
  if (this.equals(previouslySynced)) {
    return Futures.immediateFuture(this);
  }
  logger.log(Level.FINE, "Syncing user {0}", this);
  ListenableFuture<User> updateUserMapping =
      service.updateUserMapping(googleIdentity, schema, attribute, Optional.of(identity));
  return Futures.transform(
      updateUserMapping,
      (@Nullable User input) -> {
        checkState(input != null, "user can not be null");
        checkArgument(
            isSameUser(googleIdentity, input),
            "unexpected user object. expected %s got %s",
            googleIdentity,
            input);
        return this;
      },
      getExecutor());
}
 
Example #8
Source File: UsersServiceImpl.java    From connector-sdk with Apache License 2.0 6 votes vote down vote up
/** Updates {@link User}'s custom schema attributes using Google Admin SDK API. */
@Override
public ListenableFuture<User> updateUserMapping(
    String userId, String schemaName, String attributeName, Optional<String> value)
    throws IOException {
  Update update =
      service
          .users()
          .update(
              userId,
              new User()
                  .setCustomSchemas(
                      Collections.singletonMap(
                          schemaName,
                          Collections.singletonMap(attributeName, value.orElse("")))));
  return batchRequest(update, retryPolicy, batchService);
}
 
Example #9
Source File: FakeIdentityRepositoryIT.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
private Object getSchemaValueForUser(String userEmail) throws IOException {
  final String idKey = identitySourceId + "_identifier";
  User user = dirFacade.fetchUser(userEmail);
  Map<String, Map<String, Object>> schemas = user.getCustomSchemas();

  assertNotNull(schemas);
  assertThat(schemas.keySet(), hasItem(identitySourceId));
  Map<String, Object> sourceIdMap = schemas.get(identitySourceId);
  assertThat(sourceIdMap.keySet(), hasItem(idKey));
  return sourceIdMap.get(idKey);
}
 
Example #10
Source File: MapUserIdentityCommand.java    From cloud-search-samples with Apache License 2.0 5 votes vote down vote up
public void run() {
  try {
    Directory service = Utils.buildDirectoryService();
    Map<String, Object> properties = Collections.singletonMap(
        idSource + "_identifier", externalId);
    User user = new User().setCustomSchemas(
        Collections.singletonMap(idSource, properties));
    User updatedUser = service.users().update(userEmail, user).execute();
    System.out.printf("Updated user %s", updatedUser.toPrettyString());
  } catch (Exception e) {
    System.err.printf("Unable to map user identity: %s\n", e);
    e.printStackTrace(System.err);
  }
}
 
Example #11
Source File: UnmapUserIdentityCommand.java    From cloud-search-samples with Apache License 2.0 5 votes vote down vote up
public void run() {
  try {
    Directory service = Utils.buildDirectoryService();
    Map<String, Object> properties = Collections.singletonMap(
        idSource + "_identifier", "");
    User user = new User().setCustomSchemas(
        Collections.singletonMap(idSource, properties));
    User updatedUser = service.users().update(userEmail, user).execute();
    System.out.printf("Updated user: %s", updatedUser.toPrettyString());
  } catch (Exception e) {
    System.err.printf("Unable to unmap user identity: %s\n", e);
    e.printStackTrace(System.err);
  }
}
 
Example #12
Source File: GetUserCommand.java    From cloud-search-samples with Apache License 2.0 5 votes vote down vote up
public void run() {
  try {
    Directory service = Utils.buildDirectoryService();
    User user = service.users().get(userEmail)
        .setProjection("full")
        .execute();
    System.out.printf("User: %s\n", user.toPrettyString());
  } catch (Exception e) {
    System.err.printf("Unable to retrieve user: %s\n", e);
    e.printStackTrace(System.err);
  }
}
 
Example #13
Source File: IdentityUserTest.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnmap() throws IOException, InterruptedException, ExecutionException {
  IdentityUser user =
      new IdentityUser.Builder()
          .setUserIdentity("user1")
          .setSchema("schema")
          .setAttribute("attrib")
          .setGoogleIdentity("[email protected]")
          .build();
  when(mockIdentityService.updateUserMapping(
          "[email protected]", "schema", "attrib", Optional.empty()))
      .thenReturn(Futures.immediateFuture(new User().setPrimaryEmail("[email protected]")));
  ListenableFuture<Boolean> sync = user.unmap(mockIdentityService);
  assertTrue(sync.get());
}
 
Example #14
Source File: IdentityUserTest.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testSyncMismatch() throws IOException, InterruptedException, ExecutionException {
  IdentityUser user =
      new IdentityUser.Builder()
          .setUserIdentity("user1")
          .setSchema("schema")
          .setAttribute("attrib")
          .setGoogleIdentity("[email protected]")
          .build();
  when(mockIdentityService.updateUserMapping(
          "[email protected]", "schema", "attrib", Optional.of("user1")))
      .thenReturn(Futures.immediateFuture(new User().setPrimaryEmail("[email protected]")));
  thrown.expectCause(isA(IllegalArgumentException.class));
  user.sync(null, mockIdentityService).get();
}
 
Example #15
Source File: DirectoryFacade.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Fetches a user's details from the Cloud Identity Service.
 */
User fetchUser(String userEmail) throws IOException {
  logger.info("Fetching user " + userEmail);
  User user = directory
      .users()
      .get(userEmail)
      .setProjection(USER_PROJECTION_FULL)
      .execute();
  logger.fine("Fetched user " + user.toPrettyString());
  return user;
}
 
Example #16
Source File: IdentityUserTest.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testSyncIgnoreCase() throws IOException, InterruptedException, ExecutionException {
  IdentityUser user =
      new IdentityUser.Builder()
          .setUserIdentity("user1")
          .setSchema("schema")
          .setAttribute("attrib")
          .setGoogleIdentity("[email protected]")
          .build();
  when(mockIdentityService.updateUserMapping(
          "[email protected]", "schema", "attrib", Optional.of("user1")))
      .thenReturn(Futures.immediateFuture(new User().setPrimaryEmail("[email protected]")));
  ListenableFuture<IdentityUser> sync = user.sync(null, mockIdentityService);
  assertEquals(user, sync.get());
}
 
Example #17
Source File: IdentityUserTest.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testSync() throws IOException, InterruptedException, ExecutionException {
  IdentityUser user =
      new IdentityUser.Builder()
          .setUserIdentity("user1")
          .setSchema("schema")
          .setAttribute("attrib")
          .setGoogleIdentity("[email protected]")
          .build();
  when(mockIdentityService.updateUserMapping(
          "[email protected]", "schema", "attrib", Optional.of("user1")))
      .thenReturn(Futures.immediateFuture(new User().setPrimaryEmail("[email protected]")));
  ListenableFuture<IdentityUser> sync = user.sync(null, mockIdentityService);
  assertEquals(user, sync.get());
}
 
Example #18
Source File: UsersServiceImplTest.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void testListUsers() throws Exception {
  Users.List list1 = mock(Users.List.class);
  when(list1.setCustomer("customer1")).thenReturn(list1);
  when(list1.setCustomFieldMask("schema")).thenReturn(list1);
  when(list1.setProjection("custom")).thenReturn(list1);
  when(list1.setPageToken(null)).thenReturn(list1);

  User user1 = new User().setPrimaryEmail("[email protected]");
  when(list1.execute())
      .thenReturn(
          new com.google.api.services.admin.directory.model.Users()
              .setNextPageToken("nextPage")
              .setUsers(Collections.singletonList(user1)));

  Users.List list2 = mock(Users.List.class);
  when(list2.setCustomer("customer1")).thenReturn(list2);
  when(list2.setCustomFieldMask("schema")).thenReturn(list2);
  when(list2.setProjection("custom")).thenReturn(list2);
  when(list2.setPageToken("nextPage")).thenReturn(list2);

  User user2 = new User().setPrimaryEmail("[email protected]");
  when(list2.execute())
      .thenReturn(
          new com.google.api.services.admin.directory.model.Users()
              .setUsers(Collections.singletonList(user2)));
  when(users.list()).thenReturn(list1, list2);
  Iterable<User> actual = usersService.listUsers("schema");
  assertTrue(Iterables.elementsEqual(ImmutableList.of(user1, user2), actual));
}
 
Example #19
Source File: DirectoryFacade.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a list of all the e-mails in the domain.
 */
private ImmutableSet<String> listAllEmailsInDomain() throws IOException {
  Set<String> allUserIds = new HashSet<>();
  String nextPageToken = null;
  do {
    logger.fine("Fetching the next page of users...");
    Users users = directory
        .users()
        .list()
        .setMaxResults(NUM_USERS_PER_PAGE)
        .setDomain(domain)
        .setPageToken(nextPageToken)
        .execute();
    List<User> userList = users.getUsers();
    if (userList != null) {
      logger.log(Level.FINE, "Fetched {0} users.", userList.size());
      allUserIds.addAll(
          userList
              .stream()
              .map(User::getPrimaryEmail)
              .collect(Collectors.toSet()));
    }
    nextPageToken = users.getNextPageToken();
    logger.log(Level.FINE, "Next users page token is \"{0}\".", nextPageToken);
  } while (nextPageToken != null);
  logger.log(Level.FINE, "Fetched a total of {0} users.", allUserIds.size());
  return ImmutableSet.copyOf(allUserIds);
}
 
Example #20
Source File: GoogleDirectory.java    From account-provisioning-for-google-apps with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
  }
}
 
Example #21
Source File: GoogleDirectory.java    From account-provisioning-for-google-apps with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #22
Source File: GoogleDirectoryTest.java    From account-provisioning-for-google-apps with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example #23
Source File: GoogleProvisioningConnector.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #24
Source File: FullSyncIdentityConnector.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
private Optional<IdentityUser> buildIdentityUser(User u) {
  Map<String, Map<String, Object>> customSchemas = u.getCustomSchemas();
  if (customSchemas == null) {
    return Optional.empty();
  }
  Map<String, Object> values = customSchemas.get(sourceConfiguration.getIdentitySourceSchema());
  if (values == null) {
    return Optional.empty();
  }
  Object value = values.get(sourceConfiguration.getIdentitySourceSchemaAttribute());
  if (value == null) {
    return Optional.empty();
  }

  String userIdentity = value.toString();
  if (userIdentity.isEmpty()) {
    return Optional.empty();
  }

  return Optional.of(
      new IdentityUser.Builder()
          .setGoogleIdentity(u.getPrimaryEmail())
          .setSchema(sourceConfiguration.getIdentitySourceSchema())
          .setAttribute(sourceConfiguration.getIdentitySourceSchemaAttribute())
          .setUserIdentity(userIdentity)
          .build());
}
 
Example #25
Source File: IdentityUser.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
private static boolean isSameUser(String googleIdentity, User user) {
  if (googleIdentity.equalsIgnoreCase(user.getPrimaryEmail())) {
    return true;
  }
  if (user.getAliases() == null) {
    return false;
  }
  return user.getAliases().stream().anyMatch(googleIdentity::equalsIgnoreCase);
}
 
Example #26
Source File: IdentityServiceImpl.java    From connector-sdk with Apache License 2.0 5 votes vote down vote up
/** Updates {@link User}'s custom schema attributes using Google Admin SDK API. */
@Override
public ListenableFuture<User> updateUserMapping(
    String userId, String schemaName, String attributeName, Optional<String> value)
    throws IOException {
  return usersService.updateUserMapping(userId, schemaName, attributeName, value);
}
 
Example #27
Source File: GoogleProvisioningConnector.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
/**
 * 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;
}
 
Example #28
Source File: GoogleProvisioningConnector.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example #29
Source File: UsersServiceImpl.java    From connector-sdk with Apache License 2.0 4 votes vote down vote up
/** Gets {@link User} from Google Admin SDK API. */
@Override
public ListenableFuture<User> getUserMapping(String userId) throws IOException {
  Get get = service.users().get(userId).setProjection("full");
  return batchRequest(get, retryPolicy, batchService);
}
 
Example #30
Source File: IdentityServiceImpl.java    From connector-sdk with Apache License 2.0 4 votes vote down vote up
/** Gets {@link User} from Google Admin SDK API. */
@Override
public ListenableFuture<User> getUserMapping(String userId) throws IOException {
  return usersService.getUserMapping(userId);
}