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()); }
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; } }
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 boolean isRefreshRequired(RefreshingServiceInstance si) { try { si.currentTime(); Calendar cal = si.getSessionManager().getCurrentSession().getLoginTime(); long loginTime = cal.getTimeInMillis(); long age = System.currentTimeMillis() - loginTime; if (age > TimeUnit.MINUTES.toMillis(15)) { return true; } } catch (Exception e) { // if the currentTime() call is rejected our session token is likely // expired return true; } return false; }