use of com.tremolosecurity.config.xml.AuthLockoutType in project OpenUnison by TremoloSecurity.
the class LoadAuthChainsFromK8s method createAuthChain.
private AuthChainType createAuthChain(JSONObject item, String name) throws Exception {
AuthChainType act = new AuthChainType();
act.setName(name);
JSONObject spec = (JSONObject) item.get("spec");
act.setLevel(((Long) spec.get("level")).intValue());
Boolean finishOnRequiredSucess = (Boolean) spec.get("finishOnRequiredSucess");
if (finishOnRequiredSucess != null) {
act.setFinishOnRequiredSucess(finishOnRequiredSucess);
} else {
act.setFinishOnRequiredSucess(false);
}
String root = (String) spec.get("root");
if (root != null) {
act.setRoot(root);
}
JSONObject jsonCompliance = (JSONObject) spec.get("compliance");
if (jsonCompliance != null) {
AuthLockoutType alt = new AuthLockoutType();
alt.setEnabled((Boolean) jsonCompliance.get("enabled"));
alt.setMaxFailedAttempts(((Integer) jsonCompliance.get("maxLockoutTime")));
alt.setNumFailedAttribute((String) jsonCompliance.get("numFailedAttribute"));
alt.setLastFailedAttribute((String) jsonCompliance.get("lastFailedAttribute"));
alt.setLastSucceedAttribute((String) jsonCompliance.get("lastSucceedAttribute"));
alt.setUpdateAttributesWorkflow((String) jsonCompliance.get("updateAttributesWorkflow"));
alt.setUidAttributeName((String) jsonCompliance.get("uidAttributeName"));
act.setCompliance(alt);
}
JSONArray mechs = (JSONArray) spec.get("authMechs");
for (Object o : mechs) {
JSONObject mech = (JSONObject) o;
AuthMechType amt = new AuthMechType();
amt.setName((String) mech.get("name"));
amt.setRequired((String) mech.get("required"));
amt.setParams(new AuthMechParamType());
JSONObject jsonObj = (JSONObject) mech.get("params");
for (Object ok : jsonObj.keySet()) {
String paramName = (String) ok;
Object val = jsonObj.get(paramName);
if (val instanceof String) {
ParamWithValueType pt = new ParamWithValueType();
pt.setName(paramName);
pt.setValue((String) val);
amt.getParams().getParam().add(pt);
} else {
JSONArray vals = (JSONArray) val;
for (Object ov : vals) {
ParamWithValueType pt = new ParamWithValueType();
pt.setName(paramName);
pt.setValue((String) ov);
amt.getParams().getParam().add(pt);
}
}
}
JSONArray secretParams = (JSONArray) mech.get("secretParams");
if (secretParams != null) {
HttpCon nonwatchHttp = this.k8sWatch.getK8s().createClient();
String token = this.k8sWatch.getK8s().getAuthToken();
try {
for (Object ox : secretParams) {
JSONObject secretParam = (JSONObject) ox;
String paramName = (String) secretParam.get("name");
String secretName = (String) secretParam.get("secretName");
String secretKey = (String) secretParam.get("secretKey");
String secretValue = this.k8sWatch.getSecretValue(secretName, secretKey, token, nonwatchHttp);
ParamWithValueType pt = new ParamWithValueType();
pt.setName(paramName);
pt.setValue(secretValue);
amt.getParams().getParam().add(pt);
}
} finally {
nonwatchHttp.getHttp().close();
nonwatchHttp.getBcm().close();
}
}
act.getAuthMech().add(amt);
}
return act;
}
Aggregations