Forum Stats

  • 3,759,893 Users
  • 2,251,611 Discussions
  • 7,870,858 Comments

Discussions

Manage Password in bpm process or bpel

Mipi
Mipi Member Posts: 36 Red Ribbon

Hi all,

I need create a BPEL service witch need call a REST service.

The Rest Service required authentication in input .

My proplem is password field , How I manage the password without include password in the code?

Can I use an eis or similar as it is used for DB connections with DBAdapter?

Thanks,

M.

Tagged:
Mipi

Best Answer

«13

Answers

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited May 23, 2019 8:11AM Accepted Answer

    Hi,

    You can use the Credential Store Frame work for that. Then using a java snippet in an Embedded Java activity you can fetch it: https://dzone.com/articles/get-credential-store-framework-key-inside-soa-comp

    Regards,
    Martien

    MipiMipi
  • Mipi
    Mipi Member Posts: 36 Red Ribbon
    edited May 23, 2019 11:32AM

    Thanks, I will try!

  • Mipi
    Mipi Member Posts: 36 Red Ribbon
    edited May 24, 2019 4:44AM

    I have try this solution but when restart the soa the configuration is missing.

    All nights SOA is restarted. I will thing use properties file in oracle path,

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited May 24, 2019 5:43AM

    That is strange: it should store it in the database.

    Mipi
  • Mipi
    Mipi Member Posts: 36 Red Ribbon
    edited May 24, 2019 9:55AM

    sorry, my error

    thanks for all

  • Mipi
    Mipi Member Posts: 36 Red Ribbon
    edited Jun 4, 2019 4:51AM

    Hi I have try this solutions, but now I have a problem:

    1) Deploy Jar : OK

    2) Test KO

    When test the service, return follow error:

    java.security.AccessControlException: access denied (oracle.security.jps.service.credstore.CredentialAccessPermission context=SYSTEM,mapName=##..

    In file jazn-data file was already present in configurations.

    Thanks for support.

    M.

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Jun 4, 2019 5:55AM

    Could show a bit more on what you did, how you configered it, your BPEL process, how you tested it and what happens?

    Regards,
    Martien

  • Mipi
    Mipi Member Posts: 36 Red Ribbon
    edited Jun 4, 2019 6:26AM

    Yes (sorry for my english),

    I have create a BPEL, in bpel file I have import my Class (because past code directly on th java Embedding palete, I received error in deploy phase), I have add import in also

    <import location="oracle.soa.management.facade.ComponentInstance"

    importType="http://schemas.oracle.com/bpel/extension/java"/>

        <import location="oracle.soa.management.facade.LocatorFactory"

                importType="http://schemas.oracle.com/bpel/extension/java"/>

        <import location="oracle.soa.management.facade.Composite"

    importType="http://schemas.oracle.com/bpel/extension/java"/>

        <import location="oracle.soa.management.facade.LocatorFactory"

                importType="http://schemas.oracle.com/bpel/extension/java"/>

        <import location="oracle.soa.management.facade.Locator"

    importType="http://schemas.oracle.com/bpel/extension/java"/>

    (not used in java Embedding).

    My java Class is :

    package xxx.yyy;

    import oracle.soa.management.facade.Locator;

    import oracle.soa.management.facade.LocatorFactory;

    import oracle.soa.management.facade.Composite;

    import oracle.soa.management.facade.LocatorFactory;

    import oracle.soa.management.facade.ComponentInstance;

    public class SecurityRetrieve {

        public SecurityRetrieve() {

            super();

        }

        public static String getCredential(String mode) {

            String result = "";

            try {

    oracle.security.jps.JpsContextFactory jpsCtxFactory =

    oracle.security.jps.JpsContextFactory.getContextFactory();

                oracle.security.jps.JpsContext jpsCtx = jpsCtxFactory.getContext();

    oracle.security.jps.service.credstore.CredentialStore credStore =

    jpsCtx.getServiceInstance(oracle.security.jps.service.credstore.CredentialStore.class);

    oracle.security.jps.service.credstore.PasswordCredential cred =

    (oracle.security.jps.service.credstore.PasswordCredential)credStore.getCredential("OAM_STORE",

                                                                                                      "KeystorePassword");

                if (cred == null) {

                    result = "Credential not found.";

    System.out.println("Credential not found.");

                } else {

                    if (mode.equalsIgnoreCase("User")) {

                        result = getUser(cred);

                    }else{

                        result = getPwd(cred);

                    }

                   

                }

               

            } catch (Exception e) {

                e.printStackTrace();

                return e.toString();

            }

            return result;

        }

        private static String getUser(oracle.security.jps.service.credstore.PasswordCredential cred) {

            String user = "";

            //user = cred.getName();

            user="Michele";

            return user;

        }

       

        private static String getPwd(oracle.security.jps.service.credstore.PasswordCredential cred) {

            String pwd = "";

            //pwd = String.valueOf(cred.getPassword());

            pwd="Pass";

            return pwd;

        }

    }

    And in java embedding

    try {   

                  XMLElement modeX = (XMLElement) getVariableData("inputVariable", "payload", "/client:process/client:mode");

                  String mode = modeX.getTextContent();   

                  XMLElement jobNameX = (XMLElement) getVariableData("inputVariable", "payload", "/client:process/client:jobName");

                  String jobName = jobNameX.getTextContent();   

                  String json="";   

            String user =""; 

            String pwd ="";  

       

                  user =xxx.yyy.SecurityRetrieve.getCredential("User");   

                  pwd =xxx.yyy.SecurityRetrieve.getCredential("Password");   

     

    json="{\"actionName\":\"getTaskIdByName\",\"authPass\":\""+pwd+"\",\"authUser\":\""+user+"\",\"mode\":\""+mode+"\",\"taskName\":\""+jobName+"\"}";   

        oracle.soa.common.util.Base64Encoder encoder = new oracle.soa.common.util.Base64Encoder();     

         

    String encodedString = null;      

    encodedString = encoder.encode(json);      

    setVariableData("base64EncodedJson",encodedString);    

    setVariableData("base64EncodedJson",json);  

    }   

    catch (Exception e){   

                  e.printStackTrace();    

                  addAuditTrailEntry(e);   

    }

  • Martien van den Akker
    Martien van den Akker Member Posts: 2,776 Bronze Crown
    edited Jun 4, 2019 7:23AM

    Hi Michele,

    In your class you now hard code your user name/password. You somehow tested those values are correct?

    I see that you build up your string like 'json="{\"actionName\":\"getTaskIdByName\",\"authPass\":\""+pwd+"\",\"authUser\":\""+user+"\",\"mode\":\""+mode+"\",\"taskName\":\""+jobName+"\"}";  ' and then b64 encode it.

    What do you do with it and why is it build up like this?

    At what point do you get your error?

    Have you tried the invocation of the service for which you do this using SoapUI or Postman?

    Regards,

    Martien

  • Mipi
    Mipi Member Posts: 36 Red Ribbon
    edited Jun 4, 2019 4:15PM

    Hi, i call my service with soapui and my service call by http with json in base64 other service.

    I thinks the problem Is in

    oracle.security.jps.service.credstore.PasswordCredential cred =

    (oracle.security.jps.service.credstore.PasswordCredential)credStore.getCredential("map","Key");

    Becouse if I add this code directly in Java embendding I Have problem i  deploy phase .

    Yes I have add user and password  in code for test but return always some error :

    java.security.AccessControlException: access denied (oracle.security.jps.service.credstore.CredentialAccessPermission context=SYSTEM,mapName=External-System,keyName=xxx read)

    Thanks,

    Mipi