use of com.okta.idx.sdk.api.model.Options in project okta-idx-java by okta.
the class AuthenticationTransaction method getAuthenticators.
private List<Authenticator> getAuthenticators(Options[] options) {
if (options == null || options.length == 0) {
return null;
}
List<Authenticator> authenticators = new ArrayList<>();
for (Options option : options) {
String id = null;
String label = option.getLabel();
String enrollmentId = null;
String authenticatorType = null;
boolean hasNestedFactors = false;
boolean isChannelFactor = false;
Map<String, String> nestedMethods = new LinkedHashMap<>();
FormValue[] optionFormValues = ((OptionsForm) option.getValue()).getForm().getValue();
for (FormValue formValue : optionFormValues) {
if (formValue.getName().equals("methodType")) {
authenticatorType = String.valueOf(formValue.getValue());
// parse value from children
Options[] nestedOptions = formValue.options();
if (nestedOptions.length > 0) {
for (Options children : nestedOptions) {
nestedMethods.put(String.valueOf(children.getValue()), String.valueOf(children.getLabel()));
}
hasNestedFactors = true;
} else {
nestedMethods.put(String.valueOf(formValue.getValue()), label);
}
} else if ("channel".equals(formValue.getName())) {
authenticatorType = String.valueOf(option.getLabel()).toLowerCase(Locale.ROOT).replaceAll(" ", "_");
isChannelFactor = true;
Options[] nestedOptions = formValue.options();
if (nestedOptions.length > 0) {
for (Options children : nestedOptions) {
nestedMethods.put(String.valueOf(children.getValue()), String.valueOf(children.getLabel()));
}
hasNestedFactors = true;
} else {
nestedMethods.put(authenticatorType, label);
}
}
if (formValue.getName().equals("id")) {
id = String.valueOf(formValue.getValue());
}
if (formValue.getName().equals("enrollmentId")) {
enrollmentId = String.valueOf(formValue.getValue());
}
}
List<Authenticator.Factor> factors = new ArrayList<>();
for (Map.Entry<String, String> entry : nestedMethods.entrySet()) {
factors.add(new Authenticator.Factor(id, entry.getKey(), enrollmentId, entry.getValue(), isChannelFactor ? entry.getKey() : null));
}
authenticators.add(new Authenticator(id, authenticatorType, label, factors, hasNestedFactors));
}
return authenticators;
}
use of com.okta.idx.sdk.api.model.Options in project okta-idx-java by okta.
the class AuthenticationTransaction method getAuthenticators.
private List<Authenticator> getAuthenticators(FormValue parent) {
if (parent == null) {
return null;
}
List<Authenticator> authenticators = new ArrayList<>();
String id = null;
String label = parent.getLabel();
String enrollmentId = null;
String authenticatorType = null;
Map<String, String> nestedMethods = new LinkedHashMap<>();
boolean hasNestedFactors = false;
for (FormValue formValue : parent.form().getValue()) {
if (formValue.getName().equals("methodType")) {
authenticatorType = String.valueOf(formValue.getValue());
// parse value from children
Options[] nestedOptions = formValue.options();
if (nestedOptions.length > 0) {
for (Options children : nestedOptions) {
nestedMethods.put(String.valueOf(children.getValue()), String.valueOf(children.getLabel()));
}
hasNestedFactors = true;
} else {
nestedMethods.put(String.valueOf(formValue.getValue()), label);
}
}
if (formValue.getName().equals("id")) {
id = String.valueOf(formValue.getValue());
}
if (formValue.getName().equals("enrollmentId")) {
enrollmentId = String.valueOf(formValue.getValue());
}
}
List<Authenticator.Factor> factors = new ArrayList<>();
for (Map.Entry<String, String> entry : nestedMethods.entrySet()) {
factors.add(new Authenticator.Factor(id, entry.getKey(), enrollmentId, entry.getValue(), null));
}
authenticators.add(new Authenticator(id, authenticatorType, label, factors, hasNestedFactors));
return authenticators;
}
Aggregations