use of org.gluu.model.SchemaEntry in project oxCore by GluuFederation.
the class AttributeService method getDefaultSaml2Uri.
public String getDefaultSaml2Uri(String name) {
SchemaEntry schemaEntry = schemaService.getSchema();
if (schemaEntry == null) {
List<String> attributeNames = new ArrayList<String>();
attributeNames.add(name);
List<AttributeTypeDefinition> attributeTypes = schemaService.getAttributeTypeDefinitions(schemaEntry, attributeNames);
AttributeTypeDefinition attributeTypeDefinition = schemaService.getAttributeTypeDefinition(attributeTypes, name);
if (attributeTypeDefinition != null) {
return String.format("urn:oid:%s", attributeTypeDefinition.getOID());
}
}
return "";
}
use of org.gluu.model.SchemaEntry in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method generateGluuAttributeRulesFile.
public boolean generateGluuAttributeRulesFile(List<GluuAttribute> attributes) {
boolean ret = false;
log.info(">>>>>>>>>> IN Shibboleth3ConfService.generateGluuAttributeRulesFile() ...");
if (appConfiguration.getShibboleth3IdpRootDir() == null) {
throw new InvalidConfigurationException("Failed to update configuration due to undefined IDP root folder");
}
VelocityContext context = new VelocityContext();
List<String> attributeNames = new ArrayList<String>();
for (GluuAttribute attribute : attributes) {
attributeNames.add(attribute.getName());
}
SchemaEntry schemaEntry = shemaService.getSchema();
List<AttributeTypeDefinition> attributeTypes = shemaService.getAttributeTypeDefinitions(schemaEntry, attributeNames);
Map<String, String> attributeSaml1Strings = new HashMap<String, String>();
Map<String, String> attributeSaml2Strings = new HashMap<String, String>();
for (GluuAttribute metadata : attributes) {
String attributeName = metadata.getName();
String saml1String = metadata.getSaml1Uri();
if (StringHelper.isEmpty(saml1String)) {
boolean standard = metadata.isCustom() || StringHelper.isEmpty(metadata.getUrn()) || (!StringHelper.isEmpty(metadata.getUrn()) && metadata.getUrn().startsWith("urn:gluu:dir:attribute-def:"));
saml1String = String.format("urn:%s:dir:attribute-def:%s", (standard ? "gluu" : "mace"), attributeName);
}
attributeSaml1Strings.put(attributeName, saml1String);
String saml2String = metadata.getSaml2Uri();
if (StringHelper.isEmpty(saml2String)) {
AttributeTypeDefinition attributeTypeDefinition = shemaService.getAttributeTypeDefinition(attributeTypes, attributeName);
if (attributeTypeDefinition == null) {
log.error("Failed to get OID for attribute name {}", attributeName);
return false;
}
saml2String = String.format("urn:oid:%s", attributeTypeDefinition.getOID());
}
attributeSaml2Strings.put(attributeName, saml2String);
}
context.put("attributes", attributes);
context.put("attributeSaml1Strings", attributeSaml1Strings);
context.put("attributeSaml2Strings", attributeSaml2Strings);
String gluuAttributesRules = generateConfFile(SHIB_IDP_GLUU_ATTRIBUTE_RULES_FILE, context);
log.info("Gluu attributes rules file path is {}", getGluuAttributesRulesFilePath());
ret = writeConfFile(getGluuAttributesRulesFilePath(), gluuAttributesRules);
log.info(">>>>>>>>>>> LEAVING Shibboleth3ConfService.generateGluuAttributeRulesFile() ...");
return ret;
}
use of org.gluu.model.SchemaEntry in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method getSAML2URI.
public String getSAML2URI(GluuAttribute attribute) {
if (StringHelper.isNotEmpty(attribute.getSaml2Uri())) {
return "SAML1 URI: " + attribute.getSaml2Uri();
}
List<String> attributeNames = new ArrayList<String>();
attributeNames.add(attribute.getName());
SchemaEntry schemaEntry = shemaService.getSchema();
List<AttributeTypeDefinition> attributeTypes = shemaService.getAttributeTypeDefinitions(schemaEntry, attributeNames);
String attributeName = attribute.getName();
AttributeTypeDefinition attributeTypeDefinition = shemaService.getAttributeTypeDefinition(attributeTypes, attributeName);
if (attributeTypeDefinition == null) {
log.error("Failed to get OID for attribute name {}", attributeName);
return null;
}
return "SAML2 URI: urn:oid:" + attributeTypeDefinition.getOID();
}
use of org.gluu.model.SchemaEntry in project oxTrust by GluuFederation.
the class CacheRefreshTimer method validateTargetServerSchema.
private boolean validateTargetServerSchema(List<String> targetObjectClasses, List<String> targetAttributes) {
SchemaEntry schemaEntry = schemaService.getSchema();
if (schemaEntry == null) {
// Destination server not requires schema validation
return true;
}
Set<String> objectClassesAttributesSet = schemaService.getObjectClassesAttributes(schemaEntry, targetObjectClasses.toArray(new String[0]));
Set<String> targetAttributesSet = new LinkedHashSet<String>();
for (String attrbute : targetAttributes) {
targetAttributesSet.add(StringHelper.toLowerCase(attrbute));
}
targetAttributesSet.removeAll(objectClassesAttributesSet);
if (targetAttributesSet.size() == 0) {
return true;
}
log.error("Skipping target entries update. Destination server schema doesn't has next attributes: '{}'", targetAttributesSet);
return false;
}
use of org.gluu.model.SchemaEntry in project oxTrust by GluuFederation.
the class UpdateAttributeAction method determineOrigin.
private String determineOrigin(String attributeName) {
String[] objectClasses = ArrayHelper.arrayMerge(new String[] { "gluuPerson" }, appConfiguration.getPersonObjectClassTypes());
SchemaEntry schemaEntry = schemaService.getSchema();
for (String objectClass : objectClasses) {
Set<String> attributeNames = schemaService.getObjectClassesAttributes(schemaEntry, new String[] { objectClass });
String atributeNameToSearch = StringHelper.toLowerCase(attributeName);
boolean contains = attributeNames.contains(atributeNameToSearch);
if (contains) {
return objectClass;
}
}
log.error("Failed to determine object class by attribute name '{}'", attributeName);
return null;
}
Aggregations