Class AzureAdRestEntityMapper

java.lang.Object
com.atlassian.crowd.directory.rest.mapper.AzureAdRestEntityMapper

public class AzureAdRestEntityMapper extends Object
Maps REST entities returned from Microsoft Graph to Crowd entities and vice versa
  • Constructor Details

    • AzureAdRestEntityMapper

      public AzureAdRestEntityMapper()
  • Method Details

    • mapUsers

      public <T> List<T> mapUsers(GraphUsersList graphUsersList, Class<T> returnType, long directoryId, String alternativeUsernameAttribute)
      Maps a users response from Microsoft Entra ID to Crowd users.
      Parameters:
      graphUsersList - the response from Microsoft Entra ID
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name
      Returns:
      a list of mapped Crowd users
    • mapUsers

      public <T> List<T> mapUsers(Collection<GraphUser> graphUsersList, Class<T> returnType, long directoryId, String alternativeUsernameAttribute)
      Maps a collection of Microsoft Entra ID users to Crowd users.
      Parameters:
      graphUsersList - the users to map
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name
      Returns:
      a list of mapped Crowd users
    • mapDeltaQueryUsers

      public DeltaQueryResult<UserWithAttributes> mapDeltaQueryUsers(GraphDeltaQueryResult<GraphDeltaQueryUser> graphUsersList, long directoryId, String alternativeUsernameAttribute)
      Maps a delta query result for users to a result suitable for incremental synchronisation.
      Parameters:
      graphUsersList - the users to map
      directoryId - the id of the Crowd directory
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name
      Returns:
      a list of mapped new users, ids of deleted users and a token suitable for change tracking
    • mapUser

      public <T> T mapUser(GraphUser graphUser, Class<T> returnType, long directoryId, String alternativeUsernameAttribute)
      Maps a user obtained from the Microsoft Entra ID users endpoint to a Crowd object
      Parameters:
      graphUser - the user obtained from Microsoft Entra ID
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name
      Returns:
      the mapped Crowd user
    • mapGroups

      public <T> List<T> mapGroups(GraphGroupList graphGroupList, Class<T> returnType, long directoryId)
      Maps a groups response from Microsoft Entra ID to Crowd groups.
      Parameters:
      graphGroupList - the response from Microsoft Entra ID
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      Returns:
      a list of mapped Crowd groups
    • mapGroups

      public <T> List<T> mapGroups(Collection<GraphGroup> graphGroups, Class<T> returnType, long directoryId)
      Maps a collection of Microsoft Entra ID groups to Crowd groups.
      Parameters:
      graphGroups - the groups to map
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      Returns:
      a list of mapped Crowd groups
    • mapDeltaQueryGroups

      public DeltaQueryResult<GroupWithMembershipChanges> mapDeltaQueryGroups(GraphDeltaQueryResult<GraphDeltaQueryGroup> graphGroups, long directoryId)
      Maps a delta query result for groups to a result suitable for incremental synchronisation.
      Parameters:
      graphGroups - the groups to map
      directoryId - the id of the Crowd directory
      Returns:
      a list of mapped new groups, ids of deleted groups and a token suitable for change tracking
    • mapDirectoryObjects

      public <T> List<T> mapDirectoryObjects(GraphDirectoryObjectList directoryObjectList, Class<T> returnType, long directoryId, String alternativeUsernameAttribute)
      Maps a directory objects response from Microsoft Entra ID. The objects in the response should be of one type (groups or users)
      Parameters:
      directoryObjectList - the directory objects response from Microsoft Entra ID
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name
      Returns:
      a list of mapped Crowd objects
    • mapDirectoryObjects

      public <T> List<T> mapDirectoryObjects(Collection<DirectoryObject> directoryObjects, Class<T> returnType, long directoryId, String alternativeUsernameAttribute)
      Maps a collection of directory objects to Crowd objects. The objects should be filtered by type (groups or users)
      Parameters:
      directoryObjects - the directory objects to map
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name
      Returns:
      a list of mapped Crowd objects
    • mapGroup

      public <T> T mapGroup(GraphGroup graphGroup, Class<T> returnType, long directoryId)
      Maps a group obtained from the Microsoft Entra ID groups endpoint to a Crowd object
      Parameters:
      graphGroup - the group obtained from Microsoft Entra ID
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      Returns:
      the mapped Crowd group
    • mapDeltaQueryGroup

      public GroupWithMembershipChanges mapDeltaQueryGroup(GraphDeltaQueryGroup graphGroup, long directoryId)
      Maps a group obtained from the Microsoft Entra ID groups endpoint to a Crowd object
      Parameters:
      graphGroup - the group obtained from Microsoft Entra ID
      directoryId - the id of the Crowd directory
      Returns:
      the mapped Crowd group
    • mapDirectoryObject

      public <T> T mapDirectoryObject(DirectoryObject directoryObject, Class<T> returnType, long directoryId, String alternativeUsernameAttribute)
      Maps an AzureAD directory object to a Crowd object. The directory object must be of a concrete type
      Parameters:
      directoryObject - the result from Microsoft Entra ID
      returnType - the desired return type
      directoryId - the id of the Crowd directory
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name
      Returns:
      the mapped Crowd object
      Throws:
      IllegalArgumentException - when the directoryObject is a generic DirectoryObject instance
    • getUsername

      public String getUsername(GraphUser user, String alternativeUsernameAttribute)
      Returns name of the user.
      Parameters:
      user - GraphUser returned by Azure
      alternativeUsernameAttribute - name of the attribute that should be mapped to user name