简体   繁体   中英

Need to get the weblogic server username and password at runtime

My application is deployed in weblogic server. From within my application I am invoking a secured rest service using the HttpURLConnection. In order to invoke the rest service securely, I need to pass the weblogic username and password. How do I get the weblogic username and password from within my java code?

You need to create a weblogic "context" and set the username/password in your app if you are a client. Server side, a local context is used:

weblogic.jndi.Environment environment = new weblogic.jndi.Environment();
environment.setInitialContextFactory(weblogic.jndi.Environment.DEFAULT_INITIAL_CONTEXT_FACTORY);
environment.setProviderURL(“t3://myhost:7001”);
environment.setSecurityPrincipal(“weblogic”);
environment.setSecurityCrendentials(“weblogic1”);
InitialContext ctx = environment.getInitialContext();

You can get the username/pass from the boot.properties in your <domain>/servers/<server name>/security folder.

You can also get the username/pass by manipulating the embedded LDAP within Weblogic. Please see:

Initial Context Factory

Setting Up JNDI

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM