Getting the User Name of the Logged In User

In the TIBCO Enterprise Administrator, when a currently logged in user invokes an operation on the product through its Agent, the name of the logged in user who is invoking this operation can be made available to the Agent.

This can be done by adding a parameter whose type is com.tibco.tea.agent.api.TeaPrincipal. No TeaParam annotation is needed for this method parameter. In the method code, the getName() method of the TeaPrincipal class can be invoked to get the name of the user who invoked the operation.

Procedure

  • Pass the TeaPrincipal as a parameter in the uploadFile method:
    @TeaOperation(name = "upload", description = "Upload File")
    public void uploadFile(
    @TeaParam(name = "filepath", description = "File to Upload")
    final DataSource fileDataSource, TeaPrincipal teaPrincipal)
    throws IOException
    { String userName = teaPrincipal.getName(); ... }