diff --git a/api/src/main/java/com/okta/idx/sdk/api/client/AuthenticationTransaction.java b/api/src/main/java/com/okta/idx/sdk/api/client/AuthenticationTransaction.java index d7ef120ba..29b387cfb 100644 --- a/api/src/main/java/com/okta/idx/sdk/api/client/AuthenticationTransaction.java +++ b/api/src/main/java/com/okta/idx/sdk/api/client/AuthenticationTransaction.java @@ -17,6 +17,7 @@ import com.okta.commons.http.Response; import com.okta.commons.lang.Assert; +import com.okta.commons.lang.Strings; import com.okta.idx.sdk.api.exception.ProcessingException; import com.okta.idx.sdk.api.model.AuthenticationStatus; import com.okta.idx.sdk.api.model.CurrentAuthenticatorEnrollment; @@ -309,7 +310,13 @@ private static void copyErrorMessages(IDXResponse idxResponse, AuthenticationRes return; } Arrays.stream(idxResponse.getMessages().getValue()) - .forEach(msg -> authenticationResponse.addError(msg.getMessage())); + .forEach(msg -> { + String message = msg.getMessage(); + if (msg.getI18NMessage() != null && Strings.hasText(msg.getI18NMessage().getKey())) { + message += ", " + msg.getI18NMessage(); + } + authenticationResponse.addError(message); + }); } private void fillOutAuthenticators(AuthenticationResponse authenticationResponse) { diff --git a/api/src/main/java/com/okta/idx/sdk/api/model/I18NMessage.java b/api/src/main/java/com/okta/idx/sdk/api/model/I18NMessage.java new file mode 100644 index 000000000..ebdf0d0b0 --- /dev/null +++ b/api/src/main/java/com/okta/idx/sdk/api/model/I18NMessage.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2023-Present, Okta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.okta.idx.sdk.api.model; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; + +import java.util.List; + +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) +public class I18NMessage { + + private String key; + + private List params; + + public String getKey() { + return key; + } + + public List getParams() { + return params; + } + + @Override + public String toString() { + return "key='" + key + '\'' + ", params=" + params; + } +} diff --git a/api/src/main/java/com/okta/idx/sdk/api/model/MessageValue.java b/api/src/main/java/com/okta/idx/sdk/api/model/MessageValue.java index b1e79b3d5..acef568ef 100644 --- a/api/src/main/java/com/okta/idx/sdk/api/model/MessageValue.java +++ b/api/src/main/java/com/okta/idx/sdk/api/model/MessageValue.java @@ -23,6 +23,8 @@ public class MessageValue { private String message; + @JsonAlias("i18n") + private I18NMessage i18NMessage; @JsonAlias("class") private String value; @@ -30,7 +32,18 @@ public String getMessage() { return message; } + public I18NMessage getI18NMessage() { + return i18NMessage; + } + public String getValue() { return value; } + + @Override + public String toString() { + return "message='" + message + '\'' + + ", i18n=" + i18NMessage + + ", value='" + value + '\''; + } } diff --git a/api/src/test/groovy/com/okta/idx/sdk/api/client/IDXAuthenticationWrapperTest.groovy b/api/src/test/groovy/com/okta/idx/sdk/api/client/IDXAuthenticationWrapperTest.groovy index 80c4e49aa..20ac9953a 100644 --- a/api/src/test/groovy/com/okta/idx/sdk/api/client/IDXAuthenticationWrapperTest.groovy +++ b/api/src/test/groovy/com/okta/idx/sdk/api/client/IDXAuthenticationWrapperTest.groovy @@ -689,7 +689,8 @@ class IDXAuthenticationWrapperTest { new AuthenticationOptions("mary@unknown.com", "superSecret".toCharArray()), beginResponse.proceedContext ) assertThat(authenticationResponse, notNullValue()) - assertThat(authenticationResponse.getErrors(), hasItem("There is no account with the Username mary@unknown.com.")) + assertThat(authenticationResponse.getErrors(), + hasItem("There is no account with the Username mary@unknown.com., key='idx.unknown.user', params=[]")) assertThat(authenticationResponse.getAuthenticationStatus(), is(AuthenticationStatus.UNKNOWN) ) @@ -877,7 +878,8 @@ class IDXAuthenticationWrapperTest { new AuthenticationOptions("Mary@unknown.com", "superSecret".toCharArray()), beginResponse.proceedContext ) assertThat(authenticationResponse, notNullValue()) - assertThat(authenticationResponse.getErrors(), hasItem("There is no account with the Username Mary@unknown.com.")) + assertThat(authenticationResponse.getErrors(), + hasItem("There is no account with the Username Mary@unknown.com., key='idx.unknown.user', params=[]")) assertThat(authenticationResponse.getAuthenticators(), nullValue()) } diff --git a/pom.xml b/pom.xml index 5cc9f82d2..4380aeeea 100644 --- a/pom.xml +++ b/pom.xml @@ -36,8 +36,8 @@ 2.15.2 2.0 - 1.3.1 - 3.0.3 + 1.3.4 + 3.0.4 9.0.76 1.6.10 okta/okta-idx-java @@ -252,6 +252,7 @@ org.owasp dependency-check-maven + 8.3.1 false diff --git a/samples/embedded-sign-in-widget/pom.xml b/samples/embedded-sign-in-widget/pom.xml index 5ec5c9d11..0cb363f76 100644 --- a/samples/embedded-sign-in-widget/pom.xml +++ b/samples/embedded-sign-in-widget/pom.xml @@ -92,7 +92,7 @@ com.nimbusds nimbus-jose-jwt - 9.19 + 9.30.2 diff --git a/samples/pom.xml b/samples/pom.xml index db176ec66..ce2e19ad3 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -25,7 +25,6 @@ okta-idx-java-samples - com.okta.idx.sdk Okta IDX Java SDK :: Samples pom @@ -34,14 +33,4 @@ embedded-sign-in-widget - - - - com.fasterxml.jackson.core - jackson-databind - 2.13.3 - - - -