Search This Blog

Monday, September 21, 2015

How to get the username from BPEL code

I have an requirement where Composite-A (SAML1Call) call Calls Composite-B (SAML1)

I have created a new project , SAML1 with
oracle/wss11_saml_token_with_message_protection_service_policy
This is called from SAML1Call SOA composite

SAML1Call uses oracle/wss_username_token_service_policy for the inbound
and oracle/wss11_saml_token_with_message_protection_client_policy for calling
the SAML1 composite
 

We would like to get the UserName from BPEL code 


Please check the enhancment request
Bug 21247695 - Need extract currently logged in security user name in BPEL
easily


How to get the security header parameters in a BPEL process (Doc ID
2021281.1)

You need to copy the file jps-api.jar to your bpel project SCA-INF\lib
directory

for example ,

copy
D:\fmw1117\Middleware\oracle_common\modules\oracle.jps_11.1.1\jps-api.jar
C:\JDeveloper\mywork\test1\SAML1\SCA-INF\lib

define a bpel variable say CurrentLoggedInUser with XML type as string and
have the following java embeding activity

++
 javax.security.auth.Subject currentSubject =
oracle.security.jps.util.SubjectUtil.getCurrentSubject();
String   userName =
oracle.security.jps.util.SubjectUtil.getUserName(currentSubject);
System.out.println(" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ");
System.out.println(" In the SAML1 Composite "+userName);
System.out.println(" xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ");
setVariableData("CurrentLoggedInUser",userName);
++