code: protected String getSecurityName(String loginName, String urAuthenticatedId) throws EntryNotFoundException, RegistryException {
  
          UserRegistry ur = getUserRegistry();
          if (ur != null && ur.getType() != "CUSTOM") { // Preserve the existing behavior for CUSTOM user registries
              String securityName = ur.getUserSecurityName(urAuthenticatedId);
              if (securityName != null) {
                  return securityName;
              }
          }
  
          // If a loginName was provided, use it.
          if (loginName != null) {
              return loginName;
          }
  
          if (ur != null) {
              return ur.getUserSecurityName(urAuthenticatedId);
          } else {
              throw new NullPointerException("No user registry");
          }
      }
docs: Common method called by all login modules that use the UserRegistry (UsernameAndPasswordLoginModule,
  CertificateLoginModule, HashtableLoginModule and TokenLoginModule). Determines the securityName to use
  for the login.
  
  @param loginName The username passed to the login
  @param urAuthenticatedId The id returned by UserRegistry checkPassword or mapCertificate.
  
  @return The securityName to use for the WSPrincipal.
  
  @throws EntryNotFoundException
  @throws RegistryException