Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location attribute added, removed extra scope #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ public void getGoogleCredential() {
try (InputStream inputStream = new ByteArrayInputStream(keyJson.getBytes(StandardCharsets.UTF_8))) {
credentials = ServiceAccountCredentials.fromStream(inputStream, () -> HTTP_TRANSPORT)
.createScoped(DirectoryScopes.ADMIN_DIRECTORY_USER,
DirectoryScopes.ADMIN_DIRECTORY_GROUP,
DirectoryScopes.ADMIN_DIRECTORY_GROUP,
LicensingScopes.APPS_LICENSING)
.createDelegated(getServiceAccountUser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public class GoogleAppsConnector implements Connector, CreateOp, DeleteOp, Schem
public static final String TYPE_ATTR = "type";
public static final String PRODUCT_ID_SKU_ID_USER_ID = "productId,skuId,userId";
public static final String PHOTO_ATTR = "__PHOTO__";
public static final String LOCATIONS_ATTR = "locations";

/**
* Place holder for the {@link Configuration} passed into the init() method
* {@link GoogleAppsConnector#init(org.identityconnectors.framework.spi.Configuration)}
Expand Down Expand Up @@ -1742,13 +1744,17 @@ private ConnectorObject getUserFromResource(User user, ConnectorObjectBuilder bu
.getOrganizations())));
}
if (null == attributesToGet || attributesToGet.contains(PHONES_ATTR)) {
// builder.addAttribute(AttributeBuilder.build(PHONES_ATTR, (Collection) user.getPhones()));
builder.addAttribute(AttributeBuilder.build(PHONES_ATTR, (Collection) GoogleAppsUtil.structAttrToString((Collection) user.getPhones())));
}
if (null == attributesToGet || attributesToGet.contains(ALIASES_ATTR)) {
builder.addAttribute(AttributeBuilder.build(ALIASES_ATTR, (Collection) GoogleAppsUtil.structAttrToString((Collection) user.getAliases())));
}

if (null == attributesToGet || attributesToGet.contains(LOCATIONS_ATTR)) {
builder.addAttribute(AttributeBuilder.build(LOCATIONS_ATTR, (Collection) GoogleAppsUtil.structAttrToString((Collection) user
.getLocations())));
}

if (null == attributesToGet || attributesToGet.contains(NON_EDITABLE_ALIASES_ATTR)) {
builder.addAttribute(AttributeBuilder.build(NON_EDITABLE_ALIASES_ATTR, user
.getNonEditableAliases()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class UserHandler implements FilterVisitor<StringBuilder, Directory.Users
public static final String IS_MAILBOX_SETUP_ATTR = "isMailboxSetup";
public static final String THUMBNAIL_PHOTO_URL_ATTR = "thumbnailPhotoUrl";
public static final String DELETION_TIME_ATTR = "deletionTime";
public static final String LOCATIONS_ATTR = "locations";

private static final Map<String, String> NAME_DICTIONARY;
private static final Set<String> S;
Expand Down Expand Up @@ -475,6 +476,8 @@ public static ObjectClassInfo getUserClassInfo() {
.setMultiValued(true).build());
builder.addAttributeInfo(AttributeInfoBuilder.define(ALIASES_ATTR)
.setMultiValued(true).build());
builder.addAttributeInfo(AttributeInfoBuilder.define(LOCATIONS_ATTR)
.setMultiValued(true).build());

builder.addAttributeInfo(AttributeInfoBuilder.define(NON_EDITABLE_ALIASES_ATTR)
.setUpdateable(false).setCreateable(false).setMultiValued(true).build());
Expand Down Expand Up @@ -559,6 +562,7 @@ public static Directory.Users.Insert createUser(Directory.Users users,
user.setAddresses(GoogleAppsUtil.getStructAttr((Attribute) attributes.find(ADDRESSES_ATTR)));
user.setOrganizations(GoogleAppsUtil.getStructAttr((Attribute) attributes.find(ORGANIZATIONS_ATTR)));
user.setPhones(GoogleAppsUtil.getStructAttr((Attribute) attributes.find(PHONES_ATTR)));
user.setLocations(GoogleAppsUtil.getStructAttr((Attribute) attributes.find(LOCATIONS_ATTR)));

user.setSuspended(attributes.findBoolean(SUSPENDED_ATTR));
user.setChangePasswordAtNextLogin(attributes
Expand Down Expand Up @@ -709,10 +713,17 @@ public static Directory.Users.Patch updateUser(Directory.Users users, Uid uid,
if (null == content) {
content = new User();
}
// content.setPhones(phones.getValue());
content.setPhones(GoogleAppsUtil.getStructAttr(phones));
}

Attribute locations = attributes.find(LOCATIONS_ATTR);
if (null != locations) {
if (null == content) {
content = new User();
}
content.setLocations(GoogleAppsUtil.getStructAttr(locations));
}

Attribute orgUnitPath = attributes.find(ORG_UNIT_PATH_ATTR);
if (null != orgUnitPath) {
String stringValue = GoogleAppsUtil.getStringValueWithDefault(orgUnitPath, null);
Expand Down