Skip to content

Commit

Permalink
Merge pull request #28 from brettchaldecott/bugfix/ticket-26
Browse files Browse the repository at this point in the history
Bugfix/ticket 26
  • Loading branch information
DanielRivers authored Oct 1, 2024
2 parents cc95861 + 9d5a129 commit 03f82ff
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
39 changes: 17 additions & 22 deletions kinde-core/src/main/java/com/kinde/KindeClientBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> values = new ArrayList<>();

// Private constructor to initialize the enum constants
private AuthorizationType(String value) {
AuthorizationType(String value) {
this.value = value;
}

AuthorizationType(String value, List<String> values) {
this.value = value;
this.values.addAll(values);
}

// Getter method to retrieve the string value
public String getValue() {
return value;
Expand All @@ -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);
}
Expand Down
Empty file.

0 comments on commit 03f82ff

Please sign in to comment.