org.apache.neethi.Policy

Here are the examples of the java api org.apache.neethi.Policy taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

56 Examples 7

19 Source : PolicyEngineImpl.java
with Eclipse Public License 1.0
from OpenLiberty

Policy getAggregatedMessagePolicy(BindingMessageInfo bmi) {
    Policy aggregated = null;
    for (PolicyProvider pp : getPolicyProviders()) {
        Policy p = pp.getEffectivePolicy(bmi);
        if (null == aggregated) {
            aggregated = p;
        } else if (p != null) {
            aggregated = aggregated.merge(p);
        }
    }
    return aggregated == null ? new Policy() : aggregated;
}

19 Source : EffectivePolicyImpl.java
with Eclipse Public License 1.0
from OpenLiberty

// for tests
void setPolicy(Policy ep) {
    policy = ep;
}

19 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

public Policy getEffectivePolicy(BindingMessageInfo bmi) {
    readDoreplacedent();
    Policy p = null;
    for (PolicyAttachment pa : attachments) {
        if (pa.appliesTo(bmi)) {
            if (p == null) {
                p = new Policy();
            }
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

18 Source : PolicyEngineImpl.java
with Eclipse Public License 1.0
from OpenLiberty

Policy getAggregatedServicePolicy(ServiceInfo si) {
    if (si == null) {
        return new Policy();
    }
    Policy aggregated = null;
    for (PolicyProvider pp : getPolicyProviders()) {
        Policy p = pp.getEffectivePolicy(si);
        if (null == aggregated) {
            aggregated = p;
        } else if (p != null) {
            aggregated = aggregated.merge(p);
        }
    }
    return aggregated == null ? new Policy() : aggregated;
}

18 Source : PolicyEngineImpl.java
with Eclipse Public License 1.0
from OpenLiberty

Policy getAggregatedEndpointPolicy(EndpointInfo ei) {
    Policy aggregated = null;
    for (PolicyProvider pp : getPolicyProviders()) {
        Policy p = pp.getEffectivePolicy(ei);
        if (null == aggregated) {
            aggregated = p;
        } else if (p != null) {
            aggregated = aggregated.merge(p);
        }
    }
    return aggregated == null ? new Policy() : aggregated;
}

18 Source : PolicyEngineImpl.java
with Eclipse Public License 1.0
from OpenLiberty

Policy getAggregatedOperationPolicy(BindingOperationInfo boi) {
    Policy aggregated = null;
    for (PolicyProvider pp : getPolicyProviders()) {
        Policy p = pp.getEffectivePolicy(boi);
        if (null == aggregated) {
            aggregated = p;
        } else if (p != null) {
            aggregated = aggregated.merge(p);
        }
    }
    return aggregated == null ? new Policy() : aggregated;
}

18 Source : PolicyEngineImpl.java
with Eclipse Public License 1.0
from OpenLiberty

Policy getAggregatedFaultPolicy(BindingFaultInfo bfi) {
    Policy aggregated = null;
    for (PolicyProvider pp : getPolicyProviders()) {
        Policy p = pp.getEffectivePolicy(bfi);
        if (null == aggregated) {
            aggregated = p;
        } else if (p != null) {
            aggregated = aggregated.merge(p);
        }
    }
    return aggregated == null ? new Policy() : aggregated;
}

18 Source : Wsdl11AttachmentPolicyProvider.java
with Eclipse Public License 1.0
from OpenLiberty

/**
 * The effective policy for a WSDL endpoint policy subject includes the element policy of the
 * wsdl11:port element that defines the endpoint merged with the element policy of the
 * referenced wsdl11:binding element and the element policy of the referenced wsdl11:portType
 * element that defines the interface of the endpoint.
 *
 * @param ei the EndpointInfo object identifying the endpoint
 * @return the effective policy
 */
public Policy getEffectivePolicy(EndpointInfo ei) {
    Policy p = getElementPolicy(ei);
    p = mergePolicies(p, getElementPolicy(ei.getBinding()));
    p = mergePolicies(p, getElementPolicy(ei.getInterface(), true));
    return p;
}

18 Source : Wsdl11AttachmentPolicyProvider.java
with Eclipse Public License 1.0
from OpenLiberty

private Policy mergePolicies(Policy p1, Policy p2) {
    if (p1 == null) {
        return p2;
    } else if (p2 == null) {
        return p1;
    }
    return p1.merge(p2);
}

18 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

public Policy getEffectivePolicy(EndpointInfo ei) {
    readDoreplacedent();
    Policy p = null;
    for (PolicyAttachment pa : attachments) {
        if (pa.appliesTo(ei)) {
            if (p == null) {
                p = new Policy();
            }
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

18 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

public Policy getEffectivePolicy(BindingFaultInfo bfi) {
    readDoreplacedent();
    Policy p = null;
    for (PolicyAttachment pa : attachments) {
        if (pa.appliesTo(bfi)) {
            if (p == null) {
                p = new Policy();
            }
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

18 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

public Policy getEffectivePolicy(ServiceInfo si) {
    readDoreplacedent();
    Policy p = null;
    for (PolicyAttachment pa : attachments) {
        if (pa.appliesTo(si)) {
            if (p == null) {
                p = new Policy();
            }
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

18 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

public Policy getEffectivePolicy(BindingOperationInfo boi) {
    readDoreplacedent();
    Policy p = null;
    for (PolicyAttachment pa : attachments) {
        if (pa.appliesTo(boi)) {
            if (p == null) {
                p = new Policy();
            }
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

17 Source : PolicyUtil.java
with Apache License 2.0
from wso2

public static OMElement getEmptyPolicyAsOMElement() {
    ByteArrayInputStream bais = new ByteArrayInputStream(EMPTY_POLICY.getBytes());
    Policy policy = PolicyEngine.getPolicy(bais);
    return getPolicyAsOMElement(policy);
}

17 Source : EffectivePolicyImpl.java
with Eclipse Public License 1.0
from OpenLiberty

void initialiseInterceptors(PolicyInterceptorProviderRegistry reg, PolicyEngineImpl engine, Set<Interceptor<? extends org.apache.cxf.message.Message>> out, replacedertion a, boolean useIn, boolean fault) {
    QName qn = a.getName();
    List<Interceptor<? extends org.apache.cxf.message.Message>> i = null;
    if (useIn && !fault) {
        i = reg.getInInterceptorsForreplacedertion(qn);
    } else if (!useIn && !fault) {
        i = reg.getOutInterceptorsForreplacedertion(qn);
    } else if (useIn && fault) {
        i = reg.getInFaultInterceptorsForreplacedertion(qn);
    } else if (!useIn && fault) {
        i = reg.getOutFaultInterceptorsForreplacedertion(qn);
    }
    out.addAll(i);
    if (a instanceof PolicyContainingreplacedertion) {
        Policy p = ((PolicyContainingreplacedertion) a).getPolicy();
        if (p != null) {
            for (replacedertion a2 : getSupportedAlternatives(engine, p)) {
                initialiseInterceptors(reg, engine, out, a2, useIn, fault);
            }
        }
    }
}

17 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

Policy resolveReference(PolicyReference ref, Doreplacedent doc) {
    Policy p = null;
    if (isExternal(ref)) {
        p = resolveExternal(ref, doc.getBaseURI());
    } else {
        p = resolveLocal(ref, doc);
    }
    checkResolved(ref, p);
    return p;
}

16 Source : WSPolicyFeature.java
with Eclipse Public License 1.0
from OpenLiberty

Policy resolveReference(PolicyReference ref, PolicyBuilder builder, Bus bus, DescriptionInfo i) {
    Policy p = null;
    if (!ref.getURI().startsWith("#")) {
        String base = i == null ? null : i.getBaseURI();
        p = resolveExternal(ref, base, bus);
    } else {
        p = resolveLocal(ref, bus, i);
    }
    if (null == p) {
        throw new PolicyException(new Message("UNRESOLVED_POLICY_REFERENCE_EXC", BUNDLE, ref.getURI()));
    }
    return p;
}

16 Source : Wsdl11AttachmentPolicyProvider.java
with Eclipse Public License 1.0
from OpenLiberty

/**
 * The effective policy for a WSDL operation policy subject is calculated in relation to a
 * specific port, and includes the element policy of the wsdl11:portType/wsdl11:operation
 * element that defines the operation merged with that of the corresponding
 * wsdl11:binding/wsdl11:operation element.
 *
 * @param bi the BindingOperationInfo identifying the operation in relation to a port
 * @return the effective policy
 */
public Policy getEffectivePolicy(BindingOperationInfo bi) {
    DescriptionInfo di = bi.getBinding().getDescription();
    Policy p = getElementPolicy(bi, false, di);
    p = mergePolicies(p, getElementPolicy(bi.getOperationInfo(), false, di));
    return p;
}

16 Source : Wsdl11AttachmentPolicyProvider.java
with Eclipse Public License 1.0
from OpenLiberty

Policy resolveReference(PolicyReference ref, DescriptionInfo di) {
    Policy p = null;
    if (isExternal(ref)) {
        String uri = di.getBaseURI();
        if (uri == null) {
            uri = Integer.toString(di.hashCode());
        }
        p = resolveExternal(ref, uri);
    } else {
        p = resolveLocal(ref, di);
    }
    checkResolved(ref, p);
    return p;
}

16 Source : AssertionInfoMap.java
with Eclipse Public License 1.0
from OpenLiberty

private void putreplacedertionInfo(replacedertion a) {
    if (a instanceof PolicyContainingreplacedertion) {
        Policy p = ((PolicyContainingreplacedertion) a).getPolicy();
        if (p != null) {
            List<replacedertion> pcs = new ArrayList<replacedertion>();
            getreplacedertions(p, pcs);
            for (replacedertion na : pcs) {
                putreplacedertionInfo(na);
            }
        }
    }
    replacedertionInfo ai = new replacedertionInfo(a);
    Collection<replacedertionInfo> ail = get(a.getName());
    if (ail == null) {
        ail = new ArrayList<replacedertionInfo>();
        put(a.getName(), ail);
    }
    for (replacedertionInfo ai2 : ail) {
        if (ai2.getreplacedertion() == a) {
            return;
        }
    }
    ail.add(ai);
}

16 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(BindingMessageInfo bmi) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for BindingMessageInfo", bmi != null ? bmi.getMessageInfo() : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(bmi);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges BindingMessageInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

15 Source : EffectivePolicyImpl.java
with Eclipse Public License 1.0
from OpenLiberty

/**
 */
public clreplaced EffectivePolicyImpl implements EffectivePolicy {

    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(EffectivePolicyImpl.clreplaced);

    private static final Logger LOG = LogUtils.getL7dLogger(EffectivePolicyImpl.clreplaced);

    protected Policy policy;

    protected Collection<replacedertion> chosenAlternative;

    protected List<Interceptor<? extends org.apache.cxf.message.Message>> interceptors;

    public Policy getPolicy() {
        return policy;
    }

    public List<Interceptor<? extends org.apache.cxf.message.Message>> getInterceptors() {
        return interceptors;
    }

    public Collection<replacedertion> getChosenAlternative() {
        return chosenAlternative;
    }

    public void initialise(EndpointPolicyImpl epi, PolicyEngineImpl engine, boolean inbound) {
        initialise(epi, engine, inbound, false);
    }

    public void initialise(EndpointPolicyImpl epi, PolicyEngineImpl engine, boolean inbound, boolean fault) {
        policy = epi.getPolicy();
        chosenAlternative = epi.getChosenAlternative();
        if (chosenAlternative == null) {
            chooseAlternative(engine, null);
        }
        initialiseInterceptors(engine, inbound, fault);
    }

    public void initialise(EndpointInfo ei, BindingOperationInfo boi, PolicyEngineImpl engine, replacedertor replacedertor, boolean requestor, boolean request) {
        initialisePolicy(ei, boi, engine, requestor, request, replacedertor);
        chooseAlternative(engine, replacedertor);
        initialiseInterceptors(engine, false);
    }

    public void initialise(EndpointInfo ei, BindingOperationInfo boi, PolicyEngineImpl engine, replacedertor replacedertor, boolean requestor, boolean request, List<List<replacedertion>> incoming) {
        initialisePolicy(ei, boi, engine, requestor, request, replacedertor);
        chooseAlternative(engine, replacedertor, incoming);
        initialiseInterceptors(engine, false);
    }

    public void initialise(EndpointInfo ei, BindingOperationInfo boi, PolicyEngineImpl engine, boolean requestor, boolean request) {
        replacedertor replacedertor = initialisePolicy(ei, boi, engine, requestor, request, null);
        chooseAlternative(engine, replacedertor);
        initialiseInterceptors(engine, requestor);
    }

    public void initialise(EndpointInfo ei, BindingOperationInfo boi, BindingFaultInfo bfi, PolicyEngineImpl engine, replacedertor replacedertor) {
        initialisePolicy(ei, boi, bfi, engine);
        chooseAlternative(engine, replacedertor);
        initialiseInterceptors(engine, false);
    }

    private <T> T getreplacedertorAs(replacedertor as, Clreplaced<T> t) {
        if (t.isInstance(as)) {
            return t.cast(as);
        } else if (as instanceof PolicyUtils.Wrappedreplacedertor) {
            Object o = ((PolicyUtils.Wrappedreplacedertor) as).getWrappedreplacedertor();
            if (t.isInstance(o)) {
                return t.cast(o);
            }
        }
        return null;
    }

    replacedertor initialisePolicy(EndpointInfo ei, BindingOperationInfo boi, PolicyEngineImpl engine, boolean requestor, boolean request, replacedertor replacedertor) {
        if (boi.isUnwrapped()) {
            boi = boi.getUnwrappedOperation();
        }
        BindingMessageInfo bmi = request ? boi.getInput() : boi.getOutput();
        EndpointPolicy ep;
        if (requestor) {
            ep = engine.getClientEndpointPolicy(ei, getreplacedertorAs(replacedertor, Conduit.clreplaced));
        } else {
            ep = engine.getServerEndpointPolicy(ei, getreplacedertorAs(replacedertor, Destination.clreplaced));
        }
        policy = ep.getPolicy();
        if (ep instanceof EndpointPolicyImpl) {
            replacedertor = ((EndpointPolicyImpl) ep).getreplacedertor();
        }
        policy = policy.merge(engine.getAggregatedOperationPolicy(boi));
        if (null != bmi) {
            policy = policy.merge(engine.getAggregatedMessagePolicy(bmi));
        }
        policy = policy.normalize(engine.getRegistry(), true);
        return replacedertor;
    }

    void initialisePolicy(EndpointInfo ei, BindingOperationInfo boi, BindingFaultInfo bfi, PolicyEngineImpl engine) {
        policy = engine.getServerEndpointPolicy(ei, (Destination) null).getPolicy();
        policy = policy.merge(engine.getAggregatedOperationPolicy(boi));
        if (bfi != null) {
            policy = policy.merge(engine.getAggregatedFaultPolicy(bfi));
        }
        policy = policy.normalize(engine.getRegistry(), true);
    }

    void chooseAlternative(PolicyEngineImpl engine, replacedertor replacedertor) {
        chooseAlternative(engine, replacedertor, null);
    }

    void chooseAlternative(PolicyEngineImpl engine, replacedertor replacedertor, List<List<replacedertion>> incoming) {
        Collection<replacedertion> alternative = engine.getAlternativeSelector().selectAlternative(policy, engine, replacedertor, incoming);
        if (null == alternative) {
            PolicyUtils.logPolicy(LOG, Level.FINE, "No alternative supported.", getPolicy());
            throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
        } else {
            setChosenAlternative(alternative);
        }
    }

    void initialiseInterceptors(PolicyEngineImpl engine) {
        initialiseInterceptors(engine, false);
    }

    void initialiseInterceptors(PolicyEngineImpl engine, boolean useIn) {
        initialiseInterceptors(engine, useIn, false);
    }

    void initialiseInterceptors(PolicyEngineImpl engine, boolean useIn, boolean fault) {
        if (engine.getBus() != null) {
            PolicyInterceptorProviderRegistry reg = engine.getBus().getExtension(PolicyInterceptorProviderRegistry.clreplaced);
            Set<Interceptor<? extends org.apache.cxf.message.Message>> out = new LinkedHashSet<Interceptor<? extends org.apache.cxf.message.Message>>();
            for (replacedertion a : getChosenAlternative()) {
                initialiseInterceptors(reg, engine, out, a, useIn, fault);
            }
            setInterceptors(new ArrayList<Interceptor<? extends org.apache.cxf.message.Message>>(out));
        }
    }

    protected Collection<replacedertion> getSupportedAlternatives(PolicyEngineImpl engine, Policy p) {
        Collection<replacedertion> alternatives = new ArrayList<replacedertion>();
        for (Iterator<List<replacedertion>> it = p.getAlternatives(); it.hasNext(); ) {
            List<replacedertion> alternative = it.next();
            if (engine.supportsAlternative(alternative, null)) {
                alternatives.addAll(alternative);
            }
        }
        return alternatives;
    }

    void initialiseInterceptors(PolicyInterceptorProviderRegistry reg, PolicyEngineImpl engine, Set<Interceptor<? extends org.apache.cxf.message.Message>> out, replacedertion a, boolean useIn, boolean fault) {
        QName qn = a.getName();
        List<Interceptor<? extends org.apache.cxf.message.Message>> i = null;
        if (useIn && !fault) {
            i = reg.getInInterceptorsForreplacedertion(qn);
        } else if (!useIn && !fault) {
            i = reg.getOutInterceptorsForreplacedertion(qn);
        } else if (useIn && fault) {
            i = reg.getInFaultInterceptorsForreplacedertion(qn);
        } else if (!useIn && fault) {
            i = reg.getOutFaultInterceptorsForreplacedertion(qn);
        }
        out.addAll(i);
        if (a instanceof PolicyContainingreplacedertion) {
            Policy p = ((PolicyContainingreplacedertion) a).getPolicy();
            if (p != null) {
                for (replacedertion a2 : getSupportedAlternatives(engine, p)) {
                    initialiseInterceptors(reg, engine, out, a2, useIn, fault);
                }
            }
        }
    }

    // for tests
    void setPolicy(Policy ep) {
        policy = ep;
    }

    void setChosenAlternative(Collection<replacedertion> c) {
        chosenAlternative = c;
    }

    void setInterceptors(List<Interceptor<? extends org.apache.cxf.message.Message>> out) {
        interceptors = out;
    }
}

15 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(ServiceInfo si) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for ServiceInfo", si != null ? si.getName() : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(si);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges ServiceInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

15 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(EndpointInfo ei) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for EndpointInfo", ei != null ? ei : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(ei);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges EndpointInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

15 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(BindingOperationInfo boi) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for BindingOperationInfo", boi != null ? boi : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(boi);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges BindingOperationInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

15 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(BindingFaultInfo bfi) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for BindingFaultInfo", bfi != null ? bfi : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(bfi);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges BindingFaultInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

15 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for BindingMessageInfo", bmi != null ? bmi.getMessageInfo() : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(bmi);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges BindingMessageInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

14 Source : WSATPolicyOverrideInterceptor.java
with Eclipse Public License 1.0
from OpenLiberty

/*
     * (non-Javadoc)
     * 
     * @see org.apache.cxf.interceptor.Interceptor#handleMessage(org.apache.cxf.message.Message)
     */
@Override
public void handleMessage(Message msg) throws Fault {
    try {
        replacedertionInfoMap map = msg.get(replacedertionInfoMap.clreplaced);
        if (!remove && map.getreplacedertionInfo(Constants.AT_replacedERTION_QNAME).isEmpty()) {
            Policy p = generateWSATPolicy(msg);
            insertPolicy(msg, p, map);
        } else if (remove && !map.getreplacedertionInfo(Constants.AT_replacedERTION_QNAME).isEmpty()) {
            map.remove(Constants.AT_replacedERTION_QNAME);
        }
    } catch (Throwable e) {
        throw new Fault(e);
    }
}

14 Source : WSPolicyFeature.java
with Eclipse Public License 1.0
from OpenLiberty

protected Policy resolveExternal(PolicyReference ref, String baseURI, Bus bus) {
    PolicyBuilder builder = bus.getExtension(PolicyBuilder.clreplaced);
    ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
    PolicyRegistry registry = bus.getExtension(PolicyEngine.clreplaced).getRegistry();
    Policy resolved = registry.lookup(ref.getURI());
    if (null != resolved) {
        return resolved;
    }
    return resolver.resolveReference(ref.getURI());
}

14 Source : WSPolicyFeature.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public void initialize(Client client, Bus bus) {
    Endpoint endpoint = client.getEndpoint();
    Policy p = initializeEndpointPolicy(endpoint, bus);
    PolicyEngine pe = bus.getExtension(PolicyEngine.clreplaced);
    EndpointInfo ei = endpoint.getEndpointInfo();
    EndpointPolicy ep = pe.getClientEndpointPolicy(ei, null);
    pe.setClientEndpointPolicy(ei, ep.updatePolicy(p));
}

14 Source : WSPolicyFeature.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public void initialize(Server server, Bus bus) {
    Endpoint endpoint = server.getEndpoint();
    Policy p = initializeEndpointPolicy(endpoint, bus);
    PolicyEngine pe = bus.getExtension(PolicyEngine.clreplaced);
    EndpointInfo ei = endpoint.getEndpointInfo();
    EndpointPolicy ep = pe.getServerEndpointPolicy(ei, null);
    pe.setServerEndpointPolicy(ei, ep.updatePolicy(p));
    // Add policy to the service model (and consequently to the WSDL)
    ServiceModelPolicyUpdater pu = new ServiceModelPolicyUpdater(ei);
    for (PolicyProvider pp : ((PolicyEngineImpl) pe).getPolicyProviders()) {
        if (pp instanceof ExternalAttachmentProvider) {
            pu.addPolicyAttachments(((ExternalAttachmentProvider) pp).getAttachments());
        }
    }
}

14 Source : WSPolicyFeature.java
with Eclipse Public License 1.0
from OpenLiberty

private Policy initializeEndpointPolicy(Endpoint endpoint, Bus bus) {
    initialize(bus);
    DescriptionInfo i = endpoint.getEndpointInfo().getDescription();
    Collection<Policy> loadedPolicies = null;
    if (policyElements != null || policyReferenceElements != null) {
        loadedPolicies = new ArrayList<Policy>();
        PolicyBuilder builder = bus.getExtension(PolicyBuilder.clreplaced);
        if (null != policyElements) {
            for (Element e : policyElements) {
                loadedPolicies.add(builder.getPolicy(e));
            }
        }
        if (null != policyReferenceElements) {
            for (Element e : policyReferenceElements) {
                PolicyReference pr = builder.getPolicyReference(e);
                Policy resolved = resolveReference(pr, builder, bus, i);
                if (null != resolved) {
                    loadedPolicies.add(resolved);
                }
            }
        }
    }
    Policy thePolicy = new Policy();
    if (policies != null) {
        for (Policy p : policies) {
            thePolicy = thePolicy.merge(p);
        }
    }
    if (loadedPolicies != null) {
        for (Policy p : loadedPolicies) {
            thePolicy = thePolicy.merge(p);
        }
    }
    return thePolicy;
}

14 Source : ServiceModelPolicyUpdater.java
with Eclipse Public License 1.0
from OpenLiberty

private void addPolicy(Policy p) {
    try {
        W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
        p.serialize(writer);
        Element policyEl = writer.getDoreplacedent().getDoreplacedentElement();
        // Remove xmlns:xmlns attribute which Xerces chokes on
        policyEl.removeAttribute("xmlns:xmlns");
        UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
        uee.setElementType(new QName(Constants.URI_POLICY_13_NS, Constants.ELEM_POLICY));
        uee.setElement(policyEl);
        ei.getService().addExtensor(uee);
    } catch (XMLStreamException ex) {
        throw new RuntimeException("Could not serialize policy", ex);
    }
}

14 Source : EffectivePolicyImpl.java
with Eclipse Public License 1.0
from OpenLiberty

protected Collection<replacedertion> getSupportedAlternatives(PolicyEngineImpl engine, Policy p) {
    Collection<replacedertion> alternatives = new ArrayList<replacedertion>();
    for (Iterator<List<replacedertion>> it = p.getAlternatives(); it.hasNext(); ) {
        List<replacedertion> alternative = it.next();
        if (engine.supportsAlternative(alternative, null)) {
            alternatives.addAll(alternative);
        }
    }
    return alternatives;
}

14 Source : Wsdl11AttachmentPolicyProvider.java
with Eclipse Public License 1.0
from OpenLiberty

/**
 * The effective policy for a specific WSDL message (input or output) is calculated
 * in relation to a specific port, and includes the element policy of the wsdl:message
 * element that defines the message's type merged with the element policy of the
 * wsdl11:binding and wsdl11:portType message definitions that describe the message.
 * For example, the effective policy of a specific input message for a specific port
 * would be the (element policies of the) wsdl11:message element defining the message type,
 * the wsdl11:portType/wsdl11:operation/wsdl11:input element and the corresponding
 * wsdl11:binding/wsdl11:operation/wsdl11:input element for that message.
 *
 * @param bmi the BindingMessageInfo identifiying the message
 * @return the effective policy
 */
public Policy getEffectivePolicy(BindingMessageInfo bmi) {
    ServiceInfo si = bmi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bmi, false, di);
    MessageInfo mi = bmi.getMessageInfo();
    p = mergePolicies(p, getElementPolicy(mi, true, di));
    Extensible ex = getMessageTypeInfo(mi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}

14 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

Policy resolveLocal(PolicyReference ref, Doreplacedent doc) {
    String relativeURI = ref.getURI().substring(1);
    String absoluteURI = doc.getBaseURI() + ref.getURI();
    Policy resolved = registry.lookup(absoluteURI);
    if (null != resolved) {
        return resolved;
    }
    ReferenceResolver resolver = new LocalDoreplacedentReferenceResolver(doc, builder);
    resolved = resolver.resolveReference(relativeURI);
    if (null != resolved) {
        ref.setURI(absoluteURI);
        registry.register(absoluteURI, resolved);
    }
    return resolved;
}

14 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for BindingFaultInfo", bfi != null ? bfi : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(bfi);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges BindingFaultInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

14 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(ServiceInfo si, Message m) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for ServiceInfo", si != null ? si.getName() : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(si);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges ServiceInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

14 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(BindingOperationInfo boi, Message m) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for BindingOperationInfo", boi != null ? boi : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(boi);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges BindingOperationInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

14 Source : DynamicAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

@Override
public Policy getEffectivePolicy(EndpointInfo ei, Message m) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
        Tr.debug(tc, "getEffectivePolicy for EndpointInfo", ei != null ? ei : null);
    }
    readDoreplacedent();
    Policy p = new Policy();
    for (PolicyAttachment pa : attachments) {
        boolean merge = pa.appliesTo(ei);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "If merges EndpointInfo Policy by using this PolicyAttachment", pa.getPolicy().getAttributes(), merge);
        }
        if (merge) {
            p = p.merge(pa.getPolicy());
        }
    }
    return p;
}

13 Source : PolicyUtil.java
with Apache License 2.0
from wso2

public static String getPolicyreplacedtring(Policy policy) {
    ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
    try {
        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(outBuffer);
        policy.serialize(writer);
        writer.flush();
        ByteArrayInputStream bais = new ByteArrayInputStream(outBuffer.toByteArray());
        XMLPrettyPrinter xmlPrettyPrinter = new XMLPrettyPrinter(bais);
        return xmlPrettyPrinter.xmlFormat();
    } catch (XMLStreamException e) {
        throw new RuntimeException("Serialization of Policy object failed " + e);
    }
}

13 Source : WSATPolicyOverrideInterceptor.java
with Eclipse Public License 1.0
from OpenLiberty

private Policy generateWSATPolicy(Message msg) throws Throwable {
    Element policyElement;
    if (TC.isDebugEnabled()) {
        Tr.debug(TC, "Start to loadd policy from template", PATH);
    }
    InputStream is = this.getClreplaced().getResourcereplacedtream(PATH);
    if (is == null) {
        if (TC.isDebugEnabled()) {
            Tr.debug(TC, "InputStream is NULL??");
        }
        throw new RuntimeException("InputStream Object is null, not able to generate ws-at policy...");
    } else {
        policyElement = DOMUtils.readXml(is).getDoreplacedentElement();
        if (TC.isDebugEnabled()) {
            Tr.debug(TC, "Try getting policy element", policyElement);
        }
        PolicyBuilder builder = msg.getExchange().getBus().getExtension(PolicyBuilder.clreplaced);
        Policy wsatPolicy = builder.getPolicy(policyElement);
        if (TC.isDebugEnabled())
            Tr.debug(TC, "Try extract to policy object : ", wsatPolicy);
        return wsatPolicy;
    }
}

13 Source : WSPolicyFeature.java
with Eclipse Public License 1.0
from OpenLiberty

Policy resolveLocal(PolicyReference ref, final Bus bus, DescriptionInfo i) {
    String uri = ref.getURI().substring(1);
    String absoluteURI = i == null ? uri : i.getBaseURI() + uri;
    PolicyRegistry registry = bus.getExtension(PolicyEngine.clreplaced).getRegistry();
    Policy resolved = registry.lookup(absoluteURI);
    if (null != resolved) {
        return resolved;
    }
    ReferenceResolver resolver = new ReferenceResolver() {

        public Policy resolveReference(String uri) {
            PolicyBean pb = bus.getExtension(ConfiguredBeanLocator.clreplaced).getBeanOfType(uri, PolicyBean.clreplaced);
            if (null != pb) {
                PolicyBuilder builder = bus.getExtension(PolicyBuilder.clreplaced);
                return builder.getPolicy(pb.getElement());
            }
            return null;
        }
    };
    resolved = resolver.resolveReference(uri);
    if (null != resolved) {
        ref.setURI(absoluteURI);
        registry.register(absoluteURI, resolved);
    }
    return resolved;
}

13 Source : Wsdl11AttachmentPolicyProvider.java
with Eclipse Public License 1.0
from OpenLiberty

Policy resolveLocal(PolicyReference ref, DescriptionInfo di) {
    String uri = ref.getURI().substring(1);
    String absoluteURI = di.getBaseURI();
    if (absoluteURI == null) {
        absoluteURI = Integer.toString(di.hashCode()) + ref.getURI();
    } else {
        absoluteURI = absoluteURI + ref.getURI();
    }
    Policy resolved = registry.lookup(absoluteURI);
    if (null != resolved) {
        return resolved;
    }
    ReferenceResolver resolver = new LocalServiceModelReferenceResolver(di, builder);
    resolved = resolver.resolveReference(uri);
    if (null != resolved) {
        ref.setURI(absoluteURI);
        registry.register(absoluteURI, resolved);
    }
    return resolved;
}

12 Source : PolicyUtil.java
with Apache License 2.0
from wso2

public static OMElement getPolicyAsOMElement(Policy policy) {
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(baos);
        policy.serialize(writer);
        writer.flush();
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        XMLStreamReader xmlStreamReader = XMLInputFactory.newInstance().createXMLStreamReader(bais);
        StAXOMBuilder staxOMBuilder = (StAXOMBuilder) OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(), xmlStreamReader);
        return staxOMBuilder.getDoreplacedentElement();
    } catch (Exception ex) {
        throw new RuntimeException("can't convert the policy to an OMElement", ex);
    }
}

12 Source : AssertionInfoMap.java
with Eclipse Public License 1.0
from OpenLiberty

public boolean supportsAlternative(PolicyComponent replacedertion, List<QName> errors) {
    boolean preplaced = true;
    if (replacedertion instanceof Policyreplacedertion) {
        Policyreplacedertion a = (Policyreplacedertion) replacedertion;
        if (!a.isreplacederted(this) && !a.isOptional()) {
            errors.add(a.getName());
            preplaced = false;
        }
    } else if (replacedertion instanceof replacedertion) {
        replacedertion replaced = (replacedertion) replacedertion;
        Collection<replacedertionInfo> ail = getreplacedertionInfo(replaced.getName());
        boolean found = false;
        for (replacedertionInfo ai : ail) {
            if (ai.getreplacedertion().equal(replaced)) {
                found = true;
                if (!ai.isreplacederted() && !replaced.isOptional()) {
                    errors.add(replaced.getName());
                    preplaced = false;
                }
            }
        }
        if (!found) {
            errors.add(replaced.getName());
            return false;
        }
    }
    if (replacedertion instanceof PolicyContainingreplacedertion) {
        Policy p = ((PolicyContainingreplacedertion) replacedertion).getPolicy();
        if (p != null) {
            Iterator<List<replacedertion>> alternatives = p.getAlternatives();
            while (alternatives.hasNext()) {
                List<replacedertion> pc = alternatives.next();
                for (replacedertion p2 : pc) {
                    preplaced &= supportsAlternative(p2, errors);
                }
            }
        }
    }
    return preplaced;
}

12 Source : AssertionInfoMap.java
with Eclipse Public License 1.0
from OpenLiberty

public List<List<replacedertion>> checkEffectivePolicy(Policy policy) {
    List<List<replacedertion>> validated = new ArrayList<List<replacedertion>>(4);
    List<QName> errors = new ArrayList<QName>();
    Iterator<List<replacedertion>> alternatives = policy.getAlternatives();
    while (alternatives.hasNext()) {
        List<replacedertion> pc = alternatives.next();
        if (supportsAlternative(pc, errors)) {
            validated.add(pc);
        }
    }
    if (!validated.isEmpty()) {
        return validated;
    }
    Set<String> msgs = new LinkedHashSet<String>();
    for (QName name : errors) {
        Collection<replacedertionInfo> ais = getreplacedertionInfo(name);
        boolean found = false;
        for (replacedertionInfo ai : ais) {
            if (!ai.isreplacederted()) {
                String s = name.toString();
                if (ai.getErrorMessage() != null) {
                    s += ": " + ai.getErrorMessage();
                }
                msgs.add(s);
                found = true;
            }
        }
        if (!found) {
            msgs.add(name.toString());
        }
    }
    StringBuilder error = new StringBuilder();
    for (String msg : msgs) {
        error.append("\n").append(msg);
    }
    throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE, error.toString()));
}

11 Source : Wsdl11AttachmentPolicyProvider.java
with Eclipse Public License 1.0
from OpenLiberty

public Policy getEffectivePolicy(BindingFaultInfo bfi) {
    ServiceInfo si = bfi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bfi, false, di);
    FaultInfo fi = bfi.getFaultInfo();
    p = mergePolicies(p, getElementPolicy(fi, true, di));
    Extensible ex = getMessageTypeInfo(fi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}

10 Source : PolicyUtil.java
with Apache License 2.0
from wso2

public static String[] processPolicyElements(Iterator policyIterator, PolicyRegistry registry) {
    List<String> policyList = new ArrayList<String>();
    while (policyIterator.hasNext()) {
        Object value = policyIterator.next();
        if (value instanceof Policy) {
            Policy policy = (Policy) value;
            policyList.add(PolicyUtil.getPolicyreplacedtring(policy));
        } else if (value instanceof PolicyReference) {
            PolicyReference policyReference = (PolicyReference) value;
            Policy policy = registry.lookup(policyReference.getURI());
            if (policy == null) {
                throw new RuntimeException(policyReference.getURI() + " cannot be resolved");
            }
            policyList.add(PolicyUtil.getPolicyreplacedtring(policy));
        }
    }
    return policyList.toArray(new String[policyList.size()]);
}

10 Source : ExternalAttachmentProvider.java
with Eclipse Public License 1.0
from OpenLiberty

void readDoreplacedent() {
    if (null != attachments) {
        return;
    }
    // read the doreplacedent and build the attachments
    attachments = new ArrayList<PolicyAttachment>();
    Doreplacedent doc = null;
    try {
        InputStream is = location.getInputStream();
        if (null == is) {
            throw new PolicyException(new Message("COULD_NOT_OPEN_ATTACHMENT_DOC_EXC", BUNDLE, location));
        }
        doc = DOMUtils.readXml(is);
    } catch (Exception ex) {
        throw new PolicyException(ex);
    }
    for (Element ae : PolicyConstants.findAllPolicyElementsOfLocalName(doc, Constants.ELEM_POLICY_ATTACHMENT)) {
        PolicyAttachment attachment = new PolicyAttachment();
        for (Node nd = ae.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
            if (Node.ELEMENT_NODE != nd.getNodeType()) {
                continue;
            }
            QName qn = new QName(nd.getNamespaceURI(), nd.getLocalName());
            if (Constants.isAppliesToElem(qn)) {
                Collection<DomainExpression> des = readDomainExpressions((Element) nd);
                if (des.isEmpty()) {
                    // forget about this attachment
                    continue;
                }
                attachment.setDomainExpressions(des);
            } else if (Constants.isPolicyElement(qn)) {
                Policy p = builder.getPolicy(nd);
                if (null != attachment.getPolicy()) {
                    p = p.merge(attachment.getPolicy());
                }
                attachment.setPolicy(p);
            } else if (Constants.isPolicyRef(qn)) {
                PolicyReference ref = builder.getPolicyReference(nd);
                if (null != ref) {
                    Policy p = resolveReference(ref, doc);
                    if (null != attachment.getPolicy()) {
                        p = p.merge(attachment.getPolicy());
                    }
                    attachment.setPolicy(p);
                }
            }
        // TODO: wsse:Security child element
        }
        if (null == attachment.getPolicy() || null == attachment.getDomainExpressions()) {
            continue;
        }
        attachments.add(attachment);
    }
}

See More Examples