Commit b0a0e2eb authored by michael.simon's avatar michael.simon
Browse files

change cookie value for idp/op preselection

Back to only number style. To be downwards compatible.
parent 8e7d10ad
...@@ -168,36 +168,24 @@ public class DiscoveryLoginBean implements Serializable { ...@@ -168,36 +168,24 @@ public class DiscoveryLoginBean implements Serializable {
Cookie idpCookie = cookieHelper.getCookie("preselect_idp"); Cookie idpCookie = cookieHelper.getCookie("preselect_idp");
if (idpCookie != null) { if (idpCookie != null) {
String cookieValue = idpCookie.getValue(); String cookieValue = idpCookie.getValue();
cookieValue = cookieValue.replaceAll("[^0-9]", "");
if (cookieValue.startsWith("i_")) {
Long idpId = Long.parseLong(cookieValue.substring(2)); Long idpId = Long.parseLong(cookieValue);
SamlIdpMetadataEntity idp = idpService.findById(idpId); SamlIdpMetadataEntity idp = idpService.findById(idpId);
if (idp != null) { if (idp != null) {
selectedIdp = idp; selectedIdp = idp;
storeIdpSelection = true; storeIdpSelection = true;
preSelectedIdp = true; preSelectedIdp = true;
PrimeFaces.current().focus("quicklogin"); PrimeFaces.current().focus("quicklogin");
}
} }
else if (cookieValue.startsWith("o_")) { else {
Long opId = Long.parseLong(cookieValue.substring(2)); OidcRpConfigurationEntity op = oidcRpService.findById(idpId);
OidcRpConfigurationEntity op = oidcRpService.findById(opId);
if (op != null) { if (op != null) {
selectedIdp = op; selectedIdp = op;
storeIdpSelection = true; storeIdpSelection = true;
preSelectedIdp = true; preSelectedIdp = true;
PrimeFaces.current().focus("quicklogin"); PrimeFaces.current().focus("quicklogin");
} }
}
else if (cookieValue.matches("^[0-9]{1,}$")) {
Long idpId = Long.parseLong(cookieValue);
SamlIdpMetadataEntity idp = idpService.findById(idpId);
if (idp != null) {
selectedIdp = idp;
storeIdpSelection = true;
preSelectedIdp = true;
PrimeFaces.current().focus("quicklogin");
}
} }
} }
initialized = true; initialized = true;
...@@ -223,7 +211,7 @@ public class DiscoveryLoginBean implements Serializable { ...@@ -223,7 +211,7 @@ public class DiscoveryLoginBean implements Serializable {
sessionManager.setSpId(spConfig.getId()); sessionManager.setSpId(spConfig.getId());
sessionManager.setIdpId(idp.getId()); sessionManager.setIdpId(idp.getId());
if (storeIdpSelection != null && storeIdpSelection) { if (storeIdpSelection != null && storeIdpSelection) {
cookieHelper.setCookie("preselect_idp", "i_" + idp.getId().toString(), 356 * 24 * 3600); cookieHelper.setCookie("preselect_idp", idp.getId().toString(), 356 * 24 * 3600);
} }
else { else {
cookieHelper.setCookie("preselect_idp", "", 0); cookieHelper.setCookie("preselect_idp", "", 0);
...@@ -240,7 +228,7 @@ public class DiscoveryLoginBean implements Serializable { ...@@ -240,7 +228,7 @@ public class DiscoveryLoginBean implements Serializable {
sessionManager.setOidcRelyingPartyId(rp.getId()); sessionManager.setOidcRelyingPartyId(rp.getId());
if (storeIdpSelection != null && storeIdpSelection) { if (storeIdpSelection != null && storeIdpSelection) {
cookieHelper.setCookie("preselect_idp", "o_" + rp.getId().toString(), 356 * 24 * 3600); cookieHelper.setCookie("preselect_idp", rp.getId().toString(), 356 * 24 * 3600);
} }
else { else {
cookieHelper.setCookie("preselect_idp", "", 0); cookieHelper.setCookie("preselect_idp", "", 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment