use of org.oxauth.persistence.model.configuration.CustomProperty in project oxAuth by GluuFederation.
the class PythonToLdapString method test.
// @Override
// public void beforeClass() {
//
// }
//
// @Override
// public void afterClass() {
//
// }
// VIEW:
// u:\own\java\opendj-2.4.4\OpenDJ\bat\ldapsearch.bat -h localhost -p 1636
// -Z -X -D "cn=directory manager" -w secret -b "ou=configuration,o=gluu"
// "inum=@!1111!0002!4907"
// MODIFY:
// u:\own\java\opendj-2.4.4\OpenDJ\bat\ldapmodify.bat -h localhost -p 1636
// -Z -X -D "cn=directory manager" -w secret -f
// U:\own\project\oxAuth\Server\src\test\java\org\xdi\oxauth\dev\duo\script.ldif
@Test
public void test() throws IOException {
final File f = new File("U:\\own\\project\\oxAuth\\Server\\integrations\\duo\\ExternalAuthenticator.py");
final String pythonScript = IOUtils.toString(new FileInputStream(f));
System.out.println("Python script: \n" + pythonScript);
final List<CustomProperty> fields = new ArrayList<CustomProperty>();
fields.add(createAttribute("property.duo_host", "api-fa928e64.duosecurity.com"));
fields.add(createAttribute("property.duo_ikey", "DIT2906CETIMKHE1QND8"));
fields.add(createAttribute("property.duo_skey", "cjNn9R4QvQV0R2Mynw2CauCUesojuR3cPGDoVygM"));
fields.add(createAttribute("property.duo_akey", "6f88ca3dea7ac88a514cdef7c18021678ccaf0e1"));
fields.add(createAttribute(SCRIPT_FIELD_NAME, pythonScript));
final oxIDPAuthConf c = new oxIDPAuthConf();
c.setType("customAuthentication");
c.setName("duo");
c.setEnabled(true);
c.setLevel(1);
c.setPriority(1);
c.setFields(fields);
final String json = getJSONString(c);
System.out.println("JSON: \n" + json);
final oxIDPAuthConf fromJson = fromJSON(json);
for (CustomProperty attr : fromJson.getFields()) {
if (attr.getName().equals(SCRIPT_FIELD_NAME)) {
System.out.println("Script from json: \n" + attr.getValues().get(0));
}
}
}
use of org.oxauth.persistence.model.configuration.CustomProperty in project oxAuth by GluuFederation.
the class LdapCustomAuthenticationConfigurationService method mapCustomAuthentication.
private CustomAuthenticationConfiguration mapCustomAuthentication(oxIDPAuthConf oneConf) {
CustomAuthenticationConfiguration customAuthenticationConfig = new CustomAuthenticationConfiguration();
customAuthenticationConfig.setName(oneConf.getName());
customAuthenticationConfig.setLevel(oneConf.getLevel());
customAuthenticationConfig.setPriority(oneConf.getPriority());
customAuthenticationConfig.setEnabled(oneConf.getEnabled());
customAuthenticationConfig.setVersion(oneConf.getVersion());
for (CustomProperty customProperty : oneConf.getFields()) {
if ((customProperty.getValues() == null) || (customProperty.getValues().size() == 0)) {
continue;
}
String attrName = StringHelper.toLowerCase(customProperty.getName());
if (StringHelper.isEmpty(attrName)) {
continue;
}
String value = customProperty.getValues().get(0);
if (attrName.startsWith(CUSTOM_AUTHENTICATION_PROPERTY_PREFIX)) {
String key = customProperty.getName().substring(CUSTOM_AUTHENTICATION_PROPERTY_PREFIX.length());
SimpleCustomProperty property = new SimpleCustomProperty(key, value);
customAuthenticationConfig.getCustomAuthenticationAttributes().add(property);
} else if (StringHelper.equalsIgnoreCase(attrName, CUSTOM_AUTHENTICATION_SCRIPT_PROPERTY_NAME)) {
customAuthenticationConfig.setCustomAuthenticationScript(value);
} else if (StringHelper.equalsIgnoreCase(attrName, CUSTOM_AUTHENTICATION_SCRIPT_USAGE_TYPE)) {
if (StringHelper.isNotEmpty(value)) {
AuthenticationScriptUsageType authenticationScriptUsageType = AuthenticationScriptUsageType.getByValue(value);
customAuthenticationConfig.setUsageType(authenticationScriptUsageType);
}
}
}
return customAuthenticationConfig;
}
use of org.oxauth.persistence.model.configuration.CustomProperty in project oxAuth by GluuFederation.
the class PythonToLdapString method createAttribute.
private CustomProperty createAttribute(String p_name, String p_value) {
final List<String> v = new ArrayList<String>();
v.add(p_value);
final CustomProperty result = new CustomProperty();
result.setName(p_name);
result.setValues(v);
return result;
}
Aggregations