Home /Modules/wifi/SLWifiCredentials.sleela

SLWifiCredentials.sleela

lib/wifi/SLWifiCredentials.sleela · 122 line(s) · sleela

<< lib/wifi/SLWifiCredentials.sleela
   One-attempt authentication request. Prefer an OS profile/credential vault.
   SLeeLa Strings are immutable values here; clear() drops references but cannot
   guarantee memory erasure. The native C API has a secure-zero helper for buffers. >>
#sleela 2.5
material;
class SLWifiCredentials {
  < ---- 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 = 11438;
  String metaAuthor = "Max Rupplin vs. Dr. Mrs. Elisabeth Harkins";
  String metaDate = "2026-10-20";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | International | Galactic >
  String metaOrigin = "International";
  String metaBirthDate = "2026-10-20";
  < 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; }
  static final int OS_MANAGED = 0;
  static final int SAVED_PROFILE = 1;
  static final int PASSPHRASE = 2;
  static final int ENTERPRISE_PASSWORD = 3;

  int mode;
  String profileName;
  String username;
  String password;
  String caCertificateFile;
  String expectedServerName;

  void configureOSManaged() {
    mode = OS_MANAGED;
    clearFields();
  }

  void configureSavedProfile(String name) {
    mode = SAVED_PROFILE;
    profileName = name;
    username = "";
    password = "";
    caCertificateFile = "";
    expectedServerName = "";
  }

  void configurePassphrase(String passphrase) {
    mode = PASSPHRASE;
    profileName = "";
    username = "";
    password = passphrase;
    caCertificateFile = "";
    expectedServerName = "";
  }

  void configureEnterprise(String user, String secret, String caFile, String serverName) {
    mode = ENTERPRISE_PASSWORD;
    profileName = "";
    username = user;
    password = secret;
    caCertificateFile = caFile;
    expectedServerName = serverName;
  }

  boolean isValid() {
    if (mode == OS_MANAGED) { return true; }
    if (mode == SAVED_PROFILE) { return profileName != null && profileName != ""; }
    if (mode == PASSPHRASE) { return password != null && password != ""; }
    if (mode == ENTERPRISE_PASSWORD) {
      return username != null && username != "" && password != null && password != "" &&
             caCertificateFile != null && caCertificateFile != "" &&
             expectedServerName != null && expectedServerName != "";
    }
    return false;
  }

  void clearFields() {
    profileName = "";
    username = "";
    password = "";
    caCertificateFile = "";
    expectedServerName = "";
  }

  void clear() {
    clearFields();
    mode = OS_MANAGED;
  }

  boolean prefersOSAuthentication() {
    return mode == OS_MANAGED || mode == SAVED_PROFILE;
  }
}