summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--distrib/gitblit.properties14
-rw-r--r--src/com/gitblit/ConfigUserService.java24
-rw-r--r--src/com/gitblit/FileUserService.java22
-rw-r--r--src/com/gitblit/GitBlit.java20
-rw-r--r--src/com/gitblit/GitblitUserService.java10
-rw-r--r--src/com/gitblit/IUserService.java16
-rw-r--r--src/com/gitblit/LdapUserService.java63
-rw-r--r--src/com/gitblit/wicket/pages/EditUserPage.java10
8 files changed, 151 insertions, 28 deletions
diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties
index da662126..8bfa417e 100644
--- a/distrib/gitblit.properties
+++ b/distrib/gitblit.properties
@@ -231,21 +231,21 @@ realm.ldap.groupMemberPattern = (&(objectClass=group)(member=${dn}))
#
# SPACE-DELIMITED
# SINCE 1.0.0
-realm.ldap.admins= @Git_Admins
+realm.ldap.admins = @Git_Admins
-# Attribute(s) on the USER record that indicate their display (or full) name. Leave blank
-# for no mapping available in LDAP
+# Attribute(s) on the USER record that indicate their display (or full) name.
+# Leave blank for no mapping available in LDAP.
#
# This may be a single attribute, or a string of multiple attributes. Examples:
# displayName - Uses the attribute 'displayName' on the user record
# ${personalTitle}. ${givenName} ${surname} - Will concatenate the 3
-# attributes together, with a '.' after personalTitle
+# attributes together, with a '.' after personalTitle
#
# SINCE 1.0.0
-realm.ldap.displayName= displayName
+realm.ldap.displayName = displayName
-# Attribute(s) on the USER record that indicate their email address. Leave blank
-# for no mapping available in LDAP
+# Attribute(s) on the USER record that indicate their email address.
+# Leave blank for no mapping available in LDAP.
#
# This may be a single attribute, or a string of multiple attributes. Examples:
# email - Uses the attribute 'email' on the user record
diff --git a/src/com/gitblit/ConfigUserService.java b/src/com/gitblit/ConfigUserService.java
index 8170be7c..b97154f4 100644
--- a/src/com/gitblit/ConfigUserService.java
+++ b/src/com/gitblit/ConfigUserService.java
@@ -113,7 +113,29 @@ public class ConfigUserService implements IUserService {
public boolean supportsCredentialChanges() {
return true;
}
-
+
+ /**
+ * Does the user service support changes to user display name?
+ *
+ * @return true or false
+ * @since 1.0.0
+ */
+ @Override
+ public boolean supportsDisplayNameChanges() {
+ return true;
+ }
+
+ /**
+ * Does the user service support changes to user email address?
+ *
+ * @return true or false
+ * @since 1.0.0
+ */
+ @Override
+ public boolean supportsEmailAddressChanges() {
+ return true;
+ }
+
/**
* Does the user service support changes to team memberships?
*
diff --git a/src/com/gitblit/FileUserService.java b/src/com/gitblit/FileUserService.java
index 02cf2b00..fcb8eaeb 100644
--- a/src/com/gitblit/FileUserService.java
+++ b/src/com/gitblit/FileUserService.java
@@ -85,6 +85,28 @@ public class FileUserService extends FileSettings implements IUserService {
}
/**
+ * Does the user service support changes to user display name?
+ *
+ * @return true or false
+ * @since 1.0.0
+ */
+ @Override
+ public boolean supportsDisplayNameChanges() {
+ return false;
+ }
+
+ /**
+ * Does the user service support changes to user email address?
+ *
+ * @return true or false
+ * @since 1.0.0
+ */
+ @Override
+ public boolean supportsEmailAddressChanges() {
+ return false;
+ }
+
+ /**
* Does the user service support changes to team memberships?
*
* @return true or false
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index a616bef7..565b024a 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -388,6 +388,22 @@ public class GitBlit implements ServletContextListener {
/**
*
+ * @return true if the user service supports display name changes
+ */
+ public boolean supportsDisplayNameChanges() {
+ return userService.supportsDisplayNameChanges();
+ }
+
+ /**
+ *
+ * @return true if the user service supports email address changes
+ */
+ public boolean supportsEmailAddressChanges() {
+ return userService.supportsEmailAddressChanges();
+ }
+
+ /**
+ *
* @return true if the user service supports team membership changes
*/
public boolean supportsTeamMembershipChanges() {
@@ -1780,6 +1796,10 @@ public class GitBlit implements ServletContextListener {
*/
private ServerSettings loadSettingModels() {
ServerSettings settingsModel = new ServerSettings();
+ settingsModel.supportsCredentialChanges = userService.supportsCredentialChanges();
+ settingsModel.supportsDisplayNameChanges = userService.supportsDisplayNameChanges();
+ settingsModel.supportsEmailAddressChanges = userService.supportsEmailAddressChanges();
+ settingsModel.supportsTeamMembershipChanges = userService.supportsTeamMembershipChanges();
try {
// Read bundled Gitblit properties to extract setting descriptions.
// This copy is pristine and only used for populating the setting
diff --git a/src/com/gitblit/GitblitUserService.java b/src/com/gitblit/GitblitUserService.java
index 7ad3db71..bb52bef4 100644
--- a/src/com/gitblit/GitblitUserService.java
+++ b/src/com/gitblit/GitblitUserService.java
@@ -118,6 +118,16 @@ public class GitblitUserService implements IUserService {
}
@Override
+ public boolean supportsDisplayNameChanges() {
+ return serviceImpl.supportsDisplayNameChanges();
+ }
+
+ @Override
+ public boolean supportsEmailAddressChanges() {
+ return serviceImpl.supportsEmailAddressChanges();
+ }
+
+ @Override
public boolean supportsTeamMembershipChanges() {
return serviceImpl.supportsTeamMembershipChanges();
}
diff --git a/src/com/gitblit/IUserService.java b/src/com/gitblit/IUserService.java
index c3573db8..78b6e2f9 100644
--- a/src/com/gitblit/IUserService.java
+++ b/src/com/gitblit/IUserService.java
@@ -46,6 +46,22 @@ public interface IUserService {
* @since 1.0.0
*/
boolean supportsCredentialChanges();
+
+ /**
+ * Does the user service support changes to user display name?
+ *
+ * @return true or false
+ * @since 1.0.0
+ */
+ boolean supportsDisplayNameChanges();
+
+ /**
+ * Does the user service support changes to user email address?
+ *
+ * @return true or false
+ * @since 1.0.0
+ */
+ boolean supportsEmailAddressChanges();
/**
* Does the user service support changes to team memberships?
diff --git a/src/com/gitblit/LdapUserService.java b/src/com/gitblit/LdapUserService.java
index 80a966dd..78b5f99f 100644
--- a/src/com/gitblit/LdapUserService.java
+++ b/src/com/gitblit/LdapUserService.java
@@ -106,6 +106,29 @@ public class LdapUserService extends GitblitUserService {
}
/**
+ * If no displayName pattern is defined then Gitblit can manage the display name.
+ *
+ * @return true if Gitblit can manage the user display name
+ * @since 1.0.0
+ */
+ @Override
+ public boolean supportsDisplayNameChanges() {
+ return StringUtils.isEmpty(settings.getString(Keys.realm.ldap.displayName, ""));
+ }
+
+ /**
+ * If no email pattern is defined then Gitblit can manage the email address.
+ *
+ * @return true if Gitblit can manage the user email address
+ * @since 1.0.0
+ */
+ @Override
+ public boolean supportsEmailAddressChanges() {
+ return StringUtils.isEmpty(settings.getString(Keys.realm.ldap.email, ""));
+ }
+
+
+ /**
* If the LDAP server will maintain team memberships then LdapUserService
* will not allow team membership changes. In this scenario all team
* changes must be made on the LDAP server by the LDAP administrator.
@@ -194,27 +217,31 @@ public class LdapUserService extends GitblitUserService {
// Don't want visibility into the real password, make up a dummy
user.password = "StoredInLDAP";
- // Get Attributes for full name / email
- String displayName = settings.getString(Keys.realm.ldap.displayName, "displayName");
- String email = settings.getString(Keys.realm.ldap.email, "email");
+ // Get full name Attribute
+ String displayName = settings.getString(Keys.realm.ldap.displayName, "");
+ if (!StringUtils.isEmpty(displayName)) {
+ // Replace embedded ${} with attributes
+ if (displayName.contains("${")) {
+ for (Attribute userAttribute : userEntry.getAttributes())
+ displayName = StringUtils.replace(displayName, "${" + userAttribute.getName() + "}", userAttribute.getValue());
- // Replace embedded ${} with attributes
- if (displayName.contains("${")) {
- for (Attribute userAttribute : userEntry.getAttributes())
- displayName = StringUtils.replace(displayName, "${" + userAttribute.getName() + "}", userAttribute.getValue());
-
- user.displayName = displayName;
- } else {
- user.displayName = userEntry.getAttribute(displayName).getValue();
+ user.displayName = displayName;
+ } else {
+ user.displayName = userEntry.getAttribute(displayName).getValue();
+ }
}
- if (email.contains("${")) {
- for (Attribute userAttribute : userEntry.getAttributes())
- email = StringUtils.replace(email, "${" + userAttribute.getName() + "}", userAttribute.getValue());
-
- user.emailAddress = email;
- } else {
- user.emailAddress = userEntry.getAttribute(email).getValue();
+ // Get email address Attribute
+ String email = settings.getString(Keys.realm.ldap.email, "");
+ if (!StringUtils.isEmpty(email)) {
+ if (email.contains("${")) {
+ for (Attribute userAttribute : userEntry.getAttributes())
+ email = StringUtils.replace(email, "${" + userAttribute.getName() + "}", userAttribute.getValue());
+
+ user.emailAddress = email;
+ } else {
+ user.emailAddress = userEntry.getAttribute(email).getValue();
+ }
}
}
diff --git a/src/com/gitblit/wicket/pages/EditUserPage.java b/src/com/gitblit/wicket/pages/EditUserPage.java
index 1b3a0745..cfe7c35d 100644
--- a/src/com/gitblit/wicket/pages/EditUserPage.java
+++ b/src/com/gitblit/wicket/pages/EditUserPage.java
@@ -209,6 +209,12 @@ public class EditUserPage extends RootSubPage {
// not all user services support manipulating username and password
boolean editCredentials = GitBlit.self().supportsCredentialChanges();
+
+ // not all user services support manipulating display name
+ boolean editDisplayName = GitBlit.self().supportsDisplayNameChanges();
+
+ // not all user services support manipulating email address
+ boolean editEmailAddress = GitBlit.self().supportsEmailAddressChanges();
// not all user services support manipulating team memberships
boolean editTeams = GitBlit.self().supportsTeamMembershipChanges();
@@ -222,8 +228,8 @@ public class EditUserPage extends RootSubPage {
confirmPassword);
confirmPasswordField.setResetPassword(false);
form.add(confirmPasswordField.setEnabled(editCredentials));
- form.add(new TextField<String>("displayName").setEnabled(editCredentials));
- form.add(new TextField<String>("emailAddress").setEnabled(editCredentials));
+ form.add(new TextField<String>("displayName").setEnabled(editDisplayName));
+ form.add(new TextField<String>("emailAddress").setEnabled(editEmailAddress));
form.add(new CheckBox("canAdmin"));
form.add(new CheckBox("excludeFromFederation"));
form.add(repositories);