From dc5cb124d46e90c3823f47573ca25c808507d14c Mon Sep 17 00:00:00 2001 From: Sulabh Upadhyay Date: Thu, 24 Sep 2015 17:53:26 +0530 Subject: SONAR-6867: Add a new APIs UserDetails.getUserId()/setUserId(String userId) to allow plugins to pass userId information to SonarQube setUserId(String userId) and getUserId () are added to UserDetails. Testing 1. Unit test for UserDetails 2. Verification of following scenarios : a. Plugin (e.g. LDAP) is dependent on older sonarqube plugins apis ( < 5.2) and the plugin is being used in SonarQube 5.2 server b. Plugin is dependent on SonarQube 5.2 plugin apis and userId is not being populated in UserDetails along with userName and Email . c. Plugin is dependent on SonarQube 5.2 plugin apis and userId is also being populated by the plugin in UserDetails along with userName and Email. --- .../java/org/sonar/api/security/UserDetails.java | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'sonar-plugin-api/src/main') diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java b/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java index 115915e8047..705d2bcf649 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/security/UserDetails.java @@ -24,13 +24,14 @@ import com.google.common.base.Objects; /** * This class is not intended to be subclassed by clients. * - * @since 2.14 * @see ExternalUsersProvider + * @since 2.14 */ public final class UserDetails { private String name = ""; private String email = ""; + private String userId = ""; public UserDetails() { } @@ -51,11 +52,26 @@ public final class UserDetails { return name; } + /** + * @since 5.2 + */ + public void setUserId(String userId) { + this.userId = userId; + } + + /** + * @since 5.2 + */ + public String getUserId() { + return userId; + } + @Override public String toString() { return Objects.toStringHelper(this) - .add("name", name) - .add("email", email) - .toString(); + .add("name", name) + .add("email", email) + .add("userId", userId) + .toString(); } } -- cgit v1.2.3