diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java index 58c975bbec9..f4745548dd5 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/ExtendedJDBCScopeValidator.java @@ -30,6 +30,8 @@ import org.wso2.carbon.identity.oauth.cache.OAuthCache; import org.wso2.carbon.identity.oauth.cache.OAuthCacheKey; import org.wso2.carbon.identity.oauth.config.OAuthServerConfiguration; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.dao.OAuthScopeDAO; +import org.wso2.carbon.identity.oauth2.dao.OAuthScopeDAOImpl; import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO; import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; import org.wso2.carbon.identity.oauth2.model.ResourceScopeCacheEntry; @@ -62,7 +64,8 @@ public class ExtendedJDBCScopeValidator extends OAuth2ScopeValidator { } String resourceScope = null; - TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); +// TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); + OAuthScopeDAOImpl scopeDAO = new OAuthScopeDAOImpl(); boolean cacheHit = false; // Check the cache, if caching is enabled. @@ -79,7 +82,7 @@ public class ExtendedJDBCScopeValidator extends OAuth2ScopeValidator { } if (!cacheHit) { - resourceScope = tokenMgtDAO.findScopeOfResource(resource); + resourceScope = scopeDAO.findScopeOfResource(resource); if (OAuthServerConfiguration.getInstance().isCacheEnabled()) { OAuthCache oauthCache = OAuthCache.getInstance(); @@ -112,7 +115,7 @@ public class ExtendedJDBCScopeValidator extends OAuth2ScopeValidator { try { //Get the permissions associated with the scope, if any - Set permissionsOfScope = tokenMgtDAO.getRolesOfScopeByScopeKey(resourceScope); + Set permissionsOfScope = scopeDAO.getBindingsOfScopeByScopeName(resourceScope); //If the scope doesn't have any permissions associated with it. if(permissionsOfScope == null || permissionsOfScope.isEmpty()){ diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java index 5be19a5a0c8..ef720b15adb 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java @@ -26,6 +26,9 @@ import org.wso2.carbon.device.mgt.oauth.extensions.internal.OAuthExtensionsDataH import org.wso2.carbon.identity.application.common.model.User; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.dao.OAuthScopeDAO; +import org.wso2.carbon.identity.oauth2.dao.OAuthScopeDAOImpl; +import org.wso2.carbon.identity.oauth2.dao.OAuthTokenPersistenceFactory; import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO; import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; @@ -56,7 +59,11 @@ public class PermissionBasedScopeValidator extends OAuth2ScopeValidator { return true; } - TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); + OAuthScopeDAO pp = OAuthTokenPersistenceFactory.getInstance().getOAuthScopeDAO(); + int tid = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + +// TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); + OAuthScopeDAOImpl nn = new OAuthScopeDAOImpl(); List scopeList = new ArrayList<>(Arrays.asList(scopes)); @@ -71,7 +78,7 @@ public class PermissionBasedScopeValidator extends OAuth2ScopeValidator { try { //Get the permissions associated with the scope, if any - Set permissionsOfScope = tokenMgtDAO.getRolesOfScopeByScopeKey(resourceScope); + Set permissionsOfScope = pp.getBindingsOfScopeByScopeName(resourceScope, tid); //If the scope doesn't have any permissions associated with it. if(permissionsOfScope == null || permissionsOfScope.isEmpty()){ diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java index 593d9d0c89d..6fd79eac175 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/RoleBasedScopeValidator.java @@ -28,6 +28,7 @@ import org.wso2.carbon.identity.base.IdentityConstants; import org.wso2.carbon.identity.core.util.IdentityTenantUtil; import org.wso2.carbon.identity.core.util.IdentityUtil; import org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception; +import org.wso2.carbon.identity.oauth2.dao.OAuthScopeDAOImpl; import org.wso2.carbon.identity.oauth2.dao.TokenMgtDAO; import org.wso2.carbon.identity.oauth2.model.AccessTokenDO; import org.wso2.carbon.identity.oauth2.validators.OAuth2ScopeValidator; @@ -61,7 +62,8 @@ public class RoleBasedScopeValidator extends OAuth2ScopeValidator { return true; } - TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); +// TokenMgtDAO tokenMgtDAO = new TokenMgtDAO(); + OAuthScopeDAOImpl scopeDAO = new OAuthScopeDAOImpl(); List scopeList = new ArrayList<>(Arrays.asList(scopes)); @@ -76,7 +78,7 @@ public class RoleBasedScopeValidator extends OAuth2ScopeValidator { try { //Get the roles associated with the scope, if any - Set rolesOfScope = tokenMgtDAO.getRolesOfScopeByScopeKey(resourceScope); + Set rolesOfScope = scopeDAO.getBindingsOfScopeByScopeName(resourceScope); //If the scope doesn't have any roles associated with it. if(rolesOfScope == null || rolesOfScope.isEmpty()){ diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml index 18fefe60f52..0aba564bc05 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/pom.xml @@ -184,6 +184,12 @@ org.wso2.carbon.identity.framework org.wso2.carbon.identity.core + + + org.slf4j + slf4j-api + + org.wso2.carbon.identity.inbound.auth.oauth2 @@ -217,10 +223,6 @@ commons-httpclient.wso2 commons-httpclient - - org.testng - testng - commons-pool.wso2 commons-pool diff --git a/pom.xml b/pom.xml index 0e7e03645c2..dc65eafcdd0 100644 --- a/pom.xml +++ b/pom.xml @@ -401,6 +401,10 @@ org.wso2.securevault org.wso2.securevault + + org.mockito + mockito-core + @@ -884,6 +888,16 @@ org.wso2.carbon.identity.framework org.wso2.carbon.identity.core ${carbon.identity.framework.version} + + + org.powermock + powermock-api-mockito + + + org.powermock + powermock-module-testng + + org.wso2.carbon.identity.inbound.auth.oauth2 @@ -904,6 +918,24 @@ org.wso2.carbon.identity.inbound.auth.oauth2 org.wso2.carbon.identity.oauth ${identity.inbound.auth.oauth.version} + + + org.apache.tomcat + tomcat-coyote + + + org.wso2.carbon.consent.mgt + org.wso2.carbon.consent.mgt.core + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.event + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.testutil + + org.wso2.carbon.identity.framework @@ -914,11 +946,27 @@ org.wso2.carbon.identity.framework org.wso2.carbon.user.mgt ${carbon.identity.framework.version} + + + org.slf4j + log4j-over-slf4j + + org.wso2.carbon.identity.framework org.wso2.carbon.identity.base ${carbon.identity.framework.version} + + + org.powermock + powermock-api-mockito + + + org.powermock + powermock-module-testng + + @@ -1293,6 +1341,10 @@ org.wso2.carbon.identity org.wso2.carbon.user.mgt + + org.powermock + powermock-api-mockito + @@ -1808,7 +1860,7 @@ 2.2.1 6.1.1 - 4.4.17 + 4.4.24 4.4.9 [4.4.0, 5.0.0) 1.5.4 @@ -1849,13 +1901,13 @@ 7.0.34.wso2v2 - 4.7.2 + 4.7.10 - 5.7.0 + 5.11.120 [5.0.0, 6.0.0) - 5.3.1 - 5.3.0 + 5.6.51 + 5.4.4 1.0.2 [1.0.2, 2.0.0) @@ -1864,10 +1916,10 @@ [5.1.0, 6.0.0) - 4.6.1 + 4.6.8 - 4.7.8 + 4.7.23 1.2.11-wso2v10 @@ -1878,7 +1930,7 @@ 3.0.244-SNAPSHOT - 4.4.8 + 4.6.0 1.4.0.wso2v1 [1.4.0,2.0.0) 2.4.0.wso2v1 @@ -1886,7 +1938,7 @@ [2.6.0,3.0.0) - 6.1.109 + 6.2.146 (6.0.0,7.0.0] @@ -1897,7 +1949,7 @@ 2.1.10 - 4.6.8 + 4.6.28 4.6.8 [4.4.8, 5.0.0) @@ -1985,7 +2037,7 @@ [1.0.0, 1.1.0) - 1.6.1 + 1.7.0 2.3.2