ucSetLoginRole

Purpose

This exit is called following a successful sign on of a user.  It's primary purpose is to interface with remote systems that may be signing on a validated user from a remote system, and, following a successful sign on, to set the user's role to a value to be passed in from the remote system.

Applies To

Administration Methods

Signature

        public void ucSetLoginRole (SesameSession session, 
                                    Connection dbconn, 
                                    String userId) 
            throws Exception{}

Notes

Care should be taken when calling this method to ensure that the combination of User ID and User Role are valid for the user whose role is being set.

Example 

      public void ucSetLoginRole(SesameSession session, Connection dbconn, String userId) 
      throws Exception{
        boolean okayToSet = false;
        String setRole = "ADMIN"; // roll your own
        if (setRole.equals(Z.appDefaults.getAttribute("LIMITED_USER_ROLE"))) {
          okayToSet = true;
        }
        SecurityGroupUser sgu = null;
        if (!okayToSet) {
          try {
            sgu = SecurityGroupUser.getReference(setRole,
               userId,
               dbconn);
          } catch (Exception e) {}
          okayToSet = (sgu != null);
        }
        if (!okayToSet) {
          try {
            LicenseValidator lv = new LicenseValidator(dbconn, false);
            okayToSet = lv.getIsInfinite();
          } catch (Exception e) {
            ErrorWriter.write(e, ErrorWriter.LOG);
          }
        }
        if (okayToSet) {
          session.setAttribute("USER_ROLE", setRole);
          SecurityUser su = SecurityUser.getReference(dbconn, userId);
          if (su != null) {
            su.setConnection(dbconn);;
            su.setRole(setRole);
            su.executeTransaction(userId);
          }
        }      
      }