aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java
diff options
context:
space:
mode:
authorSulabh Upadhyay <suupadhy@microsoft.com>2015-09-22 15:58:26 +0530
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-09-29 23:03:35 +0200
commit271e2cde317eeee0b5a07bc74394958dc4f8370d (patch)
tree0071680f88e73a51210c841c25da32deac448425 /sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java
parentc769d5e095106fe0e922255d192c562ffef2f918 (diff)
downloadsonarqube-271e2cde317eeee0b5a07bc74394958dc4f8370d.tar.gz
sonarqube-271e2cde317eeee0b5a07bc74394958dc4f8370d.zip
SONAR-6856 : Add a new API ExternalGroupsProvider.doGetGroups(Context context) to allow plugins to pass groups information to SonarQube
Addition of one more api in ExternalGroupsProvider which will pass Context as parameter . doGetGroups(String username) is marked as deprecated Default implementation is provided in both version of doGetGroups so that authentication plugin relying on previous version ( <5.2) and current version 5.2 do not face compact issue on the SonarQube server 5.2 Testing: 1. Unit test for ExternalGroupsProvider is added. 2. Testing of authentication plugin (e.g. LDAP) targeting SonarQube Plugin apis version < 5.2 working with SonarQube server 5.2 3. Testing of LDAP plugin with SSO changes which are tareting SonarQube plugin api version 5.2 working with SonarQube server 5.2
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java b/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java
index 77341948e04..3a0134b4ad7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/security/ExternalGroupsProvider.java
@@ -20,19 +20,52 @@
package org.sonar.api.security;
import java.util.Collection;
+import javax.servlet.http.HttpServletRequest;
/**
* Note that prefix "do" for names of methods is reserved for future enhancements, thus should not be used in subclasses.
*
- * @since 2.14
* @see SecurityRealm
+ * @since 2.14
*/
public abstract class ExternalGroupsProvider {
/**
* @return list of groups associated with specified user, or null if such user doesn't exist
* @throws RuntimeException in case of unexpected error such as connection failure
+ * @deprecated replaced by {@link #doGetGroups(org.sonar.api.security.ExternalGroupsProvider.Context)} since v. 5.2
+ */
+ @Deprecated
+ public Collection<String> doGetGroups(String username) {
+ return null;
+ }
+
+ /**
+ * Override this method in order to load user group information.
+ *
+ * @return list of groups associated with specified user, or null if such user doesn't exist
+ * @throws RuntimeException in case of unexpected error such as connection failure
+ * @since 5.2
*/
- public abstract Collection<String> doGetGroups(String username);
+ public Collection<String> doGetGroups(Context context) {
+ return doGetGroups(context.getUsername());
+ }
+
+ public static final class Context {
+ private String username;
+ private HttpServletRequest request;
+
+ public Context(String username, HttpServletRequest request) {
+ this.username = username;
+ this.request = request;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+ public HttpServletRequest getRequest() {
+ return request;
+ }
+ }
}