Merge branch 'master' into 'master'

Fixing null pointer during APIM scope validation

See merge request entgra/carbon-device-mgt!579
revert-70ac1926
Ruwan Yatawara 4 years ago
commit 2942091150

@ -17,6 +17,7 @@
*/ */
package org.wso2.carbon.device.mgt.oauth.extensions.handlers; package org.wso2.carbon.device.mgt.oauth.extensions.handlers;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder; import org.wso2.carbon.device.mgt.oauth.extensions.internal.OAuthExtensionsDataHolder;
@ -26,6 +27,7 @@ import org.wso2.carbon.identity.oauth.cache.OAuthCacheKey;
import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception;
import org.wso2.carbon.identity.oauth2.dao.TokenManagementDAO; import org.wso2.carbon.identity.oauth2.dao.TokenManagementDAO;
import org.wso2.carbon.identity.oauth2.dao.TokenManagementDAOImpl; import org.wso2.carbon.identity.oauth2.dao.TokenManagementDAOImpl;
import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO;
import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; import org.wso2.carbon.identity.oauth2.model.AccessTokenDO;
import org.wso2.carbon.identity.oauth2.model.ResourceScopeCacheEntry; import org.wso2.carbon.identity.oauth2.model.ResourceScopeCacheEntry;
import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator;
@ -109,7 +111,10 @@ public class ScopeValidationHandler extends OAuth2ScopeValidator {
if (!cacheHit) { if (!cacheHit) {
TokenManagementDAO tokenMgtDAO = new TokenManagementDAOImpl(); TokenManagementDAO tokenMgtDAO = new TokenManagementDAOImpl();
try { try {
resourceScope = tokenMgtDAO.findTenantAndScopeOfResource(resource).getLeft(); Pair<String, Integer> scopeReference = tokenMgtDAO.findTenantAndScopeOfResource(resource);
if(scopeReference!=null) {
resourceScope = scopeReference.getLeft();
}
} catch (IdentityOAuth2Exception e) { } catch (IdentityOAuth2Exception e) {
log.error("Error occurred while retrieving scope for resource '" + resource + "'"); log.error("Error occurred while retrieving scope for resource '" + resource + "'");
} }

Loading…
Cancel
Save