VistALink v1.5.0.026

gov.va.med.vistalink.security
Class VistaKernelPrincipalImpl

java.lang.Object
  extended bygov.va.med.vistalink.security.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.5.0.026
Author:
Application Modernization - Foundations Team
See Also:
VistaKernelPrincipal, Serialized Form

Field Summary
 
Fields inherited from interface gov.va.med.vistalink.security.m.VistaKernelPrincipal
KEY_DIVISION_IEN, KEY_DIVISION_STATION_NAME, KEY_DIVISION_STATION_NUMBER, KEY_DOMAIN_NAME, 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, KEY_VPID
 
Method Summary
 VistaLinkConnection getAuthenticatedConnection()
          Retrieve the authenticated connection from this principal after logon.
static 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.
 java.lang.String toString()
          Rudimentary toString method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.va.med.vistalink.security.m.VistaKernelPrincipal
equals
 
Methods inherited from interface java.security.Principal
hashCode
 

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 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
Returns:
the concatenated class name, user name, division name and number, and timeout.

getKernelPrincipal

public static 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

VistALink v1.5.0.026

VistALink v1.5.0.026