use of org.wso2.carbon.identity.core.ServiceURL in project carbon-mediation by wso2.
the class Utils method getTenantAxisService.
/**
* Get the details of a deployed webapp for tenants
*
* @param serviceURL URI path
* @return meta data for webapp
*/
private static AxisService getTenantAxisService(String tenant, String serviceURL) throws AxisFault {
ConfigurationContextService contextService = IntegratorComponent.getContextService();
ConfigurationContext configContext;
ConfigurationContext tenantContext;
if (null != contextService) {
// Getting server's configContext instance
configContext = contextService.getServerConfigContext();
String[] urlparts = serviceURL.split("/");
// urlpart[0] is tenant domain
tenantContext = TenantAxisUtils.getTenantConfigurationContext(tenant, configContext);
AxisService tenantAxisService = tenantContext.getAxisConfiguration().getService(urlparts[1]);
if (tenantAxisService == null) {
AxisServiceGroup axisServiceGroup = tenantContext.getAxisConfiguration().getServiceGroup(urlparts[1]);
if (axisServiceGroup != null) {
return axisServiceGroup.getService(urlparts[2]);
} else {
// for dss samples
return tenantContext.getAxisConfiguration().getService(urlparts[2]);
}
} else {
return tenantAxisService;
}
}
return null;
}
use of org.wso2.carbon.identity.core.ServiceURL in project carbon-identity-framework by wso2.
the class CallBackValidator method isValidCallbackURL.
/**
* This method is to validate the callback URL in the request with the configured one.
*
* @param callbackURL CallbackURL Passed in the request.
* @param tenantDomain TenantDomain of the user.
* @return The status of the validation.
* @throws IdentityRecoveryException IdentityRecoveryException.
*/
public boolean isValidCallbackURL(String callbackURL, String tenantDomain) throws IdentityRecoveryException {
if (StringUtils.isBlank(tenantDomain)) {
tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
if (log.isDebugEnabled()) {
log.debug("Tenant domain is considered as super tenant domain: " + tenantDomain);
}
}
IdentityProvider residentIdP;
// Build the service URL of idp management admin service
StringBuilder builder = new StringBuilder();
String serviceURL = builder.append(IdentityManagementServiceUtil.getInstance().getServiceContextURL()).append(IdentityManagementEndpointConstants.ServiceEndpoints.IDENTITY_PROVIDER_MANAGEMENT_SERVICE).toString().replaceAll("(?<!(http:|https:))//", "/");
try {
IdentityProviderMgtServiceStub idPMgtStub = new IdentityProviderMgtServiceStub(serviceURL);
ServiceClient idpClient = idPMgtStub._getServiceClient();
IdentityManagementEndpointUtil.authenticate(idpClient);
residentIdP = idPMgtStub.getResidentIdP();
} catch (AxisFault axisFault) {
throw new IdentityRecoveryException("Error while instantiating IdentityProviderMgtServiceStub", axisFault);
} catch (Exception e) {
throw new IdentityRecoveryException("Error occurred when getting residentIDP configurations.", e);
}
IdentityProviderProperty[] idpProperties = null;
if (residentIdP != null) {
idpProperties = residentIdP.getIdpProperties();
} else {
if (log.isDebugEnabled()) {
log.debug("Resident identity provider is not found for the tenant domain: " + tenantDomain);
}
}
String callbackRegex = null;
if (idpProperties != null) {
for (IdentityProviderProperty property : idpProperties) {
if (IdentityManagementEndpointConstants.UserInfoRecovery.RECOVERY_CALLBACK_REGEX.equals(property.getValue())) {
callbackRegex = property.getValue();
if (log.isDebugEnabled()) {
log.debug("Configured recovery callback URL regex: " + callbackRegex);
}
break;
}
}
}
if (StringUtils.isNotBlank(callbackURL)) {
try {
String encodeURL = URLEncoder.encode(callbackURL, IdentityManagementEndpointConstants.UTF_8);
URI uri = new URI(encodeURL);
callbackURL = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), null, null).toString();
if (log.isDebugEnabled()) {
log.debug("Callback URL in the username recovery request: " + callbackURL);
}
} catch (URISyntaxException e) {
throw new IdentityRecoveryException("Error occurred while formatting the provided callback URL. ", e);
} catch (UnsupportedEncodingException e) {
throw new IdentityRecoveryException("Error occurred while encoding the provided callback URL.", e);
}
}
return callbackRegex == null || callbackURL.matches(callbackRegex);
}
use of org.wso2.carbon.identity.core.ServiceURL in project product-is by wso2.
the class ProvisioningTestCase method createServiceClientsForServers.
private void createServiceClientsForServers(String sessionCookie, int portOffset, CommonConstants.AdminClients[] adminClients) throws Exception {
if (adminClients == null) {
return;
}
// TODO: Need to remove getSecureServiceUrl method when server start issue got fixed / TAF 4.3.1
String serviceUrl = getSecureServiceUrl(portOffset, automationContextMap.get(portOffset).getContextUrls().getSecureServiceUrl());
if (sessionCookie == null) {
AuthenticatorClient authenticatorClient = new AuthenticatorClient(serviceUrl);
sessionCookie = authenticatorClient.login(automationContextMap.get(portOffset).getSuperTenant().getTenantAdmin().getUserName(), automationContextMap.get(portOffset).getSuperTenant().getTenantAdmin().getPassword(), automationContextMap.get(portOffset).getDefaultInstance().getHosts().get("default"));
if (sessionCookie == null) {
throw new Exception("Unable to login to the server instance : " + automationContextMap.get(portOffset).getInstance().getName());
}
}
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
for (CommonConstants.AdminClients client : adminClients) {
if (CommonConstants.AdminClients.APPLICATION_MANAGEMENT_SERVICE_CLIENT.equals(client)) {
applicationManagementServiceClients.put(portOffset, new ApplicationManagementServiceClient(sessionCookie, serviceUrl, configContext));
} else if (CommonConstants.AdminClients.IDENTITY_PROVIDER_MGT_SERVICE_CLIENT.equals(client)) {
identityProviderMgtServiceClients.put(portOffset, new IdentityProviderMgtServiceClient(sessionCookie, serviceUrl));
} else if (CommonConstants.AdminClients.USER_MANAGEMENT_CLIENT.equals(client)) {
userMgtServiceClients.put(portOffset, new UserManagementClient(serviceUrl, sessionCookie));
}
}
}
use of org.wso2.carbon.identity.core.ServiceURL in project product-is by wso2.
the class ConditionalAuthenticationTestCase method startSecondaryIS.
private void startSecondaryIS() throws Exception {
AutomationContext context = testDataHolder.getAutomationContext();
String serviceUrl = (context.getContextUrls().getSecureServiceUrl()).replace("9853", String.valueOf(IS_DEFAULT_HTTPS_PORT + PORT_OFFSET_1)) + "/";
AuthenticatorClient authenticatorClient = new AuthenticatorClient(serviceUrl);
sessionCookie = authenticatorClient.login(context.getSuperTenant().getTenantAdmin().getUserName(), context.getSuperTenant().getTenantAdmin().getPassword(), context.getDefaultInstance().getHosts().get("default"));
if (sessionCookie != null) {
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
applicationManagementServiceClient2 = new ApplicationManagementServiceClient(sessionCookie, serviceUrl, configContext);
samlSSOConfigServiceClient = new SAMLSSOConfigServiceClient(serviceUrl, sessionCookie);
}
}
use of org.wso2.carbon.identity.core.ServiceURL in project identity-inbound-auth-oauth by wso2-extensions.
the class OIDCLogoutServletTest method mockServiceURLBuilder.
private void mockServiceURLBuilder(String context) 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.getRelativeInternalURL()).thenReturn(context);
when(serviceURLBuilder.build()).thenReturn(serviceURL);
}
Aggregations