I've attached a roughly equivalent for use with Neethi 3.
On Thursday, September 01, 2011 10:25:29 AM yahya benkaouz wrote:
> Hello all,
>
> In my school project, I have to use neethi package in order to define some
> policies. And i have started to on some examples.
> One of them is avalaible on the following website:
> http://www.ibm.com/developerworks/webservices/tutorials/ws-understand-web-se
> rvices5/section5.html
>
> The question is when i launched this program with the version neethi1.0.1,
> it works well. However with the version 3.0.1. It doesn't work it seems that
> org.apache.ws.policy is not used in this version. Please, i want to know
> how can i do something similar to the program above using neethi 3.0.1
>
> Best regards,
> Yahya
--
Daniel Kulp
[email protected]
http://dankulp.com/blog
Talend - http://www.talend.com
package test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyBuilder;
import org.apache.neethi.PolicyRegistryImpl;
public class PolicyUtility {
static PolicyBuilder reader = new PolicyBuilder();
static {
reader.setPolicyRegistry(new PolicyRegistryImpl());
}
public static void main(String argsv[]){
Policy normalize1 = readPolicy("normalize1.xml");
Policy normalize2 = readPolicy("normalize2.xml");
reader.getPolicyRegistry().register("myPolicy", normalize2);
normalize1 = (Policy)normalize1.normalize(true);
writePolicy(normalize1, "normalize_output.xml");
Policy merge1 = readPolicy("merge1.xml");
Policy merge2 = readPolicy("merge2.xml");
merge1 = (Policy)merge1.merge(merge2).normalize(true);
writePolicy(merge1, "merge_output.xml");
Policy intersect1 = readPolicy("intersect1.xml");
Policy intersect2 = readPolicy("intersect2.xml");
intersect1 = (Policy)intersect1.merge(intersect2);
writePolicy(intersect1, "intersect_output.xml");
System.out.println("exiting...");
}
public static Policy readPolicy(String file){
Policy policy = null;
try{
FileInputStream fis = new FileInputStream(file);
policy = reader.getPolicy(fis);
} catch(Exception e) {
System.out.println("Exception occured: " + e);
e.printStackTrace();
}
return policy;
}
public static void writePolicy(Policy w, String file){
try{
FileOutputStream fos = new FileOutputStream(file);
XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fos);
w.serialize(writer);
writer.close();
} catch(Exception e) {
System.out.println("Exception occured: " + e);
e.printStackTrace();
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]