use of org.wso2.carbon.identity.core.URLBuilderException in project identity-inbound-auth-oauth by wso2-extensions.
the class UserAuthenticationEndpoint method setCallbackURI.
/**
* This method is used to set the callback uri. If there is no value it will set a default value.
*
* @param clientId Consumer key of the application.
* @throws IdentityOAuth2Exception
*/
private void setCallbackURI(String clientId) throws IdentityOAuth2Exception {
try {
OAuthAppDO oAuthAppDO;
oAuthAppDO = OAuth2Util.getAppInformationByClientId(clientId);
String redirectURI = oAuthAppDO.getCallbackUrl();
if (StringUtils.isBlank(redirectURI)) {
String appName = oAuthAppDO.getApplicationName();
redirectURI = getRedirectionURI(appName);
deviceAuthService.setCallbackUri(clientId, redirectURI);
AppInfoCache.getInstance().clearCacheEntry(clientId);
}
deviceFlowDO.setCallbackUri(redirectURI);
} catch (InvalidOAuthClientException | URISyntaxException | URLBuilderException | IdentityOAuth2Exception e) {
String errorMsg = String.format("Error when getting app details for client id : %s", clientId);
throw new IdentityOAuth2Exception(errorMsg, e);
}
}
use of org.wso2.carbon.identity.core.URLBuilderException in project identity-inbound-auth-oauth by wso2-extensions.
the class EndpointUtilTest method mockServiceURLBuilder.
private void mockServiceURLBuilder(String url) throws URLBuilderException {
mockStatic(ServiceURLBuilder.class);
ServiceURLBuilder serviceURLBuilder = mock(ServiceURLBuilder.class);
when(ServiceURLBuilder.create()).thenReturn(serviceURLBuilder);
when(serviceURLBuilder.addPath(any())).thenReturn(serviceURLBuilder);
ServiceURL serviceURL = mock(ServiceURL.class);
when(serviceURL.getAbsolutePublicURL()).thenReturn(url);
when(serviceURLBuilder.build()).thenReturn(serviceURL);
}
Aggregations