Authentication: refactoring

This commit is contained in:
M66B 2021-07-18 14:57:41 +02:00
parent d98ad1b5ac
commit 0c30b92b9e
1 changed files with 20 additions and 18 deletions

View File

@ -1263,20 +1263,16 @@ public class MessageHelper {
// https://tools.ietf.org/html/rfc7601 // https://tools.ietf.org/html/rfc7601
Boolean result = null; Boolean result = null;
for (String header : headers) { for (String header : headers) {
String[] part = header.split(";"); String v = getKeyValues(header).get(type);
for (int i = 1; i < part.length; i++) { if (v == null)
String[] kv = part[i].split("="); continue;
if (kv.length > 1) { String[] val = v.split("\\s+");
String key = kv[0].trim(); if (val.length > 0) {
String[] val = kv[1].trim().split(" "); if ("fail".equals(val[0]))
if (val.length > 0 && type.equals(key)) { result = false;
if ("fail".equals(val[0])) else if ("pass".equals(val[0]))
result = false; if (result == null)
else if ("pass".equals(val[0])) result = true;
if (result == null)
result = true;
}
}
} }
} }
@ -3009,10 +3005,16 @@ public class MessageHelper {
String[] params = value.split(";"); String[] params = value.split(";");
for (String param : params) { for (String param : params) {
String[] kv = param.split("="); String k, v;
if (kv.length != 2) int eq = param.indexOf('=');
continue; if (eq < 0) {
values.put(kv[0].trim().toLowerCase(), kv[1].trim()); k = param.trim().toLowerCase(Locale.ROOT);
v = "";
} else {
k = param.substring(0, eq).trim().toLowerCase(Locale.ROOT);
v = param.substring(eq + 1).trim();
}
values.put(k, v);
} }
return values; return values;