Java Code Examples for org.apache.axis2.description.AxisEndpoint#getBinding()

The following examples show how to use org.apache.axis2.description.AxisEndpoint#getBinding() . 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: SecurityDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void addPolicyToAllBindings(AxisService axisService, Policy policy)
        throws ServerException {
    try {
        if (policy.getId() == null) {
            // Generate an ID
            policy.setId(UUIDGenerator.getUUID());
        }
        Map endPointMap = axisService.getEndpoints();
        for (Object o : endPointMap.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            AxisEndpoint point = (AxisEndpoint) entry.getValue();
            AxisBinding binding = point.getBinding();
            String bindingName = binding.getName().getLocalPart();

            //only UTOverTransport is allowed for HTTP
            if (bindingName.endsWith("HttpBinding") &&
                    (!policy.getAttributes().containsValue("UTOverTransport"))) {
                continue;
            }
            binding.getPolicySubject().attachPolicy(policy);
            // Add the new policy to the registry
        }
    } catch (Exception e) {
        log.error("Error in adding security policy to all bindings", e);
        throw new ServerException("addPoliciesToService", e);
    }
}
 
Example 2
Source File: SecurityServiceAdmin.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * This method add Policy to service at the Registry. Does not add the
 * policy to Axis2. To all Bindings available
 *
 * @param axisService Service
 * @param policy      Policy
 * @throws org.wso2.carbon.utils.ServerException se
 */
public void addSecurityPolicyToAllBindings(AxisService axisService, Policy policy)
        throws ServerException {
    String serviceGroupId = axisService.getAxisServiceGroup().getServiceGroupName();
    try {
        if (policy.getId() == null) {
            policy.setId(UUIDGenerator.getUUID());
        }

        Map endPointMap = axisService.getEndpoints();
        for (Object o : endPointMap.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            AxisEndpoint point = (AxisEndpoint) entry.getValue();
            AxisBinding binding = point.getBinding();
            String bindingName = binding.getName().getLocalPart();

            //only UTOverTransport is allowed for HTTP
            if (bindingName.endsWith("HttpBinding") &&
                    (!policy.getAttributes().containsValue("UTOverTransport"))) {
                continue;
            }
            binding.getPolicySubject().attachPolicy(policy);

        }
    } catch (Exception e) {
        log.error("Error in adding security policy to all bindings", e);
        throw new ServerException("addPoliciesToService", e);
    }
}
 
Example 3
Source File: SecurityServiceAdmin.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void removeSecurityPolicyFromAllBindings(AxisService axisService, String uuid)
        throws ServerException {
    if (log.isDebugEnabled()) {
        log.debug("Removing  security policy from all bindings.");
    }
    Map endPointMap = axisService.getEndpoints();
    for (Object o : endPointMap.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        AxisEndpoint point = (AxisEndpoint) entry.getValue();
        AxisBinding binding = point.getBinding();
        if (binding.getPolicySubject().getAttachedPolicyComponent(uuid) != null) {
            binding.getPolicySubject().detachPolicyComponent(uuid);
        }
    }
}