Home /Modules/http-4.0/Http40Negotiation.sleela

Http40Negotiation.sleela

lib/http-4.0/Http40Negotiation.sleela · 77 line(s) · sleela

#sleela 2.5
material;
<< SLeeLa generation negotiation is distinct from IETF HTTP/3 negotiation.
   authenticatedOffer is only a caller-supplied policy signal; it is not itself
   a cryptographic transcript proof. The native authenticated carrier must bind
   both offers and the selected profile before dispatch. >>
class Http40Negotiation {
  < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
  << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader,
     or catalog can read and (where appropriate) override this record.
     Values are faithful to the subject's real origin where publicly known. >>
  String metaVersion = "1.0.0";
  int metaId = 11496;
  String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins";
  String metaDate = "2026-10-21";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-21";
  < metaScienceRating: maturity/robustness on a 1..10 scale >
  int metaScienceRating = 9;
  < metaNationalSchedule: a real, citable instrument or "none" >
  String metaNationalSchedule = "none";

  String getMetaVersion() { return metaVersion; }
  void setMetaVersion(String v) { metaVersion = v; }
  int getMetaId() { return metaId; }
  void setMetaId(int v) { metaId = v; }
  String getAuthor() { return metaAuthor; }
  void setAuthor(String v) { metaAuthor = v; }
  String getDate() { return metaDate; }
  void setDate(String v) { metaDate = v; }
  String getCopyright() { return metaCopyright; }
  void setCopyright(String v) { metaCopyright = v; }
  String getTrademark() { return metaTrademark; }
  void setTrademark(String v) { metaTrademark = v; }
  String getCorporation() { return metaCorporation; }
  void setCorporation(String v) { metaCorporation = v; }
  String getOrigin() { return metaOrigin; }
  void setOrigin(String v) { metaOrigin = v; }
  String getBirthDate() { return metaBirthDate; }
  void setBirthDate(String v) { metaBirthDate = v; }
  int getScienceRating() { return metaScienceRating; }
  void setScienceRating(int v) { metaScienceRating = v; }
  String getNationalSchedule() { return metaNationalSchedule; }
  void setNationalSchedule(String v) { metaNationalSchedule = v; }
  int localCapabilities = 1;
  int peerCapabilities = 1;
  int selectedLevel = 0;
  int peerGeneration = 3;
  boolean authenticatedOffer = false;
  boolean completed = false;
  < Fail closed by default; callers must explicitly authorize legacy fallback. >
  boolean allowLegacy = false;
  void setCapabilities(int localValue, int peerValue) {
    localCapabilities = localValue; peerCapabilities = peerValue;
  }
  void setPeerGeneration(int value) { peerGeneration = value; }
  void authenticateOffer(boolean value) { authenticatedOffer = value; }
  int negotiate() {
    int common = localCapabilities & peerCapabilities;
    if (!authenticatedOffer || peerGeneration < 1 || peerGeneration > 4) {
      selectedLevel = 0; completed = false; return 0;
    }
    if (peerGeneration == 4 && (common & 8) != 0) selectedLevel = 4;
    else if (allowLegacy && peerGeneration >= 3 && (common & 4) != 0) selectedLevel = 3;
    else if (allowLegacy && peerGeneration >= 2 && (common & 2) != 0) selectedLevel = 2;
    else if (allowLegacy && (common & 1) != 0) selectedLevel = 1;
    else selectedLevel = 0;
    completed = selectedLevel > 0; return selectedLevel;
  }
  boolean isComplete() { return completed; }
  boolean selectedHttp40() { return completed && selectedLevel == 4 && peerGeneration == 4; }
}