Login to Oracle Enterprise Manager Console (http://<hostname>:7001/em).
Expand WebLogic Domain, right click on the name of your domain, go to Security, and then click on Credentials.
You can read keys to existing map or create a new map with new keys. Each key can store credentials. For this example I am using existing map "oracle.wsm.security" and key "OIMAdmin".
Use Case: Read Credential from the Credentials Store in Java Embedding.
Use below code in Java Embedding to read xelsysadm credential and get OIM Client handle.
To execute below code you have to add following jars in <Application_Name><Project_Name>\SCA-INF\lib:
- jps-api.jar
- jps-manifest.jar
- oimclient.jar
String username = null, password = null;
String t3url = "t3://<hostname>:<port>"; //OIM host name and port
String credentialStoreProvider = "oracle.wsm.security"; //Map name
String OIMAdminName = "OIMAdmin"; //Key name
try {
//read xelsysadm credential from credential store
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(credentialStoreProvider,OIMAdminName);
if (cred != null) {
username = cred.getName();
password = String.valueOf(cred.getPassword());
} else {
System.out.println("Credential not found");
}
System.out.println("Username : " + username);
System.out.println("Password : " + password);
//get OIMClient Handle
java.util.Hashtable env = new java.util.Hashtable();
env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
env.put(oracle.iam.platform.OIMClient.JAVA_NAMING_PROVIDER_URL,t3url);
oracle.iam.platform.OIMClient client = new oracle.iam.platform.OIMClient(env);
client.login(username, password.toCharArray());
System.out.println("Connected, OIMClient Handle : " + client);
} catch (Exception e) {
e.printStackTrace();
}
Happy Learning!!!
while doing this, I'm getting
ReplyDelete.tracking.SCAEntityId: 40029] [composite_name: ThreeStageTrainingPrj!1.0] [FlowId: 0000MffaOWp7Y7J6ynmZMG1Su5Na000002] An error occurred while trying to notify server that a new login session has been created.[[
Any idea
Hi Anand,
ReplyDeleteI have placed all my neccessary jars with jpsconfig.xml file also getting different errors with noclassdeffound so placed those jars also. Still getting below error. Im trying to fetch credentials from MAP to my local machine.
xception in thread "main" java.lang.NoSuchMethodError: oracle.security.crypto.util.OIDManager.getProperty(Loracle/security/crypto/asn1/ASN1ObjectID;Ljava/lang/String;)Ljava/lang/String;
at oracle.security.crypto.cert.X509Extension.inputInstance(Unknown Source)
at oracle.security.crypto.cert.X509ExtensionSet.input(Unknown Source)
at oracle.security.crypto.cert.X509ExtensionSet.(Unknown Source)
at oracle.security.crypto.cert.X509.input(Unknown Source)
at oracle.security.crypto.cert.X509.(Unknown Source)
at oracle.security.crypto.cert.X509.(Unknown Source)
at oracle.security.pki.OracleWallet.l(OracleWallet)
at oracle.security.pki.OracleWallet.createSSO(OracleWallet)
at oracle.security.jps.internal.credstore.ssp.CsfWalletManager.createWallet(CsfWalletManager.java:210)
at oracle.security.jps.internal.credstore.ssp.SspCredentialStore.
Getting this error when this code is tried.....
ReplyDeleteException in thread "main" java.lang.ExceptionInInitializerError
at oracle.security.jps.JpsContextFactory$1.run(JpsContextFactory.java:77)
at oracle.security.jps.JpsContextFactory$1.run(JpsContextFactory.java:69)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.JpsContextFactory.getContextFactory(JpsContextFactory.java:68)
at CredRetrieve.main(CredRetrieve.java:18)
Caused by: java.util.MissingResourceException: Can't find oracle.security.jps.internal.common.resources.common.CommonResources bundle
at java.util.logging.Logger.setupResourceInfo(Logger.java:1945)
at java.util.logging.Logger.(Logger.java:380)
at java.util.logging.LogManager.demandLogger(LogManager.java:554)
at java.util.logging.Logger.demandLogger(Logger.java:455)
at java.util.logging.Logger.getLogger(Logger.java:553)
at oracle.security.jps.util.JpsLogger.getLogger(JpsLogger.java:187)
at oracle.security.jps.util.JpsUtil.(JpsUtil.java:183)