From 3ac75b680483910c5e7ad5b702973c52cbff54ef Mon Sep 17 00:00:00 2001 From: Hans Keeler Date: Wed, 29 Mar 2017 16:21:07 -0400 Subject: [PATCH] Refactor to new externalId format in inst search - Replace externalId code-to-name lookup with externalIdType.name in registration template - General cleanup of registration template - Refactor backend validation to use new format --- .../authenticator/hmda/ExternalId.java | 15 +++++--- .../authenticator/hmda/ExternalIdType.java | 37 +++++++++++++++++++ .../hmda/HmdaValidInstitutionsFormAction.java | 2 - keycloak/themes/hmda/login/register.ftl | 17 +++------ 4 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalIdType.java diff --git a/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalId.java b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalId.java index ac0d23a..86e4632 100644 --- a/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalId.java +++ b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalId.java @@ -7,15 +7,18 @@ */ public class ExternalId { - private String name; + private ExternalIdType externalIdType; private String value; - public String getName() { - return name; + public ExternalId() { } - public void setName(String name) { - this.name = name; + public ExternalIdType getExternalIdType() { + return externalIdType; + } + + public void setExternalIdType(ExternalIdType externalIdType) { + this.externalIdType = externalIdType; } public String getValue() { @@ -29,7 +32,7 @@ public void setValue(String value) { @Override public String toString() { return "ExternalId{" + - "name='" + name + '\'' + + "externalIdType=" + externalIdType + ", value='" + value + '\'' + '}'; } diff --git a/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalIdType.java b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalIdType.java new file mode 100644 index 0000000..804a972 --- /dev/null +++ b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/ExternalIdType.java @@ -0,0 +1,37 @@ +package gov.cfpb.keycloak.authenticator.hmda; + +/** + * Created by keelerh on 3/29/17. + */ +public class ExternalIdType { + + private String code; + private String name; + + public ExternalIdType() { + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "ExternalIdType{" + + "code='" + code + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java index 72ae2b0..c2f4b5a 100644 --- a/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java +++ b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java @@ -41,8 +41,6 @@ public void validate(ValidationContext context) { MultivaluedMap formData = context.getHttpRequest().getDecodedFormParameters(); List errors = new ArrayList<>(); - logger.info("Form data: " + formData); - // Get email field. If not populated, there is no point in proceeding. The email field check is // already checked by core Keycloak, so there's no need for a dupe context.error() here. String emailFieldVal = formData.getFirst(RegistrationPage.FIELD_EMAIL); diff --git a/keycloak/themes/hmda/login/register.ftl b/keycloak/themes/hmda/login/register.ftl index 825329b..bdcd4af 100644 --- a/keycloak/themes/hmda/login/register.ftl +++ b/keycloak/themes/hmda/login/register.ftl @@ -72,27 +72,20 @@