use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class TrustService method updateReleasedAttributes.
public void updateReleasedAttributes(GluuSAMLTrustRelationship trustRelationship) {
List<String> releasedAttributes = new ArrayList<String>();
String mailMsg = "";
for (GluuCustomAttribute customAttribute : trustRelationship.getReleasedCustomAttributes()) {
if (customAttribute.isNew()) {
mailMsg += "\nAttribute name: " + customAttribute.getName() + " Display name: " + customAttribute.getMetadata().getDisplayName() + " Attribute value: " + customAttribute.getValue();
customAttribute.setNew(false);
}
releasedAttributes.add(customAttribute.getMetadata().getDn());
}
if (!StringUtils.isEmpty(mailMsg)) {
try {
String preMsg = "Trust RelationShip name: " + trustRelationship.getDisplayName() + " (inum:" + trustRelationship.getInum() + ")\n\n";
GluuAppliance appliance = applianceService.getAppliance();
String subj = "Attributes with Privacy level 5 are released in a Trust Relationaship";
MailUtils mail = new MailUtils(appliance.getSmtpHost(), appliance.getSmtpPort(), appliance.isRequiresSsl(), appliance.isRequiresAuthentication(), appliance.getSmtpUserName(), applianceService.getDecryptedSmtpPassword(appliance));
mail.sendMail(appliance.getSmtpFromName() + " <" + appliance.getSmtpFromEmailAddress() + ">", appliance.getContactEmail(), subj, preMsg + mailMsg);
} catch (AuthenticationFailedException ex) {
log.error("SMTP Authentication Error: ", ex);
} catch (MessagingException ex) {
log.error("SMTP Host Connection Error", ex);
} catch (Exception ex) {
log.error("Failed to send the notification email: ", ex);
}
}
if (!releasedAttributes.isEmpty()) {
trustRelationship.setReleasedAttributes(releasedAttributes);
} else {
trustRelationship.setReleasedAttributes(null);
}
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class Shibboleth3ConfService method addGluuSP.
/**
* Adds Trust relationship for own shibboleth SP and restarts services after
* done.
*
* @author �Oleksiy Tataryn�
*/
public void addGluuSP() {
String gluuSPInum = trustService.generateInumForNewTrustRelationship();
String metadataFN = getSpNewMetadataFileName(gluuSPInum);
GluuSAMLTrustRelationship gluuSP = new GluuSAMLTrustRelationship();
gluuSP.setInum(gluuSPInum);
gluuSP.setDisplayName("gluu SP on appliance");
gluuSP.setDescription("Trust Relationship for the SP");
gluuSP.setSpMetaDataSourceType(GluuMetadataSourceType.FILE);
gluuSP.setSpMetaDataFN(metadataFN);
//TODO:
gluuSP.setEntityId(StringHelper.removePunctuation(gluuSP.getInum()));
gluuSP.setUrl(appConfiguration.getApplianceUrl());
String certificate = "";
boolean result = false;
try {
certificate = FileUtils.readFileToString(new File(appConfiguration.getGluuSpCert())).replaceAll("-{5}.*?-{5}", "");
generateSpMetadataFile(gluuSP, certificate);
result = isCorrectSpMetadataFile(gluuSP.getSpMetaDataFN());
} catch (IOException e) {
log.error("Failed to gluu SP read certificate file.", e);
}
GluuAppliance appliance = null;
if (result) {
gluuSP.setStatus(GluuStatus.ACTIVE);
String inum = gluuSP.getInum();
String dn = trustService.getDnForTrustRelationShip(inum);
gluuSP.setDn(dn);
List<GluuCustomAttribute> customAttributes = new ArrayList<GluuCustomAttribute>();
List<GluuAttribute> attributes = attributeService.getAllPersonAttributes(GluuUserRole.ADMIN);
HashMap<String, GluuAttribute> attributesByDNs = attributeService.getAttributeMapByDNs(attributes);
List<String> customAttributeDNs = new ArrayList<String>();
List<String> attributeNames = new ArrayList<String>();
for (String attributeName : appConfiguration.getGluuSpAttributes()) {
GluuAttribute attribute = attributeService.getAttributeByName(attributeName, attributes);
if (attribute != null) {
customAttributeDNs.add(attribute.getDn());
}
}
customAttributes.addAll(attributeService.getCustomAttributesByAttributeDNs(customAttributeDNs, attributesByDNs));
gluuSP.setReleasedCustomAttributes(customAttributes);
gluuSP.setReleasedAttributes(attributeNames);
trustService.updateReleasedAttributes(gluuSP);
trustService.addTrustRelationship(gluuSP);
appliance = applianceService.getAppliance();
appliance.setGluuSPTR(gluuSP.getInum());
}
if (result) {
applianceService.updateAppliance(appliance);
log.warn("gluuSP EntityID set to " + StringHelper.removePunctuation(gluuSP.getInum()) + ". Shibboleth3 configuration should be updated.");
// applianceService.restartServices();
} else {
log.error("IDP configuration update failed. GluuSP was not generated.");
}
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class CacheRefreshTimer method processInt.
public void processInt() {
if (this.isActive.get()) {
log.debug("Another process is active");
return;
}
CacheRefreshConfiguration cacheRefreshConfiguration = configurationFactory.getCacheRefreshConfiguration();
if (!this.isActive.compareAndSet(false, true)) {
log.debug("Failed to start process exclusively");
return;
}
try {
GluuAppliance currentAppliance = applianceService.getAppliance();
if (!isStartCacheRefresh(cacheRefreshConfiguration, currentAppliance)) {
log.debug("Starting conditions aren't reached");
return;
}
processImpl(cacheRefreshConfiguration, currentAppliance);
updateApplianceStatus(currentAppliance, System.currentTimeMillis());
this.lastFinishedTime = System.currentTimeMillis();
} catch (Throwable ex) {
log.error("Exception happened while executing cache refresh synchronization", ex);
} finally {
log.debug("Allowing to run new process exclusively");
this.isActive.set(false);
}
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class CacheRefreshTimer method updateApplianceStatus.
private void updateApplianceStatus(GluuAppliance currentAppliance, long lastRun) {
GluuAppliance appliance = applianceService.getAppliance();
Date currentDateTime = new Date();
appliance.setVdsCacheRefreshLastUpdate(currentDateTime);
appliance.setVdsCacheRefreshLastUpdateCount(currentAppliance.getVdsCacheRefreshLastUpdateCount());
appliance.setVdsCacheRefreshProblemCount(currentAppliance.getVdsCacheRefreshProblemCount());
applianceService.updateAppliance(appliance);
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ApplianceService method getAppliance.
/**
* Get appliance
*
* @return Appliance
* @throws Exception
*/
public GluuAppliance getAppliance(String[] returnAttributes) {
GluuAppliance result = null;
if (ldapEntryManager.contains(GluuAppliance.class, getDnForAppliance(getApplianceInum()))) {
result = ldapEntryManager.find(GluuAppliance.class, getDnForAppliance(getApplianceInum()), returnAttributes);
} else {
result = new GluuAppliance();
result.setInum(getApplianceInum());
result.setDn(getDnForAppliance(getApplianceInum()));
ldapEntryManager.persist(result);
}
return result;
}
Aggregations