steveloughran commented on a change in pull request #1690: HADOOP-16680. Add MicrosoftGraphGroupsMapping GroupMappingServiceProvider URL: https://github.com/apache/hadoop/pull/1690#discussion_r342488025
########## File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/MicrosoftGraphGroupsMapping.java ########## @@ -0,0 +1,314 @@ +package org.apache.hadoop.security; + +import com.google.common.annotations.VisibleForTesting; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.microsoft.graph.core.ClientException; +import com.microsoft.graph.core.DefaultConnectionConfig; +import com.microsoft.graph.logger.ILogger; +import com.microsoft.graph.logger.LoggerLevel; +import com.microsoft.graph.models.extensions.DirectoryObject; +import com.microsoft.graph.models.extensions.IGraphServiceClient; +import com.microsoft.graph.requests.extensions.GraphServiceClient; +import com.microsoft.graph.requests.extensions.IDirectoryObjectCollectionWithReferencesPage; +import com.microsoft.graph.requests.extensions.IDirectoryObjectCollectionWithReferencesRequestBuilder; +import org.apache.hadoop.conf.Configurable; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.security.oauth2.AccessTokenProvider; +import org.apache.hadoop.security.oauth2.ClientCredsTokenProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * An implementation of GroupMappingServiceProvider that uses the + * Microsoft Graph API (https://developer.microsoft.com/en-us/graph) + * to retrieve user's groups. + * + * It does this by first requesting an Oauth2 token using the + * credentials of the application registered in Azure. + * This application has to have the Directory.Read.All application + * permission for this to work. + * + * After acquiring the token, it queries the Graph API using this + * token to retrieve a list of groups of the requested user. + * + */ +public class MicrosoftGraphGroupsMapping + implements GroupMappingServiceProvider, Configurable { + + private static final Logger LOG = LoggerFactory.getLogger( + MicrosoftGraphGroupsMapping.class); + + public static final String MS_GRAPH_GROUPS_OAUTH2_URL_KEY = Review comment: javadocs of all the constants ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
