OIMClient API / OIMConnection API

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
package com.massiveGaze.connection;

import java.util.Hashtable;
import java.util.Properties;
import javax.security.auth.login.LoginException;
import oracle.iam.platform.OIMClient;
import com.properties.OIMProfileReader;
import com.thortech.xl.util.LocalConfiguration;

public class OIMConnection {
 private static String ctxFactory = null;
 private static String serverURL = null;
 private static String appServerType = null;
 private static OIMClient connectionObject = null;
 private static OIMProfileReader properties=null;
 
 private static String username = "xelsysadm";
 private static String password = "Welcome1"; 
 
 
 private static OIMClient connection() {
               
  System.out.println("Startup...");
  System.out.println("Getting configuration...");  
  //getProperties();
  //setSystemProperties();
  OIMClient localConnection = new OIMClient(getEnvironment());
  try {
   localConnection.login(username, password.toCharArray());
  } catch (LoginException e) {
   e.printStackTrace();
  }

  Properties props = LocalConfiguration.getLocalCoreServerConfiguration();
  System.out.println(props.toString());
  return localConnection;
 }

 public static synchronized OIMClient getConnection() {

  if (connectionObject == null) {
   connectionObject = connection();
  }
  return connectionObject;
 }
 
 public static void closeConnection() {
  connectionObject.logout();
 }
 
 public static Hashtable<String, String> getEnvironment(){
  getProperties();
  setSystemProperties();
  Hashtable<String, String> env = new Hashtable<String, String>();
  env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, serverURL);
  env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, ctxFactory);
  return env;
 }
 
 public static void getProperties(){
        properties = new OIMProfileReader();
  appServerType=properties.getString("appserver.type");
  serverURL=properties.getString("oim.jndi.url");
  ctxFactory=properties.getString("bpelprovider.initial.factory"); 
  System.out.println(" serverURL -> "+serverURL);
 }
 
 public static void setSystemProperties(){

  //Update path of authwl.conf file according to your environment  
  System.setProperty("java.security.auth.login.config","config/authwl.conf");
 
  
        System.setProperty("OIM.AppServerType", appServerType);
        System.setProperty("APPSERVER_TYPE", appServerType);
        System.setProperty("XL.HomeDir","");
        // SSL Port connection    http://oimreferences.blogspot.in/2013/07/oim-java-api-to-connect-oim-ssl-port.html
        /*
        System.setProperty("javax.net.ssl.trustStoreType","JKS");
        System.setProperty("javax.net.ssl.trustStore","C:/Program Files (x86)/Java/jre1.7.0_45/lib/security/cacerts");
        System.setProperty("javax.net.ssl.trustStorePassword","changeit");
        */
        // SSL Port connection
 }
 
 public static void main(String args[]){
  getConnection();
       // closeConnection();
   }
}

No comments:

Post a Comment

About OIM

Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...

Popular Posts