Hi All
Currently I am working on the VWC plugin using Flex - Java Service. Currently I can get the UserSession of VWC as mentioned in the link Re: get current user name on vsphere web client
Thanks to laurentsd.
But now I want to Get/Set some information in that UserSession so that i can pass it to Flex whenever it is updated. Thus i can make sure that Status is unique across differ UserSessions.
Broswer 1 -> Flex -> Java (Get UserSession) -> Set Status in Session -> Send the status to Flex
Broswer 2 -> Flex -> Java (Get UserSession) -> Set Status in Session -> Send the status to Flex
Kindly Help me.
The UserSession object is available in Flex through UserSessionManager:
var userSession:UserSession = UserSessionManager.instance.userSession;
This is a read-only object, you are not supposed to modify it. If you need to pass information back to the UI layer you can use your own object and service.
Thanks Laurentsd for the reply.
In my scenario, I have to keep/maintain some information in java service, which will be sent to Flex frequently [Based on the logged in credentials]. If the user is logging in with different browser with different credentials then how can I make sure that the Object information is unique across different session. Do i have to maintain any global Dictionary<sessionkeyid, Object> in order to track the Object for each session or is there any workaround for it.?
Kindly revert back.
The way you can track a unique object for each user session is indeed to have a map where the key the UserSession.clientId. That field is guaranteed to be unique for each user session. And you can dispose of the session's object by implementing the interface ClientSessionEndListener. The platform calls sessionEnded(clientId) to notify listeners about the session ending for that clientId.
Thanks Laurentsd.
I can check with clientid but I want to get the "Session Key ID" from userSession which should have below format
Session Key Format : 5200f69d-9081-c778-2282-05ef73bed6a3
this.userSession = this.userSessionService.getUserSession();
String sCookie = this.userSession.ServerInfo()[0].sessionCookie;
This sCookie also in same format but it is different.
Please help me to get Session Key ID from UserSession.
The "Session key id" for userSession you are talking about is called clientId. This is the unique id representing a Web Client user session and the only way to do what you need. The format doesn't matter.
Hi laurentsd...
I have one issue here. I have two VCenter in one SSO. So when ever i login to any VCenter, it shows both vcenter servers. Now the problem is with my following code in Java.
UserSession userSession = this._userSessionService.getUserSession();
ServerInfo sinfo = userSession.serversInfo[0];
With this, it is having "Server Information" as Array. How to identify which "vcenter" is currently logged in.? Based on that, I can get the appropriate "Server information" in that Array.
You are logged-in the SSO and not to a particular vCenter Server. Why do you need this?
Both vCenter servers showing up in the array are being used.
If you want to match a particular object in your data adapter with a vCenter server follow the example in samples/vsphereviews/vsphere-wssdk-provider/src/main/java/com/vmware/samples/wssdkprovider/VmDataProviderImpl.java.
If you want more information on a vCenter server you need to use the vSphere API.
No.. I have not logged in SSO. I have logged in vCenter server only.
For eg:
I have two vCenter servers named vc1(192.0.0.1) and vc2(192.0.0.2). And both vCenters are connected in Single SSO.
Now I am login in 192.0.0.1, But i am able to see both vCenters there. Sames goes when i login with 192.0.0.2.
But when i write the code, I am not able to find in which vCenter i have logged in currently.
Hi Lauren,
In that VmDataProviderImpl.java. example, they just always get the first server information and processing as I did.. They didnt check what is the current logged in vCenter system.
For eg:
I have two vCenter servers named vc1(192.0.0.1) and vc2(192.0.0.2). And both vCenters are connected in Single SSO.
Now I am login in 192.0.0.1, But i am able to see both vCenters there. Sames goes when i login with 192.0.0.2.
But when i write the code, I am not able to find in which vCenter i have logged in currently.
You didn't understand what Peter was saying. When you login to the Web Client you are actually connecting to the SSO server first, and that server tells the Web Client which vCenter servers are available. In your case there are vCenter servers connected. So you are logged in to both!
You need to explain your use case in more details, i.e. where in your plugin code do you need to know which vCenter server is involved?
- Either you already have a reference to some vsphere object and you can find out the vCenter server where that object belong
- Or you want the user to take some global action and you need to provide a UI for selecting the vCenter server target.