protected void processPolicyElements(Iterator policyElements, PolicySubject policySubject) { while (policyElements.hasNext()) { Policy p = PolicyEngine .getPolicy((OMElement) policyElements.next()); policySubject.attachPolicy(p); } }
public Policy getEffectivePolicy() { Collection<PolicyComponent> policyList = new ArrayList<PolicyComponent>(); policyList.addAll(getPolicySubject().getAttachedPolicyComponents()); // AxisBinding AxisBinding axisBinding = getAxisBinding(); if (axisBinding != null) { policyList.addAll(axisBinding.getPolicySubject().getAttachedPolicyComponents()); } // AxisEndpoint AxisEndpoint axisEndpoint = null; if (axisBinding != null) { axisEndpoint = axisBinding.getAxisEndpoint(); } if (axisEndpoint != null) { policyList.addAll(axisEndpoint.getPolicySubject().getAttachedPolicyComponents()); } if (axisOperation != null) { policyList.addAll(axisOperation.getPolicySubject().getAttachedPolicyComponents()); } return PolicyUtil.getMergedPolicy(policyList, this); }
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; }
public void attachPolicyComponent(PolicyComponent policyComponent) { if (policyComponent instanceof Policy) { attachPolicy((Policy) policyComponent); } else if (policyComponent instanceof PolicyReference) { attachPolicyReference((PolicyReference) policyComponent); } else { throw new IllegalArgumentException( "Invalid top level policy component type"); } }
/** * @deprecated As of 1.4 release. You can't override a policies that * applicable for the current policy scope via * {@link PolicyInclude #setEffectivePolicy(Policy)}. In case * you need to make a policy the only policy that is within the * policy cache of an {@link AxisDescription} please use * {@link PolicySubject #clear()} and * {@link PolicySubject #attachPolicy(Policy)} accordingly. * */ public void setEffectivePolicy(Policy effectivePolicy) { this.effectivePolicy = effectivePolicy; if (description != null && effectivePolicy != null) { description.getPolicySubject().clear(); description.getPolicySubject().attachPolicy(effectivePolicy); } }
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); } } }
List list = new ArrayList(policySubject.getAttachedPolicyComponents()); Policy policy = PolicyUtil.getMergedPolicy(list, null); if (policy != null) { policySubject.detachPolicyComponent(id); defaultPolicy.setId(id); policySubject.attachPolicy(defaultPolicy); throttle = defaultThrottle;
extPolicySubject = new PolicySubject(); extPolicySubject.attachPolicy(globalPolicy); } catch (FileNotFoundException e) { log.error("Error while reading global policy file..", e);
public static String generateId(AxisDescription description) { PolicySubject policySubject = description.getPolicySubject(); String identifier = "-policy-1"; if (description instanceof AxisMessage) { identifier = "msg-" + ((AxisMessage) description).getName() + identifier; description = description.getParent(); } if (description instanceof AxisOperation) { identifier = "op-" + ((AxisOperation) description).getName() + identifier; description = description.getParent(); } if (description instanceof AxisService) { identifier = "service-" + ((AxisService) description).getName() + identifier; } /* * Int 49 is the value of the Character '1'. Here we want to change '1' * to '2' or '2' to '3' .. etc. to construct a unique identifier. */ for (int index = 49; policySubject.getAttachedPolicyComponent(identifier) != null; index++) { identifier = identifier.replace((char) index, (char) (index + 1)); } return identifier; }
public AxisDescription() { parameterInclude = new ParameterIncludeImpl(); children = new ConcurrentHashMap<Object, AxisDescription>(); policySubject = new PolicySubject(); }
/** * @deprecated As of 1.4 release. You can't override a policies that * applicable for the current policy scope via * {@link PolicyInclude #setEffectivePolicy(Policy)}. In case * you need to make a policy the only policy that is within the * policy cache of an {@link AxisDescription} please use * {@link PolicySubject #clear()} and * {@link PolicySubject #attachPolicy(Policy)} accordingly. * */ public void setEffectivePolicy(Policy effectivePolicy) { this.effectivePolicy = effectivePolicy; if (description != null && effectivePolicy != null) { description.getPolicySubject().clear(); description.getPolicySubject().attachPolicy(effectivePolicy); } }
public void attachPolicyComponent(PolicyComponent policyComponent) { if (policyComponent instanceof Policy) { attachPolicy((Policy) policyComponent); } else if (policyComponent instanceof PolicyReference) { attachPolicyReference((PolicyReference) policyComponent); } else { throw new IllegalArgumentException( "Invalid top level policy component type"); } }
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); } } }
public static String generateId(AxisDescription description) { PolicySubject policySubject = description.getPolicySubject(); String identifier = "-policy-1"; if (description instanceof AxisMessage) { identifier = "msg-" + ((AxisMessage) description).getName() + identifier; description = description.getParent(); } if (description instanceof AxisOperation) { identifier = "op-" + ((AxisOperation) description).getName() + identifier; description = description.getParent(); } if (description instanceof AxisService) { identifier = "service-" + ((AxisService) description).getName() + identifier; } /* * Int 49 is the value of the Character '1'. Here we want to change '1' * to '2' or '2' to '3' .. etc. to construct a unique identifier. */ for (int index = 49; policySubject.getAttachedPolicyComponent(identifier) != null; index++) { identifier = identifier.replace((char) index, (char) (index + 1)); } return identifier; }
public AxisDescription() { parameterInclude = new ParameterIncludeImpl(); children = new ConcurrentHashMap<Object, AxisDescription>(); policySubject = new PolicySubject(); }
public Policy getEffectivePolicy() { Collection<PolicyComponent> policyList = new ArrayList<PolicyComponent>(); policyList.addAll(getPolicySubject().getAttachedPolicyComponents()); // AxisBinding AxisBinding axisBinding = getAxisBinding(); if (axisBinding != null) { policyList.addAll(axisBinding.getPolicySubject().getAttachedPolicyComponents()); } // AxisEndpoint AxisEndpoint axisEndpoint = null; if (axisBinding != null) { axisEndpoint = axisBinding.getAxisEndpoint(); } if (axisEndpoint != null) { policyList.addAll(axisEndpoint.getPolicySubject().getAttachedPolicyComponents()); } if (axisOperation != null) { policyList.addAll(axisOperation.getPolicySubject().getAttachedPolicyComponents()); } return PolicyUtil.getMergedPolicy(policyList, this); }
protected void processPolicyElements(Iterator policyElements, PolicySubject policySubject) { while (policyElements.hasNext()) { Policy p = PolicyEngine .getPolicy((OMElement) policyElements.next()); policySubject.attachPolicy(p); } }
/** * This method sets the policy as the default of this AxisDescription instance. Further more * this method does the followings. <p/> (1) Engage whatever modules necessary to execute new * the effective policy of this AxisDescription instance. (2) Disengage whatever modules that * are not necessary to execute the new effective policy of this AxisDescription instance. (3) * Check whether each module can execute the new effective policy of this AxisDescription * instance. (4) If not throw an AxisFault to notify the user. (5) Else notify each module about * the new effective policy. * * @param policy the new policy of this AxisDescription instance. The effective policy is the * merge of this argument with effective policy of parent of this * AxisDescription. * @throws AxisFault if any module is unable to execute the effective policy of this * AxisDescription instance successfully or no module to execute some portion * (one or more PrimtiveAssertions ) of that effective policy. */ public void applyPolicy(Policy policy) throws AxisFault { // sets AxisDescription policy getPolicySubject().clear(); getPolicySubject().attachPolicy(policy); /* * now we try to engage appropriate modules based on the merged policy * of axis description object and the corresponding axis binding * description object. */ applyPolicy(); }
description.getPolicySubject().attachPolicy(policy); description.getPolicySubject().attachPolicyReference(policyReference);
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; }