use of org.wso2.carbon.identity.oauth2.model.OAuth2Parameters in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpointTest method setOAuth2Parameters.
private OAuth2Parameters setOAuth2Parameters(Set<String> scopes, String appName, String responseMode, String redirectUri) {
OAuth2Parameters oAuth2Parameters = new OAuth2Parameters();
oAuth2Parameters.setScopes(scopes);
oAuth2Parameters.setResponseMode(responseMode);
oAuth2Parameters.setRedirectURI(redirectUri);
oAuth2Parameters.setApplicationName(appName);
return oAuth2Parameters;
}
use of org.wso2.carbon.identity.oauth2.model.OAuth2Parameters in project identity-inbound-auth-oauth by wso2-extensions.
the class OAuth2AuthzEndpointTest method testHandleMaxAgeParameter.
@Test(dataProvider = "provideHandleMaxAgeParameterData")
public void testHandleMaxAgeParameter(String value, Boolean state) throws Exception {
Method handleMaxAgeParameter = authzEndpointObject.getClass().getDeclaredMethod("handleMaxAgeParameter", OAuthAuthzRequest.class, OAuth2Parameters.class);
handleMaxAgeParameter.setAccessible(true);
OAuth2Parameters oAuth2Parameters = new OAuth2Parameters();
when(oAuthAuthzRequest.getParam(OAuthConstants.OIDCClaims.MAX_AGE)).thenReturn(value);
try {
handleMaxAgeParameter.invoke(authzEndpointObject, oAuthAuthzRequest, oAuth2Parameters);
} catch (Exception e1) {
assertTrue(state);
}
}
use of org.wso2.carbon.identity.oauth2.model.OAuth2Parameters in project identity-inbound-auth-oauth by wso2-extensions.
the class EndpointUtilTest method provideErrorPageData.
@DataProvider(name = "provideErrorPageData")
public Object[][] provideErrorPageData() {
OAuth2Parameters params1 = new OAuth2Parameters();
OAuth2Parameters params2 = new OAuth2Parameters();
OAuth2Parameters params3 = new OAuth2Parameters();
String state = "active";
String responseType = "dummyResponceType";
String appName = "myApp";
params1.setState(state);
params1.setResponseType(responseType);
params1.setApplicationName(appName);
params1.setRedirectURI("http://localhost:8080/callback");
params2.setState(state);
params2.setResponseType(responseType);
params2.setApplicationName(appName);
params2.setRedirectURI(null);
params3.setState(null);
params3.setResponseType(responseType);
params3.setApplicationName(appName);
params3.setRedirectURI("http://localhost:8080/callback");
return new Object[][] { { true, true, true, params1, "http://localhost:8080/location", false }, { true, false, true, params1, "http://localhost:8080/location", false }, { false, true, true, params1, "http://localhost:8080/location", true }, { false, false, false, params1, ERROR_PAGE_URL, true }, { true, true, true, params3, "http://localhost:8080/location", false } };
}
use of org.wso2.carbon.identity.oauth2.model.OAuth2Parameters in project identity-inbound-auth-oauth by wso2-extensions.
the class EndpointUtilTest method provideErrorRedirectData.
@DataProvider(name = "provideErrorRedirectData")
public Object[][] provideErrorRedirectData() {
OAuth2Parameters params1 = new OAuth2Parameters();
OAuth2Parameters params2 = new OAuth2Parameters();
String state = "active";
String responseType = "dummyResponceType";
String appName = "myApp";
params1.setState(state);
params1.setResponseType(responseType);
params1.setApplicationName(appName);
params1.setRedirectURI("http://localhost:8080/callback");
params2.setState(state);
params2.setResponseType(responseType);
params2.setApplicationName(appName);
params2.setRedirectURI(null);
return new Object[][] { { true, true, params1, null, "http://localhost:8080/location", false }, { true, false, params1, null, "http://localhost:8080/location", false }, { false, true, params1, null, "http://localhost:8080/location", false }, { true, true, params2, null, ERROR_PAGE_URL, false }, { true, true, null, null, ERROR_PAGE_URL, false }, { true, true, params1, new OAuthSystemException(), ERROR_PAGE_URL, false }, { true, true, params1, new OAuthSystemException(), ERROR_PAGE_URL, true } };
}
use of org.wso2.carbon.identity.oauth2.model.OAuth2Parameters in project identity-inbound-auth-oauth by wso2-extensions.
the class EndpointUtil method getAllowedOAuthScopes.
private static List<String> getAllowedOAuthScopes(OAuth2Parameters params) throws OAuthSystemException {
Set<String> allowedScopes = params.getScopes();
List<String> allowedOAuthScopes = new ArrayList<>();
if (CollectionUtils.isNotEmpty(allowedScopes)) {
try {
startTenantFlow(params.getTenantDomain());
/* If DropUnregisteredScopes scopes config is enabled
then any unregistered scopes(excluding internal scopes
and allowed scopes) is be dropped. Therefore they will
not be shown in the user consent screen.*/
if (oauthServerConfiguration.isDropUnregisteredScopes()) {
if (log.isDebugEnabled()) {
log.debug("DropUnregisteredScopes config is enabled. Attempting to drop unregistered scopes.");
}
allowedScopes = dropUnregisteredScopes(params);
}
// Get registered OIDC scopes.
String[] oidcScopes = oAuthAdminService.getScopeNames();
List<String> oidcScopeList = new ArrayList<>(Arrays.asList(oidcScopes));
for (String scope : allowedScopes) {
if (!oidcScopeList.contains(scope)) {
allowedOAuthScopes.add(scope);
}
}
} catch (IdentityOAuthAdminException e) {
throw new OAuthSystemException("Error while retrieving OIDC scopes.", e);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
if (log.isDebugEnabled()) {
log.debug("Allowed OAuth scopes : " + allowedOAuthScopes.stream().collect(Collectors.joining(" ")) + " for client : " + params.getClientId());
}
return allowedOAuthScopes;
}
Aggregations