コード例 #1
0
  /**
   * Adds a mapping between an external application - username pair and a pentaho username.
   *
   * @param app The name of the external application.
   * @param externalUsername The external username.
   * @param pentahoUser The Pentaho username that is mapped to the pair {@code (app,
   *     externalUsername)}.
   */
  public void addMapping(String app, String externalUsername, String pentahoUser) {
    ApplicationMappings existentMapping = getApplicationsMap().get(app);
    if (existentMapping == null) {
      existentMapping = new ApplicationMappings(app);
      getApplicationsMap().put(app, existentMapping);
    }

    existentMapping.getUsernamesMap().put(externalUsername, pentahoUser);
  }
コード例 #2
0
  @Override
  public String getUsername(String externalApplicationName, String externalUsername) {
    ApplicationMappings existentMapping = getApplicationsMap().get(externalApplicationName);
    if (existentMapping == null) {
      throw new MappingNotFoundException(
          "Application named '"
              + externalApplicationName
              + "' is not present in the current mappings");
    }

    String pentahoUsername = existentMapping.getUsernamesMap().get(externalUsername);
    if (pentahoUsername == null) {
      throw new MappingNotFoundException(
          "External username '"
              + externalUsername
              + "' not found in the mappings for application '"
              + externalApplicationName
              + "'");
    }

    return pentahoUsername;
  }