protected boolean validate(final ServiceInstance serviceInstance) { if (serviceInstance == null || serviceInstance.getSessionManager() == null) { return false; } else { return serviceInstance.getSessionManager().getCurrentSession() != null; } }
protected boolean validate(final ServiceInstance serviceInstance) { if (serviceInstance == null || serviceInstance.getSessionManager() == null) { return false; } else { return serviceInstance.getSessionManager().getCurrentSession() != null; } }
/** * Disconnect from the server and clean up */ public void logout() { if(vimService!=null) { try { serviceInstance.getSessionManager().logout(); } catch (Exception e) { System.err.println("Failed to disconnect..."); } vimService =null; serviceInstance = null; } }
public static ServiceInstance createServiceInstance() throws RemoteException, MalformedURLException { ServiceInstance si = new ServiceInstance(new URL("https://10.141.72.223/sdk"), "root", "vmware", true); si.getSessionManager().setLocale("zh-CN"); // set locale for the content of all API result. return si; }
public static void main(String[] args) throws Exception { String session = "vmware_soap_session=\"5229c547-1342-47d1-e830-223d99a47fba\""; ServiceInstance si = new ServiceInstance(new URL("https://10.17.218.174/sdk"), session , true); UserSession userSession = si.getSessionManager().getCurrentSession(); System.out.println("username=" + userSession.getUserName()); System.out.println("fullname=" + userSession.getFullName()); }
public static void main(String[] args) throws Exception { String session = "vmware_soap_session=\"5229c547-1342-47d1-e830-223d99a47fba\""; ServiceInstance si = new ServiceInstance(new URL("https://10.17.218.174/sdk"), session , true); UserSession userSession = si.getSessionManager().getCurrentSession(); System.out.println("username=" + userSession.getUserName()); System.out.println("fullname=" + userSession.getFullName()); }
public ServiceInstance(URL url, String username, String password, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || username==null) { throw new NullPointerException("None of url, username can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); vimService.getWsc().setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); vimService.getWsc().setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION setServerConnection(new ServerConnection(url, vimService, this)); UserSession userSession = getSessionManager().login(username, password, null); getServerConnection().setUserSession(userSession); }
public ServiceInstance(URL url, String sessionStr, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || sessionStr ==null) { throw new NullPointerException("None of url, session string can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); WSClient wsc = vimService.getWsc(); wsc.setCookie(sessionStr); wsc.setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); wsc.setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); setServerConnection(new ServerConnection(url, vimService, this)); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION UserSession userSession = (UserSession) getSessionManager().getCurrentProperty("currentSession"); getServerConnection().setUserSession(userSession); }
String ticket = oldsi.getSessionManager().acquireCloneTicket(); newsc.setServiceInstance(newsi); UserSession userSession = newsi.getSessionManager().cloneSession(ticket); newsc.setUserSession(userSession); return newsi;