diff --git a/kinde-core/src/main/java/com/kinde/KindeClientBuilder.java b/kinde-core/src/main/java/com/kinde/KindeClientBuilder.java index 8112ad42..72955b3f 100644 --- a/kinde-core/src/main/java/com/kinde/KindeClientBuilder.java +++ b/kinde-core/src/main/java/com/kinde/KindeClientBuilder.java @@ -21,28 +21,23 @@ public class KindeClientBuilder { * Private constructor to prevent new instantiation */ private KindeClientBuilder() { - try { - Dotenv dotenv = Dotenv.load(); - setParameterFromEnvironmental(KindeParameters.DOMAIN, dotenv); - setParameterFromEnvironmental(KindeParameters.REDIRECT_URI, dotenv); - setParameterFromEnvironmental(KindeParameters.LOGOUT_REDIRECT_URI, dotenv); - setParameterFromEnvironmental(KindeParameters.OPENID_ENDPOINT, dotenv); - setParameterFromEnvironmental(KindeParameters.AUTHORIZATION_ENDPOINT, dotenv); - setParameterFromEnvironmental(KindeParameters.TOKEN_ENDPOINT, dotenv); - setParameterFromEnvironmental(KindeParameters.LOGOUT_ENDPOINT, dotenv); - setParameterFromEnvironmental(KindeParameters.CLIENT_ID, dotenv); - setParameterFromEnvironmental(KindeParameters.CLIENT_SECRET, dotenv); - setParameterFromEnvironmental(KindeParameters.GRANT_TYPE, dotenv); - setParameterFromEnvironmental(KindeParameters.SCOPES, dotenv); - setParameterFromEnvironmental(KindeParameters.PROTOCOL, dotenv); - setParameterFromEnvironmental(KindeParameters.AUDIENCE, dotenv); - setParameterFromEnvironmental(KindeParameters.LANG, dotenv); - setParameterFromEnvironmental(KindeParameters.ORG_CODE, dotenv); - setParameterFromEnvironmental(KindeParameters.HAS_SUCCESS_PAGE, dotenv); - - } catch (Exception ex) { - // ignore exceptions as this means that the DotEnv environment was not configured - } + Dotenv dotenv = Dotenv.configure().ignoreIfMissing().systemProperties().load(); + setParameterFromEnvironmental(KindeParameters.DOMAIN, dotenv); + setParameterFromEnvironmental(KindeParameters.REDIRECT_URI, dotenv); + setParameterFromEnvironmental(KindeParameters.LOGOUT_REDIRECT_URI, dotenv); + setParameterFromEnvironmental(KindeParameters.OPENID_ENDPOINT, dotenv); + setParameterFromEnvironmental(KindeParameters.AUTHORIZATION_ENDPOINT, dotenv); + setParameterFromEnvironmental(KindeParameters.TOKEN_ENDPOINT, dotenv); + setParameterFromEnvironmental(KindeParameters.LOGOUT_ENDPOINT, dotenv); + setParameterFromEnvironmental(KindeParameters.CLIENT_ID, dotenv); + setParameterFromEnvironmental(KindeParameters.CLIENT_SECRET, dotenv); + setParameterFromEnvironmental(KindeParameters.GRANT_TYPE, dotenv); + setParameterFromEnvironmental(KindeParameters.SCOPES, dotenv); + setParameterFromEnvironmental(KindeParameters.PROTOCOL, dotenv); + setParameterFromEnvironmental(KindeParameters.AUDIENCE, dotenv); + setParameterFromEnvironmental(KindeParameters.LANG, dotenv); + setParameterFromEnvironmental(KindeParameters.ORG_CODE, dotenv); + setParameterFromEnvironmental(KindeParameters.HAS_SUCCESS_PAGE, dotenv); injector = KindeGuiceSingleton.getInstance().getInjector().createChildInjector(new KindeClientGuiceModule(this.parameters)); } diff --git a/kinde-core/src/main/java/com/kinde/authorization/AuthorizationType.java b/kinde-core/src/main/java/com/kinde/authorization/AuthorizationType.java index 92a2eaa2..779047a2 100644 --- a/kinde-core/src/main/java/com/kinde/authorization/AuthorizationType.java +++ b/kinde-core/src/main/java/com/kinde/authorization/AuthorizationType.java @@ -2,22 +2,30 @@ import com.kinde.config.KindeParameters; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.function.Function; public enum AuthorizationType { - CODE("CODE"), + CODE("CODE",List.of("authorization_code")), IMPLICIT("IMPLICIT"), CUSTOM("CUSTOM"); // Field to store the string value private final String value; + private final List values = new ArrayList<>(); // Private constructor to initialize the enum constants - private AuthorizationType(String value) { + AuthorizationType(String value) { this.value = value; } + AuthorizationType(String value, List values) { + this.value = value; + this.values.addAll(values); + } + // Getter method to retrieve the string value public String getValue() { return value; @@ -32,6 +40,9 @@ public static AuthorizationType fromValue(Object value) { if (constant.value.equals(value)) { return constant; } + if (constant.values.stream().filter(entry->entry.equals(value)).findAny().isPresent()) { + return constant; + } } throw new IllegalArgumentException("Unknown value: " + value); } diff --git a/playground/kinde-j2ee-app/src/main/resources/.env b/playground/kinde-j2ee-app/src/main/resources/.env deleted file mode 100644 index e69de29b..00000000