示例#1
0
  /**
   * Allows an external component to connect to the local server with the specified configuration.
   *
   * @param configuration the configuration for the external component.
   */
  public static void allowAccess(ExternalComponentConfiguration configuration) {

    // Remove any previous configuration for this external component

    deleteConfiguration(configuration.getSubdomain());

    // Update the database with the new granted permission and configuration

    configuration.setPermission(Permission.allowed);

    addConfiguration(configuration);
  }
示例#2
0
  /** Adds a new permission for the specified external component. */
  private static void addConfiguration(ExternalComponentConfiguration configuration) {

    // Remove the permission for the entity from the database

    java.sql.Connection con = null;

    PreparedStatement pstmt = null;

    try {

      con = DbConnectionManager.getConnection();

      pstmt = con.prepareStatement(ADD_CONFIGURATION);

      pstmt.setString(1, configuration.getSubdomain());

      pstmt.setString(2, configuration.getSecret());

      pstmt.setString(3, configuration.getPermission().toString());

      pstmt.executeUpdate();

    } catch (SQLException sqle) {

      Log.error(sqle);

    } finally {

      try {
        if (pstmt != null) pstmt.close();
      } catch (Exception e) {
        Log.error(e);
      }

      try {
        if (con != null) con.close();
      } catch (Exception e) {
        Log.error(e);
      }
    }
  }