use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class SamlTestScenary method run.
/**
* Run tests.
*
* @throws APITestException
* @throws OxTrustAPIException
*/
public void run() throws APITestException, OxTrustAPIException {
TrustRelationshipClient samlClient = client.getTrustRelationshipClient();
GluuSAMLTrustRelationship trGenerated = generateRandomeSingleTrustRelationship();
// test create()
String inum = samlClient.create(trGenerated);
// test read()
GluuSAMLTrustRelationship trReaded = samlClient.read(inum);
// TODO: compare etities
trReaded.setDescription("description changed");
// test update()
samlClient.update(trReaded, inum);
// test list()
List<SAMLTrustRelationshipShort> trustRelationships = samlClient.list();
if (!checkListForTrustRelationship(trustRelationships, inum))
throw new APITestException("TrustRelationship really not saved");
// test delete()
samlClient.delete(inum);
trustRelationships = samlClient.list();
if (checkListForTrustRelationship(trustRelationships, inum))
throw new APITestException("TrustRelationship really not deleted");
// TODO: all API calls
}
use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class ShibbolethInitializer method createShibbolethConfiguration.
public boolean createShibbolethConfiguration() {
boolean createConfig = appConfiguration.isConfigGeneration();
log.info("IDP config generation is set to " + createConfig);
if (createConfig) {
String gluuSPInum;
GluuSAMLTrustRelationship gluuSP;
try {
gluuSPInum = applianceService.getAppliance().getGluuSPTR();
// log.info("########## gluuSPInum = " + gluuSPInum);
gluuSP = new GluuSAMLTrustRelationship();
gluuSP.setDn(trustService.getDnForTrustRelationShip(gluuSPInum));
} catch (EntryPersistenceException ex) {
log.error("Failed to determine SP inum", ex);
return false;
}
// log.info("########## gluuSP.getDn() = " + gluuSP.getDn());
boolean servicesNeedRestarting = false;
// if (gluuSPInum == null || ! trustService.containsTrustRelationship(gluuSP)) {
//
// log.info("No trust relationships exist in LDAP. Adding gluuSP");
// GluuAppliance appliance = applianceService.getAppliance();
// appliance.setGluuSPTR(null);
// applianceService.updateAppliance(appliance);
// shibboleth3ConfService.addGluuSP();
// servicesNeedRestarting = true;
// }
gluuSP = trustService.getRelationshipByInum(applianceService.getAppliance().getGluuSPTR());
List<GluuSAMLTrustRelationship> trustRelationships = trustService.getAllActiveTrustRelationships();
/*
if (trustRelationships != null && !trustRelationships.isEmpty()) {
for (GluuSAMLTrustRelationship gluuSAMLTrustRelationship : trustRelationships) {
log.info("########## gluuSAMLTrustRelationship.getDn() = " + gluuSAMLTrustRelationship.getDn());
}
}
*/
String shibbolethVersion = appConfiguration.getShibbolethVersion();
log.info("########## shibbolethVersion = " + shibbolethVersion);
shibboleth3ConfService.generateMetadataFiles(gluuSP);
shibboleth3ConfService.generateConfigurationFiles(trustRelationships);
shibboleth3ConfService.removeUnusedCredentials();
shibboleth3ConfService.removeUnusedMetadata();
if (servicesNeedRestarting) {
applianceService.restartServices();
}
}
return true;
}
use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class TrustService method removeAttribute.
/**
* Remove attribute
*
* @param attribute
* Attribute
*/
public boolean removeAttribute(GluuAttribute attribute) {
log.info("Attribute removal started");
log.trace("Removing attribute from trustRelationships");
List<GluuSAMLTrustRelationship> trustRelationships = getAllTrustRelationships();
log.trace(String.format("Iterating '%d' trustRelationships", trustRelationships.size()));
for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
log.trace("Analyzing '%s'.", trustRelationship.getDisplayName());
List<String> customAttrs = trustRelationship.getReleasedAttributes();
if (customAttrs != null) {
for (String attrDN : customAttrs) {
log.trace("'%s' has custom attribute '%s'", trustRelationship.getDisplayName(), attrDN);
if (attrDN.equals(attribute.getDn())) {
log.trace("'%s' matches '%s'. deleting it.", attrDN, attribute.getDn());
List<String> updatedAttrs = new ArrayList<String>();
updatedAttrs.addAll(customAttrs);
updatedAttrs.remove(attrDN);
if (updatedAttrs.size() == 0) {
trustRelationship.setReleasedAttributes(null);
} else {
trustRelationship.setReleasedAttributes(updatedAttrs);
}
updateTrustRelationship(trustRelationship);
break;
}
}
}
}
attributeService.removeAttribute(attribute);
return true;
}
use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class TrustRelationshipInventoryAction method setCustomAttributes.
private void setCustomAttributes(List<GluuSAMLTrustRelationship> trustRelationships) {
List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.ADMIN);
HashMap<String, GluuAttribute> attributesByDNs = attributeService.getAttributeMapByDNs(attributes);
for (GluuSAMLTrustRelationship trustRelationship : trustRelationships) {
trustRelationship.setReleasedCustomAttributes(attributeService.getCustomAttributesByAttributeDNs(trustRelationship.getReleasedAttributes(), attributesByDNs));
}
}
use of org.gluu.oxtrust.model.GluuSAMLTrustRelationship in project oxTrust by GluuFederation.
the class UpdateTrustRelationshipAction method saveTR.
private void saveTR(boolean isUpdate) {
log.trace("Saving Trust Relationship");
if (isUpdate) {
String oldLogoutRedirectUri = trustService.getRelationshipByDn(trustRelationship.getDn()).getSpLogoutURL();
String newLogoutRedirectUri = trustRelationship.getSpLogoutURL();
boolean oxClientUpdateNeeded = (oldLogoutRedirectUri != null) && (newLogoutRedirectUri != null) && !newLogoutRedirectUri.equals(oldLogoutRedirectUri);
boolean parentInactive = trustRelationship.getStatus().equals(GluuStatus.INACTIVE);
if (!federatedSites.isEmpty()) {
for (GluuSAMLTrustRelationship trust : federatedSites) {
if (parentInactive) {
trust.setStatus(GluuStatus.INACTIVE);
}
updateReleasedAttributes(trust);
trustService.updateTrustRelationship(trust);
}
}
trustService.updateTrustRelationship(this.trustRelationship);
oxTrustAuditService.audit("TR " + this.trustRelationship.getInum() + " **" + this.trustRelationship.getDisplayName() + "** UPDATED", identity.getUser(), (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
if (oxClientUpdateNeeded) {
OxAuthClient client = clientService.getClientByInum(appConfiguration.getOxAuthClientId());
Set<String> updatedLogoutRedirectUris = new HashSet<String>();
List<GluuSAMLTrustRelationship> trs = trustService.getAllTrustRelationships();
if (trs != null && !trs.isEmpty()) {
for (GluuSAMLTrustRelationship tr : trs) {
String logoutRedirectUri = tr.getSpLogoutURL();
if (logoutRedirectUri != null && !logoutRedirectUri.isEmpty()) {
updatedLogoutRedirectUris.add(logoutRedirectUri);
}
}
}
if (updatedLogoutRedirectUris.isEmpty()) {
client.setPostLogoutRedirectUris(null);
} else {
client.setPostLogoutRedirectUris(updatedLogoutRedirectUris.toArray(new String[0]));
}
clientService.updateClient(client);
}
} else {
trustService.addTrustRelationship(this.trustRelationship);
oxTrustAuditService.audit("TR " + this.trustRelationship.getInum() + " **" + this.trustRelationship.getDisplayName() + "** ADDED", identity.getUser(), (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
}
}
Aggregations