use of org.wso2.carbon.identity.core.ServiceURL in project carbon-apimgt by wso2.
the class SubscriptionDataStoreImpl method isAPIResourceValidationEnabled.
public boolean isAPIResourceValidationEnabled() {
APIManagerConfiguration config = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
String serviceURL = config.getFirstProperty(APIConstants.GATEWAY_RESOURCE_CACHE_ENABLED);
if (StringUtils.isNotEmpty(serviceURL)) {
return Boolean.parseBoolean(serviceURL);
}
return true;
}
use of org.wso2.carbon.identity.core.ServiceURL in project carbon-apimgt by wso2.
the class APIManagerConfiguration method setEventHubConfiguration.
private void setEventHubConfiguration(OMElement omElement) {
EventHubConfigurationDto eventHubConfigurationDto = new EventHubConfigurationDto();
OMElement enableElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.ENABLE));
if (enableElement != null && Boolean.parseBoolean(enableElement.getText())) {
eventHubConfigurationDto.setEnabled(true);
OMElement serviceUrlElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.SERVICE_URL));
if (serviceUrlElement != null) {
String serviceUrl = APIUtil.replaceSystemProperty(serviceUrlElement.getText());
if (StringUtils.isNotEmpty(serviceUrl)) {
serviceUrl = serviceUrl.split("/" + APIConstants.SERVICES_URL_RELATIVE_PATH)[0];
eventHubConfigurationDto.setServiceUrl(serviceUrl);
}
}
OMElement initDelay = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.INIT_DELAY));
if (initDelay != null) {
eventHubConfigurationDto.setInitDelay(Integer.parseInt(initDelay.getText()));
}
OMElement usernameElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.USERNAME));
if (usernameElement != null) {
eventHubConfigurationDto.setUsername(usernameElement.getText());
}
OMElement passwordElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.PASSWORD));
if (passwordElement != null) {
String password = MiscellaneousUtil.resolve(passwordElement, secretResolver);
eventHubConfigurationDto.setPassword(APIUtil.replaceSystemProperty(password).toCharArray());
}
OMElement configurationRetrieverElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.EVENT_RECEIVER_CONFIGURATION));
if (configurationRetrieverElement != null) {
EventHubConfigurationDto.EventHubReceiverConfiguration eventHubReceiverConfiguration = new EventHubConfigurationDto.EventHubReceiverConfiguration();
Iterator receiverConnectionDetailsElements = configurationRetrieverElement.getChildElements();
Properties properties = new Properties();
while (receiverConnectionDetailsElements.hasNext()) {
OMElement element = (OMElement) receiverConnectionDetailsElements.next();
String value = MiscellaneousUtil.resolve(element, secretResolver);
properties.put(element.getLocalName(), APIUtil.replaceSystemProperty(value));
}
eventHubReceiverConfiguration.setJmsConnectionParameters(properties);
eventHubConfigurationDto.setEventHubReceiverConfiguration(eventHubReceiverConfiguration);
}
OMElement eventPublisherElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.EVENT_PUBLISHER_CONFIGURATIONS));
EventHubConfigurationDto.EventHubPublisherConfiguration eventHubPublisherConfiguration = new EventHubConfigurationDto.EventHubPublisherConfiguration();
if (eventPublisherElement != null) {
OMElement receiverUrlGroupElement = eventPublisherElement.getFirstChildWithName(new QName(APIConstants.AdvancedThrottleConstants.DATA_PUBLISHER_CONFIGURAION_REVEIVER_URL_GROUP));
if (receiverUrlGroupElement != null) {
eventHubPublisherConfiguration.setReceiverUrlGroup(APIUtil.replaceSystemProperty(receiverUrlGroupElement.getText()));
}
OMElement authUrlGroupElement = eventPublisherElement.getFirstChildWithName(new QName(APIConstants.AdvancedThrottleConstants.DATA_PUBLISHER_CONFIGURAION_AUTH_URL_GROUP));
if (authUrlGroupElement != null) {
eventHubPublisherConfiguration.setAuthUrlGroup(APIUtil.replaceSystemProperty(authUrlGroupElement.getText()));
}
OMElement eventTypeElement = eventPublisherElement.getFirstChildWithName(new QName(APIConstants.AdvancedThrottleConstants.DATA_PUBLISHER_CONFIGURAION_TYPE));
if (eventTypeElement != null) {
eventHubPublisherConfiguration.setType(eventTypeElement.getText().trim());
}
Map<String, String> publisherProps = extractPublisherProperties(eventPublisherElement);
if (publisherProps != null) {
eventHubPublisherConfiguration.setProperties(publisherProps);
}
eventHubConfigurationDto.setEventHubPublisherConfiguration(eventHubPublisherConfiguration);
}
}
this.eventHubConfigurationDto = eventHubConfigurationDto;
}
use of org.wso2.carbon.identity.core.ServiceURL in project carbon-apimgt by wso2.
the class APIUtil method getLoggedInUserInfo.
/**
* Gets the information of the logged in User.
*
* @param cookie Cookie of the previously logged in session.
* @param serviceUrl Url of the authentication service.
* @return LoggedUserInfo object containing details of the logged in user.
* @throws ExceptionException
* @throws RemoteException
*/
public static LoggedUserInfo getLoggedInUserInfo(String cookie, String serviceUrl) throws RemoteException, ExceptionException {
LoggedUserInfoAdminStub stub = new LoggedUserInfoAdminStub(null, serviceUrl + "LoggedUserInfoAdmin");
ServiceClient client = stub._getServiceClient();
Options options = client.getOptions();
options.setManageSession(true);
options.setProperty(HTTPConstants.COOKIE_STRING, cookie);
return stub.getUserInfo();
}
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));
}
}
}
Aggregations