VLJ Iteration II, v. 1.0.0.193

gov.va.med.foundations.security.vistalink
Class VistaKernelPrincipalImpl

java.lang.Object
  |
  +--gov.va.med.foundations.security.vistalink.VistaKernelPrincipalImpl
All Implemented Interfaces:
java.security.Principal, java.io.Serializable, VistaKernelPrincipal

public final class VistaKernelPrincipalImpl
extends java.lang.Object
implements java.io.Serializable, VistaKernelPrincipal

A JAAS principal representing a logged on Kernel user on an M system.

Retrieving the principal after login

Upon a successful JAAS login, one or more principals may be contained in the JAAS subject that is returned from a successful JAAS login (only one *Kernel* principal should be returned, however. The situation in which multiple principals could be returned is if some kind of compound logon has been set up that requires several logons to complete, for example one to Kernel, and one to a separate health data repository). The VistaKernelPrincipal interface is a marker you can use to identify a "VistaKernelPrincipal" as one of those principals. However, an easier approach is to use the helper method getKernelPrincipal in VistaKernelPrincipalImpl to directly retrieve the single VistaKernelPrincipal. For example:

 String cfgName = "RpcSampleServer";
 
 // create the callback handler
 CallbackHandlerSwing cbhSwing = new CallbackHandlerSwing(myFrame);
 
 // create the LoginContext
 loginContext = new LoginContext(cfgName, cbhSwing);
 
 // login to server
 loginContext.login(); 
 
 // get principal
 userPrincipal = VistaKernelPrincipalImpl.getKernelPrincipal(loginContext.getSubject());
 

Retrieving the authenticated connection from the principal

To execute RPCs, you'll need to retrieve the authenticated connection. Once a successful login has been completed, you can retrieve the associated authenticated connection from the Kernel principal. For example:

 VistaLinkConnection myConnection = userPrincipal.getAuthenticatedConnection(); 
 RpcRequest vReq = RpcRequestFactory.getRpcRequest(rpcContext, "XOB VL TEST PING"); 
 RpcResponse vResp = myConnection.executeRPC(vReq);
 

Retrieving Demographics

You can use the KEY* field strings to retrieve user demographics values via the getUserDemographicValue method. For example:

 private VistaKernelPrincipalImpl userPrincipal;
 
 // left out: perform a login... then the subject in the logincontext is populated 

 // get the Kernel principal after successful login 
 userPrincipal = VistaKernelPrincipalImpl.getKernelPrincipal(loginContext.getSubject()); 
 
 // get user demographics
 String duz = this.userPrincipal.getUserDemographicValue(VistaKernelPrincipalImpl.KEY_DUZ);
 String name = userPrincipal.getUserDemographicValue(VistaKernelPrincipalImpl.KEY_NAME_DISPLAY);
 

Version:
1.0.0.193
Author:
Application Modernization - Foundations Team
See Also:
VistaKernelPrincipal, Serialized Form

Field Summary
 
Fields inherited from interface gov.va.med.foundations.security.vistalink.VistaKernelPrincipal
KEY_DIVISION_IEN, KEY_DIVISION_STATION_NAME, KEY_DIVISION_STATION_NUMBER, KEY_DTIME, KEY_DUZ, KEY_LANGUAGE, KEY_NAME_DEGREE, KEY_NAME_DISPLAY, KEY_NAME_FAMILYLAST, KEY_NAME_GIVENFIRST, KEY_NAME_MIDDLE, KEY_NAME_NEWPERSON01, KEY_NAME_PREFIX, KEY_NAME_SUFFIX, KEY_SERVICE_SECTION, KEY_TITLE
 
Method Summary
 boolean equals(java.lang.Object o)
          Returns whether some object equals this one.
 gov.va.med.foundations.adapter.cci.VistaLinkConnection getAuthenticatedConnection()
          Retrieve the authenticated connection from this principal after logon.
static gov.va.med.foundations.security.vistalink.VistaKernelPrincipalImpl getKernelPrincipal(javax.security.auth.Subject jaasSubject)
          Returns the single Kernel principal contained in a JAAS subject returned by a JAAS LoginContext after a successful VistaLink logon to Vista.
 java.lang.String getName()
          get the Principal's full name from the New Person .01 field.
 java.lang.String getUserDemographicValue(java.lang.String key)
          returns a given user demographic value.
 int hashCode()
          Compute the hash code for this VistaKernelPrincipalImpl object.
 java.lang.String toString()
          Rudimentary toString method.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
get the Principal's full name from the New Person .01 field.

Specified by:
getName in interface VistaKernelPrincipal
Returns:
the user name (from the New Person .01 field) of the Principal.
See Also:
Principal.getName()

getAuthenticatedConnection

public gov.va.med.foundations.adapter.cci.VistaLinkConnection getAuthenticatedConnection()
Retrieve the authenticated connection from this principal after logon.

Returns:
VistaLinkConnection the authenticated Vista connection, post-successful logon.

getUserDemographicValue

public java.lang.String getUserDemographicValue(java.lang.String key)
Description copied from interface: VistaKernelPrincipal
returns a given user demographic value. Use the various KEY* field strings to retrieve various values.

Specified by:
getUserDemographicValue in interface VistaKernelPrincipal
Parameters:
key - The key under which the demographic value is stored
Returns:
String the value of the demographic value requests
See Also:
VistaKernelPrincipal.getUserDemographicValue(String)

toString

public java.lang.String toString()
Rudimentary toString method.

Specified by:
toString in interface VistaKernelPrincipal
Overrides:
toString in class java.lang.Object
Returns:
the concatenated class name, user name, division name and number, and timeout.
See Also:
Principal.toString()

equals

public boolean equals(java.lang.Object o)
Returns whether some object equals this one. Because of the nature of a principal and an authenticated connection, we never can call two principals "equal" unless the object reference is to the same object. Otherwise its unfathomable whether the two connections held by the principals are "equal". So false is returned in all instances except where the object references are to the same object.

Specified by:
equals in interface VistaKernelPrincipal
Overrides:
equals in class java.lang.Object
Parameters:
o - object to compare.
Returns:
true if the object references are the same (the only recognized 'equality' for thie object type) false if not.
See Also:
Principal.equals(Object)

hashCode

public int hashCode()
Compute the hash code for this VistaKernelPrincipalImpl object.

Specified by:
hashCode in interface java.security.Principal
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

getKernelPrincipal

public static gov.va.med.foundations.security.vistalink.VistaKernelPrincipalImpl getKernelPrincipal(javax.security.auth.Subject jaasSubject)
                                                                                             throws FoundationsException
Returns the single Kernel principal contained in a JAAS subject returned by a JAAS LoginContext after a successful VistaLink logon to Vista.

Parameters:
jaasSubject - JAAS subject returned by a JAAS LoginContext after a successful VistaLink logon to Vista.
Returns:
VistaKernelPrincipalImpl Kernel principal contained in the JAAS subject
Throws:
FoundationsException - If no Kernel principal, or more than one, are found, an exception is thrown

VLJ Iteration II, v. 1.0.0.193

VistaLink Iteration II, v. 1.0.0.193