loadCASSession method
Fonction chargeant la session CAS si celle-ci existe prends les cookies à récupérer au sein du secureStorage Retourne vrai si session chargée correctement, faux sinon
Implementation
bool loadCASSession(List<(String,String,String)> keysToGet){
String debugHeader = loadCasSessionDebugHeader;
String errorMessage = "FALSE RETURN";
if (secureStorage == null){
logger("$debugHeader - $errorMessage : secure storage wasn't set");
return false;
}
if (!secureStorage!.getSecureStorageStatus()){
logger("$debugHeader - $errorMessage : secure storage exists but something hasn't loaded correctly");
return false;
}
String? stringSessionDate = secureStorage!.getValue("sessionDate");
if (stringSessionDate == null){
logger("$debugHeader - $errorMessage : Session date value was non-existent in secure storage");
return false;
}
else{
DateTime sessionDate = DateFormat("dd/MM/yyyy-HH:mm").parse(stringSessionDate!);
if (DateTime.now().difference(sessionDate).inMinutes > 30){
logger("$debugHeader - $errorMessage : Session date was too old");
return false;
}
}
keysToGet.add(("casCookie","TGC","https://cas.insa-cvl.fr/"));
for ((String,String,String) i in keysToGet){
String? value = secureStorage!.getValue(i[0]);
if (value == null){
logger("$debugHeader - $errorMessage : searched cookie didn't exist in storage");
return false;
}
cStore.Cookie newCookie = cStore.Cookie(
i[1]!,
value,
);
Uri websiteURI = Uri.parse(i[2]);
newCookie.path = websiteURI.path;
newCookie.domain = websiteURI.host;
session.cookieStore.cookies.add(newCookie);
}
return true;
}