0 Replies Latest reply on Jan 7, 2016 9:22 AM by jacekgra RSS
    jacekgra Apprentice

    Custom Authenticator - get User object in order to set User Extenstions properties

    Hi, I am working on custom authenticator and I would like to store some auth key (from external system) in given user extension property directly in Authenticator code.

     

    In normal service I can use following code:

     

    User user = (User) EntityUtilities.findEntity("Jacek", RelationshipTypes.ThingworxRelationshipTypes.User);
    user.setPropertyValue("lastName", new StringPrimitive("Gralak"));


    And this works great. However when I am using the same piece of code after fire of successful login event in authenticator User object is null (EntityUtiilites are not able to retrieve user object):

     

    AuthenticationUtilities.validateEnabledThingworxUser(USERNAME);


    this.setCredentials(USERNAME);
    AuthenticationUtilities.getSecurityMonitorThing().fireSuccessfulLoginEvent(USERNAME,SharedConstants.EMPTY_STRING);

    User user = (User) EntityUtilities.findEntity(USERNAME, RelationshipTypes.ThingworxRelationshipTypes.User);
    user.setPropertyValue("lastName", new StringPrimitive("authentiocator"));


     

    Here user object is null.

    Any hints?