code: public String getRealm() {
          if (UNDEFINED.equals(realm)) {
              Principal principal = securityIdentity.getPrincipal();
              String realm = null;
              if (principal instanceof RealmPrincipal) {
                  realm = ((RealmPrincipal)principal).getRealm();
              }
              this.realm = realm;
  
          }
  
          return this.realm;
      }
docs: Obtain the realm used for authentication.
  
  This realm name applies to both the user and the groups.
  
  @return The name of the realm used for authentication.