All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.xml.ws.security.impl.policyconv.RequiredElementsProcessor Maven / Gradle / Ivy

There is a newer version: 4.0.4
Show newest version
/*
 * Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package com.sun.xml.ws.security.impl.policyconv;

import com.sun.xml.ws.security.policy.RequiredElements;
import com.sun.xml.wss.impl.policy.PolicyGenerationException;
import com.sun.xml.wss.impl.policy.mls.MandatoryTargetPolicy;
import com.sun.xml.wss.impl.policy.mls.MessagePolicy;
import com.sun.xml.wss.impl.policy.mls.Target;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

/**
 *
 * @author [email protected]
 */
public class RequiredElementsProcessor {

    private List assertionList;
    private MessagePolicy mp;
    /** Creates a new instance of RequiredElementProcessor */
    public RequiredElementsProcessor(List al,MessagePolicy mp) {
        this.assertionList = al;
        this.mp = mp;
    }

    public void process() throws PolicyGenerationException{
        Vector targetValues = new Vector<>();
        MandatoryTargetPolicy mt = new MandatoryTargetPolicy();
        MandatoryTargetPolicy.FeatureBinding mfb = new MandatoryTargetPolicy.FeatureBinding();
        mt.setFeatureBinding(mfb);
        List targets = mfb.getTargetBindings();
        for(RequiredElements re : assertionList){
            Iterator itr = re.getTargets();
            while(itr.hasNext()){
                String xpathExpr = (String)itr.next();
                if(!targetValues.contains(xpathExpr)){
                    targetValues.add(xpathExpr);
                    Target tr = new Target();
                    tr.setType(Target.TARGET_TYPE_VALUE_XPATH);
                    tr.setValue(xpathExpr);
                    tr.setContentOnly(false);
                    tr.setEnforce(true);
                    targets.add(tr);
                }
            }
        }
       mp.append(mt);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy