Package org.wso2.is7.client
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.
-
Field Summary
Fields inherited from class org.wso2.carbon.apimgt.impl.AbstractKeyManager
configuration, tenantDomain -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidattachResourceScopes(org.wso2.carbon.apimgt.api.model.API api, Set<org.wso2.carbon.apimgt.api.model.URITemplate> uriTemplates) protected booleanCopied from AMDefaultKeyManagerImpl.protected booleanCopied from AMDefaultKeyManagerImpl.org.wso2.carbon.apimgt.api.model.OAuthApplicationInfocreateApplication(org.wso2.carbon.apimgt.api.model.OAuthAppRequest oauthAppRequest) voiddeleteApplication(String consumerKey) voiddeleteMappedApplication(String consumerKey) voidvoiddeleteScope(String scopeName) Copied from AMDefaultKeyManagerImpl.voiddetachResourceScopes(org.wso2.carbon.apimgt.api.model.API api, Set<org.wso2.carbon.apimgt.api.model.URITemplate> uriTemplates) org.wso2.carbon.apimgt.api.model.AccessTokenInfogetAccessTokenByConsumerKey(String consumerKey) getActiveTokensByConsumerKey(String consumerKey) Copied from AMDefaultKeyManagerImpl.protected StringgetConfigurationParamValue(String parameter) Copied from AMDefaultKeyManagerImpl.org.wso2.carbon.apimgt.api.model.KeyManagerConfigurationstatic org.apache.http.client.HttpClientgetMutualTLSHttpClient(KeyStore trustStore) org.wso2.carbon.apimgt.api.model.AccessTokenInfogetNewApplicationAccessToken(org.wso2.carbon.apimgt.api.model.AccessTokenRequest tokenRequest) getNewApplicationConsumerSecret(org.wso2.carbon.apimgt.api.model.AccessTokenRequest tokenRequest) getResourceByApiId(String apiId) org.wso2.carbon.apimgt.api.model.ScopegetScopeByName(String name) Copied from AMDefaultKeyManagerImpl.getScopesForAPIS(String apiIdsString) org.wso2.carbon.apimgt.api.model.AccessTokenInfogetTokenMetaData(String accessToken) getType()getUserClaims(String username, Map<String, Object> properties) booleanisScopeExists(String scopeName) Copied from AMDefaultKeyManagerImpl.voidloadConfiguration(org.wso2.carbon.apimgt.api.model.KeyManagerConfiguration configuration) org.wso2.carbon.apimgt.api.model.OAuthApplicationInfomapOAuthApplication(org.wso2.carbon.apimgt.api.model.OAuthAppRequest appInfoRequest) Copied from AMDefaultKeyManagerImpl.booleanregisterNewResource(org.wso2.carbon.apimgt.api.model.API api, Map resourceAttributes) voidregisterScope(org.wso2.carbon.apimgt.api.model.Scope scope) Copied from AMDefaultKeyManagerImpl.org.wso2.carbon.apimgt.api.model.OAuthApplicationInforetrieveApplication(String consumerKey) voidrevokeOneTimeToken(String token, String consumerKey) org.wso2.carbon.apimgt.api.model.OAuthApplicationInfoupdateApplication(org.wso2.carbon.apimgt.api.model.OAuthAppRequest appInfoDTO) org.wso2.carbon.apimgt.api.model.OAuthApplicationInfoupdateApplicationOwner(org.wso2.carbon.apimgt.api.model.OAuthAppRequest appInfoDTO, String owner) booleanupdateRegisteredResource(org.wso2.carbon.apimgt.api.model.API api, Map resourceAttributes) voidupdateResourceScopes(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) Copied from AMDefaultKeyManagerImpl.voidupdateScope(org.wso2.carbon.apimgt.api.model.Scope scope) Copied from AMDefaultKeyManagerImpl.protected voidvalidateOAuthAppCreationProperties(org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo oAuthApplicationInfo) voidvalidateScopes(Set<org.wso2.carbon.apimgt.api.model.Scope> scopes) Copied from AMDefaultKeyManagerImpl.Methods inherited from class org.wso2.carbon.apimgt.impl.AbstractKeyManager
buildAccessTokenRequestFromJSON, buildAccessTokenRequestFromOAuthApp, buildFromJSON, canHandleToken, handleException, setTenantDomainMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.wso2.carbon.apimgt.api.model.KeyManager
buildFromJSON
-
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:
registerNewResourcein interfaceorg.wso2.carbon.apimgt.api.model.KeyManager- Overrides:
registerNewResourcein classorg.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.APIManagementExceptionCopied 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- APIoldLocalScopeKeys- Old local scopes of the API before update (excluding the versioned local scopesnewLocalScopes- New local scopes of the API after updateoldURITemplates- Old URI templates of the API before updatenewURITemplates- 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
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
-
getConfigurationParamValue
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
-
validateOAuthAppCreationProperties
protected void validateOAuthAppCreationProperties(org.wso2.carbon.apimgt.api.model.OAuthApplicationInfo oAuthApplicationInfo) throws org.wso2.carbon.apimgt.api.APIManagementException - Overrides:
validateOAuthAppCreationPropertiesin classorg.wso2.carbon.apimgt.impl.AbstractKeyManager- Throws:
org.wso2.carbon.apimgt.api.APIManagementException
-