Class WSO2IS7KeyManager

java.lang.Object
org.wso2.carbon.apimgt.impl.AbstractKeyManager
org.wso2.is7.client.WSO2IS7KeyManager
All Implemented Interfaces:
org.wso2.carbon.apimgt.api.model.KeyManager

public class WSO2IS7KeyManager extends org.wso2.carbon.apimgt.impl.AbstractKeyManager
This class provides the implementation to use WSO2 Identity Server 7 for managing OAuth clients and Tokens needed by WSO2 API Manager. NOTE: Some of the methods (stated in comments above the respective method definitions) are copied from https://raw.githubusercontent.com/wso2/carbon-apimgt/v9.29.35/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AMDefaultKeyManagerImpl.java to avoid being dependent on carbon-apimgt.
  • Constructor Details

    • WSO2IS7KeyManager

      public WSO2IS7KeyManager()
  • Method Details

    • createApplication

      public org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo createApplication(org.wso2.carbon.apimgt.api.model.OAuthAppRequest oauthAppRequest) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • updateApplication

      public org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo updateApplication(org.wso2.carbon.apimgt.api.model.OAuthAppRequest appInfoDTO) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • updateApplicationOwner

      public org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo updateApplicationOwner(org.wso2.carbon.apimgt.api.model.OAuthAppRequest appInfoDTO, String owner) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • deleteApplication

      public void deleteApplication(String consumerKey) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • retrieveApplication

      public org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo retrieveApplication(String consumerKey) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getNewApplicationAccessToken

      public org.wso2.carbon.apimgt.api.model.AccessTokenInfo getNewApplicationAccessToken(org.wso2.carbon.apimgt.api.model.AccessTokenRequest tokenRequest) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getNewApplicationConsumerSecret

      public String getNewApplicationConsumerSecret(org.wso2.carbon.apimgt.api.model.AccessTokenRequest tokenRequest) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getTokenMetaData

      public org.wso2.carbon.apimgt.api.model.AccessTokenInfo getTokenMetaData(String accessToken) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getKeyManagerConfiguration

      public org.wso2.carbon.apimgt.api.model.KeyManagerConfiguration getKeyManagerConfiguration() throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • mapOAuthApplication

      public org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo mapOAuthApplication(org.wso2.carbon.apimgt.api.model.OAuthAppRequest appInfoRequest) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. WSO2IS7ClientInfo is used instead of ClientInfo. This method will create a new record at CLIENT_INFO table by given OauthAppRequest.
      Parameters:
      appInfoRequest - oAuth application properties will contain in this object
      Returns:
      OAuthApplicationInfo with created oAuth application details.
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - Failure to obtain application information, or mismatching consumer key and secret.
    • loadConfiguration

      public void loadConfiguration(org.wso2.carbon.apimgt.api.model.KeyManagerConfiguration configuration) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getMutualTLSHttpClient

      public static org.apache.http.client.HttpClient getMutualTLSHttpClient(KeyStore trustStore) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • registerNewResource

      public boolean registerNewResource(org.wso2.carbon.apimgt.api.model.API api, Map resourceAttributes) throws org.wso2.carbon.apimgt.api.APIManagementException
      Specified by:
      registerNewResource in interface org.wso2.carbon.apimgt.api.model.KeyManager
      Overrides:
      registerNewResource in class org.wso2.carbon.apimgt.impl.AbstractKeyManager
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getResourceByApiId

      public Map getResourceByApiId(String apiId) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • updateRegisteredResource

      public boolean updateRegisteredResource(org.wso2.carbon.apimgt.api.model.API api, Map resourceAttributes) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • deleteRegisteredResourceByAPIId

      public void deleteRegisteredResourceByAPIId(String apiID) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • deleteMappedApplication

      public void deleteMappedApplication(String consumerKey) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getActiveTokensByConsumerKey

      public Set<String> getActiveTokensByConsumerKey(String consumerKey) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getAccessTokenByConsumerKey

      public org.wso2.carbon.apimgt.api.model.AccessTokenInfo getAccessTokenByConsumerKey(String consumerKey) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • getScopesForAPIS

      public Map<String,Set<org.wso2.carbon.apimgt.api.model.Scope>> getScopesForAPIS(String apiIdsString) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • registerScope

      public void registerScope(org.wso2.carbon.apimgt.api.model.Scope scope) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to register a Scope in the authorization server.
      Parameters:
      scope - Scope to register
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if there is an error while registering a new scope.
    • getScopeByName

      public org.wso2.carbon.apimgt.api.model.Scope getScopeByName(String name) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to retrieve details of a Scope in the authorization server.
      Parameters:
      name - Scope Name to retrieve
      Returns:
      Scope object
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if an error while retrieving scope
    • getAllScopes

      public Map<String,org.wso2.carbon.apimgt.api.model.Scope> getAllScopes() throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to retrieve all the scopes available in the authorization server for the given tenant domain.
      Returns:
      Mapping of Scope object to scope key
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if an error occurs while getting scopes list
    • attachResourceScopes

      public void attachResourceScopes(org.wso2.carbon.apimgt.api.model.API api, Set<org.wso2.carbon.apimgt.api.model.URITemplate> uriTemplates) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • updateResourceScopes

      public void updateResourceScopes(org.wso2.carbon.apimgt.api.model.API api, Set<String> oldLocalScopeKeys, Set<org.wso2.carbon.apimgt.api.model.Scope> newLocalScopes, Set<org.wso2.carbon.apimgt.api.model.URITemplate> oldURITemplates, Set<org.wso2.carbon.apimgt.api.model.URITemplate> newURITemplates) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to update the local scopes and resource to scope attachments of an API in the authorization server.
      Parameters:
      api - API
      oldLocalScopeKeys - Old local scopes of the API before update (excluding the versioned local scopes
      newLocalScopes - New local scopes of the API after update
      oldURITemplates - Old URI templates of the API before update
      newURITemplates - New URI templates of the API after update
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if fails to update resources scopes
    • detachResourceScopes

      public void detachResourceScopes(org.wso2.carbon.apimgt.api.model.API api, Set<org.wso2.carbon.apimgt.api.model.URITemplate> uriTemplates) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • deleteScope

      public void deleteScope(String scopeName) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to delete a Scope in the authorization server.
      Parameters:
      scopeName - Scope name
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if an error occurs while deleting the scope
    • updateScope

      public void updateScope(org.wso2.carbon.apimgt.api.model.Scope scope) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to update a Scope in the authorization server.
      Parameters:
      scope - Scope object
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if an error occurs while updating the scope
    • isScopeExists

      public boolean isScopeExists(String scopeName) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to check whether the a Scope exists for the given scope name in the authorization server.
      Parameters:
      scopeName - Scope Name
      Returns:
      whether scope exists or not
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if an error occurs while checking the existence of the scope
    • validateScopes

      public void validateScopes(Set<org.wso2.carbon.apimgt.api.model.Scope> scopes) throws org.wso2.carbon.apimgt.api.APIManagementException
      Copied from AMDefaultKeyManagerImpl. This method will be used to validate the scope set provided and populate the additional parameters (description and bindings) for each Scope object.
      Parameters:
      scopes - Scope set to validate
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException - if an error occurs while validating and populating
    • getType

      public String getType()
    • getConfigurationParamValue

      protected String getConfigurationParamValue(String parameter)
      Copied from AMDefaultKeyManagerImpl. Return the value of the provided configuration parameter.
      Parameters:
      parameter - Parameter name
      Returns:
      Parameter value
    • checkAccessTokenPartitioningEnabled

      protected boolean checkAccessTokenPartitioningEnabled()
      Copied from AMDefaultKeyManagerImpl. Check whether Token partitioning is enabled.
      Returns:
      true/false
    • checkUserNameAssertionEnabled

      protected boolean checkUserNameAssertionEnabled()
      Copied from AMDefaultKeyManagerImpl. Check whether user name assertion is enabled.
      Returns:
      true/false
    • getUserClaims

      public Map<String,String> getUserClaims(String username, Map<String,Object> properties) throws org.wso2.carbon.apimgt.api.APIManagementException
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException
    • revokeOneTimeToken

      public void revokeOneTimeToken(String token, String consumerKey)
    • validateOAuthAppCreationProperties

      protected void validateOAuthAppCreationProperties(org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo oAuthApplicationInfo) throws org.wso2.carbon.apimgt.api.APIManagementException
      Overrides:
      validateOAuthAppCreationProperties in class org.wso2.carbon.apimgt.impl.AbstractKeyManager
      Throws:
      org.wso2.carbon.apimgt.api.APIManagementException