-
Notifications
You must be signed in to change notification settings - Fork 3
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
Udl #13
Open
zzOzz
wants to merge
8
commits into
nuxeo-archives:7.10
Choose a base branch
from
zzOzz:udl
base: 7.10
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Udl #13
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
83446d7
first test
zzOzz 74c65c7
refactor all
zzOzz d179913
add normal invitation
zzOzz 62977cc
remove nuxeo code
zzOzz 1088deb
Merge branch '7.10' into udl
zzOzz 3528387
Merge branch '7.10' into udl
zzOzz ce53d69
changes for MR
zzOzz a2d7acd
changes for MR
zzOzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ pojo-bin | |
seam-bin | ||
deploy.sh | ||
log/ | ||
.idea | ||
nuxeo-shibboleth-invitation.iml | ||
|
||
*.pyc | ||
*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.nuxeo</groupId> | ||
<artifactId>nuxeo-addons-parent</artifactId> | ||
<version>7.10-HF35-SNAPSHOT</version> | ||
<groupId>fr.udl.nuxeo</groupId> | ||
<artifactId>package_parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<groupId>org.nuxeo.shibboleth.invitation</groupId> | ||
<artifactId>nuxeo-shibboleth-invitation</artifactId> | ||
<groupId>${marketplace.bundle.groupId}</groupId> | ||
<artifactId>nuxeo-shibboleth-invitation-udl</artifactId> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original groupId/artifactId should be set back. |
||
<name>nuxeo-shibboleth-invitation</name> | ||
<description> | ||
This addon provides the ability to invite external users to join Nuxeo | ||
|
@@ -122,4 +122,4 @@ | |
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
</project> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,32 +64,37 @@ public class ShibbolethUserMapper implements UserMapper { | |
|
||
@Override | ||
public NuxeoPrincipal getOrCreateAndUpdateNuxeoPrincipal(Object userObject) { | ||
log.trace("fuck getOrCreateAndUpdateNuxeoPrincipal"); | ||
return getOrCreateAndUpdateNuxeoPrincipal(userObject, true, true, null); | ||
} | ||
|
||
protected UserInvitationService fetchService() { | ||
log.trace("fuck fetchService"); | ||
return Framework.getLocalService(UserRegistrationService.class); | ||
} | ||
|
||
@Override | ||
public NuxeoPrincipal getOrCreateAndUpdateNuxeoPrincipal(Object userObject, boolean createIfNeeded, boolean update, | ||
Map<String, Serializable> params) { | ||
|
||
log.trace("fuck getOrCreateAndUpdateNuxeoPrincipal"); | ||
// Fetching keys from the shibboleth configuration in nuxeo | ||
ShibbolethAuthenticationService shiboService = Framework.getService(ShibbolethAuthenticationService.class); | ||
BiMap<String, String> metadata = shiboService.getUserMetadata(); | ||
String usernameKey = MoreObjects.firstNonNull(metadata.get("username"), "username"); | ||
String lastNameKey = MoreObjects.firstNonNull(metadata.get("lastName"), "lastName"); | ||
String firstNameKey = MoreObjects.firstNonNull(metadata.get("firstName"), "firstName"); | ||
String emailKey = MoreObjects.firstNonNull(metadata.get("email"), "email"); | ||
String companyKey = MoreObjects.firstNonNull(metadata.get("company"), "company"); | ||
String passwordKey = MoreObjects.firstNonNull(metadata.get("password"), "password"); | ||
|
||
String email = (String) ((Map) userObject).get(emailKey); | ||
ShibbolethUserInfo userInfo = new ShibbolethUserInfo((String) ((Map) userObject).get(usernameKey), | ||
(String) ((Map) userObject).get(passwordKey), (String) ((Map) userObject).get(firstNameKey), | ||
(String) ((Map) userObject).get(lastNameKey), (String) ((Map) userObject).get(companyKey), email); | ||
|
||
// BiMap<String, String> metadata = shiboService.getUserMetadata(); | ||
// String usernameKey = MoreObjects.firstNonNull(metadata.get("username"), "username"); | ||
// String lastNameKey = MoreObjects.firstNonNull(metadata.get("lastName"), "lastName"); | ||
// String firstNameKey = MoreObjects.firstNonNull(metadata.get("firstName"), "firstName"); | ||
// String emailKey = MoreObjects.firstNonNull(metadata.get("email"), "email"); | ||
// String companyKey = MoreObjects.firstNonNull(metadata.get("company"), "company"); | ||
// String passwordKey = MoreObjects.firstNonNull(metadata.get("password"), "password"); | ||
// | ||
// String email = (String) ((Map) userObject).get(emailKey); | ||
// ShibbolethUserInfo userInfo = new ShibbolethUserInfo((String) ((Map) userObject).get(usernameKey), | ||
// (String) ((Map) userObject).get(passwordKey), (String) ((Map) userObject).get(firstNameKey), | ||
// (String) ((Map) userObject).get(lastNameKey), (String) ((Map) userObject).get(companyKey), email); | ||
|
||
|
||
ShibbolethUserInfo userInfo = new ShibbolethUserInfo((String)((Map)userObject).get("username"), (String)((Map)userObject).get("password"), (String)((Map)userObject).get("firstName"), (String)((Map)userObject).get("lastName"), (String)((Map)userObject).get("company"), (String)((Map)userObject).get("email")); | ||
String email = (String)((Map)userObject).get("email"); | ||
// Check if email has been provided and if invitation has been assigned to a user with email as username | ||
DocumentModel userDoc = null; | ||
String userName = userInfo.getUserName(); | ||
|
@@ -111,15 +116,19 @@ public NuxeoPrincipal getOrCreateAndUpdateNuxeoPrincipal(Object userObject, bool | |
return userManager.getPrincipal(userId); | ||
} | ||
|
||
protected void updateACP(String userName, String email, DocumentModel userDoc) { | ||
protected void updateACP(final String userName,final String email, final DocumentModel userDoc) { | ||
log.trace("fuck updateACP"); | ||
new UnrestrictedSessionRunner(getTargetRepositoryName()) { | ||
@Override | ||
public void run() { | ||
|
||
NuxeoPrincipal principal = userManager.getPrincipal( | ||
(String) userDoc.getProperty(userSchemaName, "username")); | ||
ArrayList<String> groups = new ArrayList<>(principal.getGroups()); | ||
|
||
log.trace("group for user " + userName + ":" + principal.getPrincipalId() + ":" + principal.getEmail()); | ||
for(String group: groups) { | ||
log.trace(group); | ||
} | ||
userManager.deleteUser(userDoc); | ||
userDoc.setPropertyValue("user:username", userName); | ||
userDoc.setPropertyValue("user:groups", groups); | ||
|
@@ -162,6 +171,7 @@ public void run() { | |
} | ||
|
||
protected DocumentModel createUser(ShibbolethUserInfo userInfo) { | ||
log.trace("fuck createUser"); | ||
DocumentModel userDoc; | ||
try { | ||
userDoc = userManager.getBareUserModel(); | ||
|
@@ -178,12 +188,14 @@ protected DocumentModel createUser(ShibbolethUserInfo userInfo) { | |
|
||
@Override | ||
public void init(Map<String, String> params) throws Exception { | ||
log.trace("fuck init"); | ||
userManager = Framework.getLocalService(UserManager.class); | ||
userSchemaName = userManager.getUserSchemaName(); | ||
groupSchemaName = userManager.getGroupSchemaName(); | ||
} | ||
|
||
private DocumentModel findUser(String field, String userName) { | ||
log.trace("fuck findUser"); | ||
Map<String, Serializable> query = new HashMap<>(); | ||
query.put(field, userName); | ||
DocumentModelList users = userManager.searchUsers(query, null); | ||
|
@@ -195,26 +207,38 @@ private DocumentModel findUser(String field, String userName) { | |
} | ||
|
||
private DocumentModel updateUser(DocumentModel userDoc, ShibbolethUserInfo userInfo) { | ||
log.trace("fuck updateUser"); | ||
NuxeoPrincipal principal = userManager.getPrincipal( | ||
(String) userDoc.getProperty(userSchemaName, "username")); | ||
ArrayList<String> groups = new ArrayList<>(principal.getGroups()); | ||
log.trace("group for user :" + userDoc.getProperty(userSchemaName, "username") + ":" + principal.getEmail()); | ||
for(String group: groups) { | ||
log.trace(group); | ||
} | ||
userDoc.setPropertyValue(userManager.getUserEmailField(), userInfo.getEmail()); | ||
userDoc.setProperty(userSchemaName, "firstName", userInfo.getFirstName()); | ||
userDoc.setProperty(userSchemaName, "lastName", userInfo.getLastName()); | ||
userDoc.setProperty(userSchemaName, "password", userInfo.getPassword()); | ||
userDoc.setProperty(userSchemaName, "company", userInfo.getCompany()); | ||
userDoc.setPropertyValue("user:groups", groups); | ||
userManager.updateUser(userDoc); | ||
return userDoc; | ||
} | ||
|
||
@Override | ||
public Object wrapNuxeoPrincipal(NuxeoPrincipal principal, Object nativePrincipal, | ||
Map<String, Serializable> params) { | ||
log.trace("fuck wrapNuxeoPrincipal"); | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void release() { | ||
log.trace("fuck release"); | ||
} | ||
|
||
public String getTargetRepositoryName() { | ||
log.trace("fuck getTargetRepositoryName"); | ||
return Framework.getService(RepositoryManager.class).getDefaultRepositoryName(); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for deprecation instead of removal. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be removed from the commit.