To supplement my previous blog post, you might be wondering how to see the user in the subject of a running bpel process? Well you can always use external software like TCP Monitor, fiddler, etc to analyze the http traffic and extract the user in the subject. There is another simple way to do this during development time using bpelx:exec activity.
As you might be knowing that there is a Java Embedding activity which can be used to execute java code fragments in a bpel process. There are a number of other useful things you can do with bpelx:exec activity. One of them is using it to print the principle in the subject in the soa log. Just drag and drop the Java Embedding activity into the bpel process and copy paste the below code into it and you are done.
java.security.AccessControlContext acc = java.security.AccessController.getContext();
javax.security.auth.Subject subject = javax.security.auth.Subject.getSubject(acc);
System.out.println("*******************************************");
System.out.println("#####USER NAME IN THE SUBJECT : " + subject.toString());
System.out.println("*******************************************");
javax.security.auth.Subject subject = javax.security.auth.Subject.getSubject(acc);
System.out.println("*******************************************");
System.out.println("#####USER NAME IN THE SUBJECT : " + subject.toString());
System.out.println("*******************************************");
This will result in addition of the bpelx:exec into your bpel process code as shown below:
<bpelx:exec name="Java_Embedding1" version="1.5" language="java">
<![CDATA[/*Write your java code below e.g.
System.out.println("Hello, World");
*/
java.security.AccessControlContext acc = java.security.AccessController.getContext();
javax.security.auth.Subject subject = javax.security.auth.Subject.getSubject(acc);
System.out.println("*******************************************");
System.out.println("#####USER NAME IN THE SUBJECT : " + subject.toString());
System.out.println("*******************************************");]]>
</bpelx:exec>
As you might have noticed we need to use the complete package name along with the class inside the bpelx:exec as there is no provision to import libraries here.
No comments:
Post a Comment