org.apache.axis2.description.AxisService Java Examples

The following examples show how to use org.apache.axis2.description.AxisService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Wsdl20Processor.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void process(final CarbonHttpRequest request,
                    final CarbonHttpResponse response,
                    final ConfigurationContext configurationContext) throws Exception {
    WSDLPrinter wsdlPrinter = new WSDLPrinter() {
        public void printWSDL(AxisService axisService) throws IOException {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            axisService.printWSDL2(baos);
            RequestProcessorUtil.writeDocument(baos,
                                               response.getOutputStream(),
                                               "annotated-wsdl2.xsl",
                                               configurationContext.getContextRoot(),
                                               checkForAnnotation(request));
        }
    };
    String requestURI = request.getRequestURI();
    String contextPath = configurationContext.getServiceContextPath();
    String serviceName = requestURI.substring(requestURI.indexOf(contextPath) + contextPath.length() + 1);
    printWSDL(configurationContext, serviceName, response, wsdlPrinter);
}
 
Example #2
Source File: SecurityServiceAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public void setServiceParameterElement(String serviceName, Parameter parameter)
        throws AxisFault {
    AxisService axisService = axisConfig.getService(serviceName);

    if (axisService == null) {
        throw new AxisFault("Invalid service name '" + serviceName + "'");
    }

    Parameter p = axisService.getParameter(parameter.getName());
    if (p != null) {
        if (!p.isLocked()) {
            axisService.addParameter(parameter);
        }
    } else {
        axisService.addParameter(parameter);
    }

}
 
Example #3
Source File: SecurityConfigAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
protected boolean engageModules(String scenarioId, String serviceName, AxisService axisService)
        throws SecurityConfigException {

    boolean isRahasEngaged = false;
    SecurityScenario securityScenario = SecurityScenarioDatabase.get(scenarioId);
    String[] moduleNames = (String[]) securityScenario.getModules()
            .toArray(new String[securityScenario.getModules().size()]);
    // handle each module required
    try {

        for (String modName : moduleNames) {
            AxisModule module = axisService.getAxisConfiguration().getModule(modName);
            // engage at axis2
            axisService.disengageModule(module);
            axisService.engageModule(module);
            if (SecurityConstants.TRUST_MODULE.equalsIgnoreCase(modName)) {
                isRahasEngaged = true;
            }
        }
        return isRahasEngaged;

    } catch (AxisFault e) {
        log.error(e);
        throw new SecurityConfigException("Error in engaging modules", e);
    }
}
 
Example #4
Source File: SecurityConfigAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
protected void disableRESTCalls(String serviceName, String scenrioId)
        throws SecurityConfigException {

    if (scenrioId.equals(SecurityConstants.USERNAME_TOKEN_SCENARIO_ID)) {
        return;
    }

    try {
        AxisService service = axisConfig.getServiceForActivation(serviceName);
        if (service == null) {
            throw new SecurityConfigException("nullService");
        }

        Parameter param = new Parameter();
        param.setName(DISABLE_REST);
        param.setValue(Boolean.TRUE.toString());
        service.addParameter(param);

    } catch (AxisFault e) {
        log.error(e);
        throw new SecurityConfigException("disablingREST", e);
    }
}
 
Example #5
Source File: SecurityConfigAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Expose this service only via the specified transport
 *
 * @param serviceId          service name
 * @param transportProtocols transport protocols to expose
 * @throws AxisFault                                        axisfault
 * @throws org.wso2.carbon.security.SecurityConfigException ex
 */
public void setServiceTransports(String serviceId, List<String> transportProtocols)
        throws SecurityConfigException, AxisFault {

    AxisService axisService = axisConfig.getServiceForActivation(serviceId);

    if (axisService == null) {
        throw new SecurityConfigException("nullService");
    }

    List<String> transports = new ArrayList<>();
    for (int i = 0; i < transportProtocols.size(); i++) {
        transports.add(transportProtocols.get(i));
    }
    axisService.setExposedTransports(transports);

    if (log.isDebugEnabled()) {
        log.debug("Successfully add selected transport bindings to service " + serviceId);
    }
}
 
Example #6
Source File: SecurityConfigAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * This will return the policy path which is taken from registry. ie the original policy. It will be retrieved
 * from the policy which is attached to the service
 * @param serviceName name of the service.
 * @return Registry path to policy.
 */
private String getPolicyRegistryPath(String serviceName) {
    AxisService service = axisConfig.getServiceForActivation(serviceName);
    // Define an empty string. This will only get executed when a policy is picked from registry. Having an empty
    // string will avoid issues if something went wrong while adding policy path to carbonSecConfig
    String policyPath = "";
    try {
        OMElement carbonSecConfig = getCarbonSecConfigs(getCurrentPolicy(service));
        OMElement policyPathElement = carbonSecConfig.getFirstChildWithName(new QName(SecurityConstants
                .SECURITY_NAMESPACE, POLICY_PATH));
        if (policyPathElement != null) {
            policyPath = policyPathElement.getText();
        }
    } catch (SecurityConfigException e) {
        log.error("Error while retrieving current policy from service", e);
    }
    return policyPath;
}
 
Example #7
Source File: SubscriptionCreationWSWorkflowExecutorTest.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
@Test
public void testWorkflowCleanupTask() throws Exception {
	WorkflowDTO workflowDTO = new WorkflowDTO();
	workflowDTO.setWorkflowReference("1");
	workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());

	ServiceReferenceHolderMockCreator serviceRefMock = new ServiceReferenceHolderMockCreator(-1234);
	ServiceReferenceHolderMockCreator.initContextService();

	PowerMockito.whenNew(ServiceClient.class)
			.withArguments(Mockito.any(ConfigurationContext.class), Mockito.any(AxisService.class))
			.thenReturn(serviceClient);

	try {
		subscriptionCreationWSWorkflowExecutor.cleanUpPendingTask(workflowDTO.getExternalWorkflowReference());
	} catch (WorkflowException e) {
		Assert.fail("Error while calling the cleanup task");
	}

}
 
Example #8
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Helper method to handle security policies.
 *
 * @param file deployment data file.
 * @param axisService to be modified.
 * @return true if security is enabled, false otherwise.
 * @throws DataServiceFault
 */
private boolean handleSecurityProxy(DeploymentFileData file, AxisService axisService) throws DataServiceFault {
    try (FileInputStream fis = new FileInputStream(file.getFile().getAbsoluteFile())) {
        boolean secEnabled = false;
        StAXOMBuilder builder = new StAXOMBuilder(fis);
        OMElement documentElement =  builder.getDocumentElement();
        OMElement enableSecElement= documentElement.getFirstChildWithName(new QName(DBSFields.ENABLESEC));
        if (enableSecElement != null) {
            secEnabled = true;
        }
        OMElement policyElement= documentElement.getFirstChildWithName(new QName(DBSFields.POLICY));
        if (policyElement != null) {
            String policyKey = policyElement.getAttributeValue(new QName(DBSFields.POLICY_KEY));
            if (null == policyKey) {
                throw new DataServiceFault("Policy key element should contain a policy key in "
                        + file.getFile().getName());
            }
            Policy policy = PolicyEngine.getPolicy(DBUtils.getInputStreamFromPath(policyKey));
            axisService.getPolicySubject().attachPolicy(policy);
        }
        return secEnabled;
    }catch (Exception e) {
        throw new DataServiceFault(e, "Error in processing security policy");
    }
}
 
Example #9
Source File: WSDLToDataService.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Populates and returns an AxisService from a WSDL.
 * @param wsdlContent The WSDL content
 * @return AxisService which represents the given WSDL
 * @throws DataServiceFault
 */
private static AxisService getAxisServiceFromWSDL(byte[] wsdlContent) throws DataServiceFault {
	try {
		AxisService axisService;
		ByteArrayInputStream byteIn = new ByteArrayInputStream(wsdlContent);
		if (isWSDL20(wsdlContent)) {
			axisService = new WSDL20ToAxisServiceBuilder(byteIn, null, null).populateService();
		} else { // Must be WSDL11
			axisService = new WSDL11ToAxisServiceBuilder(byteIn, null, null).populateService();
		}
		return axisService;
	} catch (AxisFault e) {
		String message = "Error in getting AxisService from WSDL";
		throw new DataServiceFault(e, message);
	}
}
 
Example #10
Source File: UrlMappingServiceListener.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public void terminatingConfigurationContext(org.apache.axis2.context.ConfigurationContext configCtx) {
    HashMap<String, AxisService> serviceList = configCtx.getAxisConfiguration().getServices();
    for(Map.Entry<String, AxisService> entry : serviceList.entrySet()) {
        Parameter mapping = entry.getValue().getParameter("custom-mapping");
        int tenantId;
        if(mapping == null) {
            return;
        } else {
            if (((String)mapping.getValue()).equalsIgnoreCase("true")) {
                tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
                HostUtil.removeUrlMappingFromMap(tenantId, entry.getValue().getName());
                log.info("removing service mapping" + entry.getValue().getName() );

            }

        }
    }
}
 
Example #11
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static ServiceContext createAdressedEnabledClientSide(
        AxisService service) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());
    ConfigurationContext configContext = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(
                    "target/test-resources/integrationRepo", null);
    AxisModule axisModule = DeploymentEngine.buildModule(file,
                                                         configContext.getAxisConfiguration());

    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    axisConfiguration.addModule(axisModule);
    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
            configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
}
 
Example #12
Source File: UtilServer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static ServiceContext createAdressedEnabledClientSide(
        AxisService service, String clientHome) throws AxisFault {
    File file = getAddressingMARFile();
    TestCase.assertTrue(file.exists());

    ConfigurationContext configContext = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(clientHome, null);
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();

    AxisModule axisModule = DeploymentEngine.buildModule(file,axisConfiguration);
    axisConfiguration.addModule(axisModule);

    axisConfiguration.addService(service);
    ServiceGroupContext serviceGroupContext =
            configContext.createServiceGroupContext((AxisServiceGroup) service.getParent());
    return serviceGroupContext.getServiceContext(service);
}
 
Example #13
Source File: SecurityDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
private Policy applyPolicyToBindings(AxisService axisService) throws ServerException {
    Parameter parameter = axisService.getParameter(APPLY_POLICY_TO_BINDINGS);
    if (parameter != null && "true".equalsIgnoreCase(parameter.getValue().toString()) &&
            axisService.getPolicySubject() != null && axisService.getPolicySubject().getAttachedPolicyComponents()
            != null) {
        Iterator iterator = axisService.getPolicySubject().
                getAttachedPolicyComponents().iterator();
        while (iterator.hasNext()) {
            PolicyComponent currentPolicyComponent = (PolicyComponent) iterator.next();
            if (currentPolicyComponent instanceof Policy) {
                Policy policy = ((Policy) currentPolicyComponent);
                String policyId = policy.getId();
                axisService.getPolicySubject().detachPolicyComponent(policyId);
                addPolicyToAllBindings(axisService, policy);
                return policy;
            }
        }
    }
    return null;
}
 
Example #14
Source File: DBUtils.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * This method returns the available data services names.
 *
 * @param axisConfiguration Axis configuration
 * @return names of available data services
 * @throws AxisFault
 */
public static String[] getAvailableDS(AxisConfiguration axisConfiguration) throws AxisFault {
    List<String> serviceList = new ArrayList<>();
    Map<String, AxisService> map = axisConfiguration.getServices();
    Set<String> set = map.keySet();
    for (String serviceName : set) {
        AxisService axisService = axisConfiguration.getService(serviceName);
        Parameter parameter = axisService.getParameter(DBConstants.AXIS2_SERVICE_TYPE);
        if (parameter != null) {
            if (DBConstants.DB_SERVICE_TYPE.equals(parameter.getValue().toString())) {
                serviceList.add(serviceName);
            }
        }
    }
    return serviceList.toArray(new String[serviceList.size()]);
}
 
Example #15
Source File: Wsdl11Processor.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void process(final CarbonHttpRequest request,
                    final CarbonHttpResponse response,
                    final ConfigurationContext configurationContext) throws Exception {

    WSDLPrinter wsdlPrinter = new WSDLPrinter() {
        public void printWSDL(AxisService axisService) throws IOException {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            String importedWSDL = getImportedWSDL(request, "wsdl");
            if ("".equals(importedWSDL)) {
                axisService.printWSDL(baos, NetworkUtils.getLocalHostname());
            } else {
                axisService.printUserWSDL(baos, importedWSDL);
            }
            RequestProcessorUtil.writeDocument(baos,
                                               response.getOutputStream(),
                                               "annotated-wsdl.xsl",
                                               configurationContext.getContextRoot(),
                                               checkForAnnotation(request));
        }
    };
    String requestURI = request.getRequestURI();
    String contextPath = configurationContext.getServiceContextPath();
    String serviceName = requestURI.substring(requestURI.indexOf(contextPath) + contextPath.length() + 1);
    printWSDL(configurationContext, serviceName, response, wsdlPrinter);
}
 
Example #16
Source File: InfoProcessor.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public void process(CarbonHttpRequest request,
                    CarbonHttpResponse response,
                    ConfigurationContext configurationContext) throws Exception {
    String requestURI = request.getRequestURI();
    String contextPath = configurationContext.getServiceContextPath();
    String serviceName =
            requestURI.substring(requestURI.indexOf(contextPath) + contextPath.length() + 1);
    AxisService axisService =
            configurationContext.getAxisConfiguration().getServiceForActivation(serviceName);
    if (!RequestProcessorUtil.canExposeServiceMetadata(axisService)) {
        response.setError(HttpStatus.SC_FORBIDDEN,
                          "Access to service metadata for service: " + serviceName +
                          " has been forbidden");
        return;
    }
    String serviceHtml = ServiceHTMLProcessor.printServiceHTML(
            serviceName, configurationContext);
    if (serviceHtml != null) {
        response.setStatus(HttpStatus.SC_OK);
        response.addHeader(HTTP.CONTENT_TYPE, "text/html");
        response.getOutputStream().write(serviceHtml.getBytes());
    }
}
 
Example #17
Source File: STSConfigAdmin.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Override WSAS callback handler to be able to auth users with usermanager.
 *
 * @param axisConfig
 * @throws AxisFault
 */
public static void overrideCallbackHandler(AxisConfiguration axisConfig, String service) throws AxisFault {
    AxisService sts = axisConfig.getService(service);
    Parameter cbHandlerParam = sts.getParameter(WSHandlerConstants.PW_CALLBACK_REF);
    if (cbHandlerParam != null) {
        sts.removeParameter(cbHandlerParam);
        if (log.isDebugEnabled()) {
            log.debug("removedParameter");
        }
    }

    Parameter param = getPasswordCallBackRefParameter();

    sts.addParameter(param);

    if (log.isDebugEnabled()) {
        log.debug("addedParameter");
    }
}
 
Example #18
Source File: TenantSTSObserver.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public void serviceUpdate(AxisEvent axisEvent, AxisService service) {
    int eventType = axisEvent.getEventType();
    if (eventType == AxisEvent.SERVICE_DEPLOY) {
        try {
            if (ServerConstants.STS_NAME.equals(service.getName())) {
                if (log.isDebugEnabled()) {
                    log.debug("Configuring the STS service for tenant: " +
                              PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain() +
                              "[" + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId() + "]");
                }
                STSConfigAdmin.configureGenericSTS(service.getAxisConfiguration());
            }
        } catch (IdentityProviderException e) {
            log.error("Failed to configure STS service for tenant: " +
                      PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId() +
                      " - " + PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(), e);
        }
    }
}
 
Example #19
Source File: IWADeploymentInterceptor.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Updates RelyingPartyService with Crypto information
 *
 * @param config AxisConfiguration
 * @throws Exception
 */
public static void populateRampartConfig(AxisConfiguration config) throws Exception {

    AxisService service;

    // Get the RelyingParty Service to update security policy with keystore information
    service = config.getService(IWA_SERVICE_NAME);
    if (service == null) {
        String msg = IWA_SERVICE_NAME + " is not available in the Configuration Context";
        log.error(msg);
    }

    // Create a Rampart Config with default crypto information
    //Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig();
    Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig();
    // Add the RampartConfig to service policy
    service.getPolicySubject().attachPolicy(rampartConfig);

}
 
Example #20
Source File: IntegratorStatefulHandler.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Finds axis Service and the Operation for DSS requests
 *
 * @param msgContext request message context
 * @throws AxisFault if any exception occurs while finding axis service or operation
 */
private static void dispatchAndVerify(MessageContext msgContext) throws AxisFault {
    requestDispatcher.invoke(msgContext);
    AxisService axisService = msgContext.getAxisService();
    if (axisService != null) {
        httpLocationBasedDispatcher.invoke(msgContext);
        if (msgContext.getAxisOperation() == null) {
            requestURIOperationDispatcher.invoke(msgContext);
        }

        AxisOperation axisOperation;
        if ((axisOperation = msgContext.getAxisOperation()) != null) {
            AxisEndpoint axisEndpoint =
                    (AxisEndpoint) msgContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
            if (axisEndpoint != null) {
                AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisEndpoint
                        .getBinding().getChild(axisOperation.getName());
                msgContext.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
            }
            msgContext.setAxisOperation(axisOperation);
        }
    }
}
 
Example #21
Source File: StatisticsAdmin.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private AxisService getAxisService(String serviceName) {
    AxisConfiguration axisConfiguration = getAxisConfig();
    AxisService axisService = axisConfiguration.getServiceForActivation(serviceName);
    // Check if the service in in ghost list
    try {
        if (axisService == null && GhostDeployerUtils.
                getTransitGhostServicesMap(axisConfiguration).containsKey(serviceName)) {
            GhostDeployerUtils.waitForServiceToLeaveTransit(serviceName, getAxisConfig());
            axisService = axisConfiguration.getServiceForActivation(serviceName);
        }
    } catch (AxisFault axisFault) {
        log.error("Error occurred while service : " + serviceName + " is " +
                  "trying to leave transit", axisFault);
    }
    return axisService;
}
 
Example #22
Source File: UrlMappingDeploymentInterceptor.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public void serviceUpdate(AxisEvent axisEvent, AxisService axisService) {

        Parameter mapping = axisService.getParameter("custom-mapping");
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (mapping == null) {
            return;
        } else {
            if (((String) mapping.getValue()).equalsIgnoreCase("true")) {
                if (axisEvent.getEventType() == 1 || axisEvent.getEventType() == 3) {
                    if (tenantId != MultitenantConstants.SUPER_TENANT_ID) {
                        HostUtil.addServiceUrlMapping(tenantId, axisService.getName());
                    }
                } else if (axisEvent.getEventType() == 0 || axisEvent.getEventType() == 2) {
                    tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
                    HostUtil.removeUrlMappingFromMap(tenantId, axisService.getName());
                }
            }
        }
    }
 
Example #23
Source File: STSAdminServiceImpl.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public void removeTrustedService(String serviceAddress) throws SecurityConfigException {
    try {
        AxisService stsService = getAxisConfig().getService(ServerConstants.STS_NAME);
        Parameter origParam = stsService.getParameter(SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG
                .getLocalPart());
        if (origParam != null) {
            OMElement samlConfigElem = origParam.getParameterElement().getFirstChildWithName(
                    SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG);
            SAMLTokenIssuerConfig samlConfig = new SAMLTokenIssuerConfig(samlConfigElem);
            samlConfig.getTrustedServices().remove(serviceAddress);
            setSTSParameter(samlConfig);
            removeTrustedService(ServerConstants.STS_NAME, ServerConstants.STS_NAME,
                    serviceAddress);
        } else {
            throw new AxisFault("missing parameter : "
                    + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart());
        }

    } catch (Exception e) {
        log.error("Error while removing a trusted service", e);
        throw new SecurityConfigException(e.getMessage(), e);
    }
}
 
Example #24
Source File: POXSecurityHandler.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private String getScenarioId(MessageContext msgCtx, AxisService service) throws SecurityConfigException {
    String scenarioID = null;
    try {
        scenarioID = (String) service.getParameter(SecurityConstants.SCENARIO_ID_PARAM_NAME).getValue();
    } catch (Exception e) {
    }//ignore

    if (scenarioID == null) {
        synchronized (this) {
            SecurityConfigAdmin securityAdmin = new SecurityConfigAdmin(msgCtx.
                    getConfigurationContext().getAxisConfiguration());
            SecurityScenarioData data = securityAdmin.getCurrentScenario(service.getName());
            if (data != null) {
                scenarioID = data.getScenarioId();
                try {
                    Parameter param = new Parameter();
                    param.setName(SecurityConstants.SCENARIO_ID_PARAM_NAME);
                    param.setValue(scenarioID);
                    service.addParameter(param);
                } catch (AxisFault axisFault) {
                    log.error("Error while adding Scenario ID parameter", axisFault);
                }
            }
        }
    }

    return scenarioID;
}
 
Example #25
Source File: STSDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void serviceUpdate(AxisEvent event, AxisService service) {
    if (event.getEventType() == AxisEvent.SERVICE_DEPLOY
        && ServerConstants.STS_NAME.equals(service.getName())) {
        try {
            updateSTSService(service.getAxisConfiguration());
        } catch (Exception e) {
            log.error("Error while updating " + ServerConstants.STS_NAME
                      + " in STSDeploymentInterceptor", e);
        }
    }
}
 
Example #26
Source File: STSObserver.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public void serviceUpdate(AxisEvent axisEvent, AxisService service) {
    int eventType = axisEvent.getEventType();
    if (eventType == AxisEvent.SERVICE_DEPLOY) {
        try {
            STSConfigAdmin.configureService(service.getName());
            if (ServerConstants.STS_NAME.equals(service.getName())) {
                STSConfigAdmin.configureGenericSTS();
            }
        } catch (IdentityProviderException e) {
            log.error(e);
        }
    }

}
 
Example #27
Source File: ApplicationCreationWSWorkflowExecutorTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testWorkflowExecute() throws Exception {
	ApplicationWorkflowDTO workflowDTO = new ApplicationWorkflowDTO();       

	Application application = new Application("TestAPP", new Subscriber(null));
	
	application.setTier("Gold");
	application.setCallbackUrl("www.wso2.com");
	application.setDescription("Description");	
	workflowDTO.setApplication(application);
	workflowDTO.setTenantDomain("wso2");
	workflowDTO.setUserName("admin");
	workflowDTO.setCallbackUrl("http://localhost:8280/workflow-callback");
	workflowDTO.setWorkflowReference("1");
	workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());

	PowerMockito.doNothing().when(apiMgtDAO).updateSubscriptionStatus(
			Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);

	ServiceReferenceHolderMockCreator serviceRefMock = new ServiceReferenceHolderMockCreator(-1234);
	ServiceReferenceHolderMockCreator.initContextService();

	PowerMockito.whenNew(ServiceClient.class)
			.withArguments(Mockito.any(ConfigurationContext.class), Mockito.any(AxisService.class))
			.thenReturn(serviceClient);

	try {
		Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
	} catch (WorkflowException e) {
		Assert.fail("Unexpected WorkflowException occurred while executing Subscription creation ws workflow");
	}

}
 
Example #28
Source File: ApplicationCreationWSWorkflowExecutorTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void testWorkflowExecuteWithLimitedParam() throws Exception {
	//application without a callback url 
	ApplicationWorkflowDTO workflowDTO = new ApplicationWorkflowDTO();       

	Application application = new Application("TestAPP", new Subscriber(null));
	
	application.setTier("Gold");
	application.setDescription("Description");	
	workflowDTO.setApplication(application);
	workflowDTO.setTenantDomain("wso2");
	workflowDTO.setUserName("admin");
	workflowDTO.setWorkflowReference("1");
	workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());

	PowerMockito.doNothing().when(apiMgtDAO).updateSubscriptionStatus(
			Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);

	ServiceReferenceHolderMockCreator serviceRefMock = new ServiceReferenceHolderMockCreator(-1234);
	ServiceReferenceHolderMockCreator.initContextService();

	PowerMockito.whenNew(ServiceClient.class)
			.withArguments(Mockito.any(ConfigurationContext.class), Mockito.any(AxisService.class))
			.thenReturn(serviceClient);

	try {
		Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
	} catch (WorkflowException e) {
		Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
	}

}
 
Example #29
Source File: DBUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This method verifies whether there's an existing data service for the given name.
 *
 * @param axisConfiguration Axis configuration
 * @param dataService       Data service
 * @return Boolean (Is available)
 * @throws AxisFault
 */
public static boolean isAvailableDS(AxisConfiguration axisConfiguration, String dataService) throws AxisFault {
    Map<String, AxisService> map = axisConfiguration.getServices();
    AxisService axisService = map.get(dataService);
    if (axisService != null) {
        Parameter parameter = axisService.getParameter(DBConstants.AXIS2_SERVICE_TYPE);
        if (parameter != null) {
            if (DBConstants.DB_SERVICE_TYPE.equals(parameter.getValue().toString())) {
                return true;
            }
        }
    }
    return false;
}
 
Example #30
Source File: XsdProcessor.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void process(CarbonHttpRequest request,
                    CarbonHttpResponse response,
                    ConfigurationContext configCtx) throws Exception {
    String requestURI = request.getRequestURI();
    String contextPath = configCtx.getServiceContextPath();
    String serviceName = requestURI.substring(requestURI.indexOf(contextPath) + contextPath.length() + 1);
    AxisService axisService =
            configCtx.getAxisConfiguration().getServiceForActivation(serviceName);
    XsdUtil.printXsd(request, response, configCtx, serviceName, axisService);

}