Java Code Examples for org.apache.axis2.description.AxisService#getName()

The following examples show how to use org.apache.axis2.description.AxisService#getName() . 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: WSDLToDataService.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and deploys a contract first data service with the given WSDL
 * data.
 * @param axisConfig The current axis configuration
 * @param wsdlContent The WSDL content
 * @throws DataServiceFault
 */
public static void deployDataService(AxisConfiguration axisConfig,
		byte[] wsdlContent) throws DataServiceFault {
	try {
		AxisService axisService = getAxisServiceFromWSDL(wsdlContent);
		String serviceName = axisService.getName();
		DataService dataService = createDataServiceFromAxisService(axisService);
		String dsContents = DataServiceSerializer.serializeDataService(dataService).toString();
		writeToRepository(axisConfig, serviceName, dsContents);
	} catch (DataServiceFault e) {
		log.error("Error in deploying contract first data service", e); //TODO
		throw e;
	}
}
 
Example 2
Source File: AbstractAdmin.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void checkAdminService() {
    MessageContext msgCtx = MessageContext.getCurrentMessageContext();
    if (msgCtx == null) {
        return;
    }
    AxisService axisService = msgCtx.getAxisService();
    if (axisService.getParameter(Constants.ADMIN_SERVICE_PARAM_NAME) == null) {
        throw new RuntimeException(
                "AbstractAdmin can only be extended by Carbon admin services. " + getClass().getName()
                        + " is not an admin service. Service name " + axisService.getName()
                        + ". The service should have defined the " + Constants.ADMIN_SERVICE_PARAM_NAME
                        + " parameter");
    }
}
 
Example 3
Source File: Util.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get the WS-D types of an Axis2 service. By default the port types of the
 * service are considered as WS-D types.
 *
 * @param axisService The Axis2 service
 * @return a WS-D type to be associated with the service
 */
public static QName getTypes(AxisService axisService) {
    QName portType;
    String localPart;
    if (axisService.getParameter(WSDL2Constants.INTERFACE_LOCAL_NAME) != null) {
        localPart = (String) axisService.getParameter(
                WSDL2Constants.INTERFACE_LOCAL_NAME).getValue();
    } else {
        localPart = axisService.getName() + Java2WSDLConstants.PORT_TYPE_SUFFIX;
    }
    portType = new QName(axisService.getTargetNamespace(), localPart);
    return portType;
}
 
Example 4
Source File: TracingInPostDispatchHandler.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
    AxisService axisService = msgContext.getAxisService();

    if (axisService == null || axisService.isClientSide()) {
        return InvocationResponse.CONTINUE;
    }

    // Do not trace messages from admin services
    if (axisService.getParent() != null) {
        if (SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup())) {
            return InvocationResponse.CONTINUE;
        }
    }

    ConfigurationContext configCtx = msgContext.getConfigurationContext();
    TraceFilter traceFilter =
        (TraceFilter) configCtx.getAxisConfiguration().
            getParameter(TracerConstants.TRACE_FILTER_IMPL).getValue();
    if (traceFilter.isFilteredOut(msgContext)) {
        return InvocationResponse.CONTINUE;
    }

    if ((msgContext.getAxisOperation() != null) &&
        (msgContext.getAxisOperation().getName() != null)) {
        String operationName =
            msgContext.getAxisOperation().getName().getLocalPart();
        String serviceName = axisService.getName();

        // Add the message id to the CircularBuffer.
        // We need to track only the IN_FLOW msg, since with that sequence number,
        // we can retrieve all other related messages from the persister.
        appendMessage(msgContext.getConfigurationContext(),
                      serviceName, operationName,
                      storeMessage(serviceName, operationName, msgContext));
    }
    return InvocationResponse.CONTINUE;
}
 
Example 5
Source File: SecurityDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
private void processPolicy (AxisService axisService, String policyId,
                            PolicyComponent currentPolicyComponent) throws UserStoreException,
        AxisFault {

    // Do not apply anything if no policy
    if(StringUtils.isNotEmpty(policyId) && NO_POLICY_ID.equalsIgnoreCase(policyId)){
        if(axisService != null){
            UserRealm userRealm = (UserRealm)PrivilegedCarbonContext.getThreadLocalCarbonContext()
                    .getUserRealm();
            String serviceGroupId = axisService.getAxisServiceGroup().getServiceGroupName();
            String serviceName = axisService.getName();
            removeAuthorization(userRealm,serviceGroupId,serviceName);
        }

        AxisModule module = axisService.getAxisConfiguration().getModule(SecurityConstants
                .RAMPART_MODULE_NAME);
        // disengage at axis2
        axisService.disengageModule(module);
        return;
    }

    if (policyId != null && isSecPolicy(policyId)) {

        if (log.isDebugEnabled()) {
            log.debug("Policy " + policyId + " is identified as a security " +
                    "policy and trying to apply security parameters");
        }

        SecurityScenario scenario = SecurityScenarioDatabase.getByWsuId(policyId);
        if (scenario == null) {
            // if there is no security scenario id,  put default id
            if (log.isDebugEnabled()) {
                log.debug("Policy " + policyId + " does not belongs to a" +
                        " pre-defined security scenario. " +
                        "So treating as a custom policy");
            }
            SecurityScenario securityScenario = new SecurityScenario();
            securityScenario.setScenarioId(
                    SecurityConstants.CUSTOM_SECURITY_SCENARIO);
            securityScenario.setWsuId(policyId);
            securityScenario.setGeneralPolicy(false);
            securityScenario.setSummary(
                    SecurityConstants.CUSTOM_SECURITY_SCENARIO_SUMMARY);
            SecurityScenarioDatabase.put(policyId, securityScenario);
            scenario = securityScenario;
        }
        applySecurityParameters(axisService, scenario,
                (Policy) currentPolicyComponent);
    }
}
 
Example 6
Source File: SecurityDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
private void applySecurityParameters(AxisService service, SecurityScenario secScenario,
                                     Policy policy) {
    try {

        UserRealm userRealm = (UserRealm) PrivilegedCarbonContext.getThreadLocalCarbonContext()
                .getUserRealm();

        UserRegistry govRegistry = (UserRegistry) PrivilegedCarbonContext
                .getThreadLocalCarbonContext().getRegistry(RegistryType.SYSTEM_GOVERNANCE);

        String serviceGroupId = service.getAxisServiceGroup().getServiceGroupName();
        String serviceName = service.getName();

        SecurityConfigParams configParams =
                SecurityConfigParamBuilder.getSecurityParams(getSecurityConfig(policy));

        // Set Trust (Rahas) Parameters
        if (secScenario.getModules().contains(SecurityConstants.TRUST_MODULE)) {
            AxisModule trustModule = service.getAxisConfiguration()
                    .getModule(SecurityConstants.TRUST_MODULE);
            if (log.isDebugEnabled()) {
                log.debug("Enabling trust module : " + SecurityConstants.TRUST_MODULE);
            }

            service.disengageModule(trustModule);
            service.engageModule(trustModule);

            Properties cryptoProps = new Properties();
            cryptoProps.setProperty(ServerCrypto.PROP_ID_PRIVATE_STORE,
                                    configParams.getPrivateStore());
            cryptoProps.setProperty(ServerCrypto.PROP_ID_DEFAULT_ALIAS,
                                    configParams.getKeyAlias());
            if (configParams.getTrustStores() != null) {
                cryptoProps.setProperty(ServerCrypto.PROP_ID_TRUST_STORES,
                                        configParams.getTrustStores());
            }
            service.addParameter(RahasUtil.getSCTIssuerConfigParameter(
                    ServerCrypto.class.getName(), cryptoProps, -1, null, true, true));

            service.addParameter(RahasUtil.getTokenCancelerConfigParameter());

        }

        // Authorization
        AuthorizationManager manager = userRealm.getAuthorizationManager();
        String resourceName = serviceGroupId + "/" + serviceName;
        removeAuthorization(userRealm,serviceGroupId,serviceName);
        String allowRolesParameter = configParams.getAllowedRoles();
        if (allowRolesParameter != null) {
            if (log.isDebugEnabled()) {
                log.debug("Authorizing roles " + allowRolesParameter);
            }
            String[] allowRoles = allowRolesParameter.split(",");
            if (allowRoles != null) {
                for (String role : allowRoles) {
                    manager.authorizeRole(role, resourceName,
                                          UserCoreConstants.INVOKE_SERVICE_PERMISSION);
                }
            }
        }

        // Password Callback Handler
        ServicePasswordCallbackHandler handler =
                new ServicePasswordCallbackHandler(configParams, serviceGroupId, serviceName,
                                                   govRegistry, userRealm);

        Parameter param = new Parameter();
        param.setName(WSHandlerConstants.PW_CALLBACK_REF);
        param.setValue(handler);
        service.addParameter(param);

    } catch (Throwable e) {
    //TODO: Copied from 4.2.2.
    //TODO: Not sure why we are catching throwable. Need to check error handling is correct
        String msg = "Cannot apply security parameters";
        log.error(msg, e);
    }
}