use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class UpdateOrganizationAction method modifyOrganization.
private String modifyOrganization() {
if (this.organization != null) {
return OxTrustConstants.RESULT_SUCCESS;
}
try {
GluuOrganization tmpOrganization = organizationService.getOrganization();
this.organization = new GluuOrganization();
// Clone shared instance
try {
PropertyUtils.copyProperties(this.organization, tmpOrganization);
} catch (Exception ex) {
log.error("Failed to load organization", ex);
this.organization = null;
}
} catch (LdapMappingException ex) {
log.error("Failed to load organization", ex);
}
if (this.organization == null) {
return OxTrustConstants.RESULT_FAILURE;
}
initLogoImage();
initFaviconImage();
this.loginPageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_LOGIN_PAGE);
this.welcomePageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_WELCOME_PAGE);
this.welcomeTitleText = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_TITLE_TEXT);
appliances = new ArrayList<GluuAppliance>();
try {
appliances.addAll(applianceService.getAppliances());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class PermissionService method hasPermission.
public boolean hasPermission(Object target, String action) {
log.trace("Checking permissions for target '{}' an 'action'. Identity: {}", target, action, identity);
if (!identity.isLoggedIn()) {
return false;
}
if (identity.hasRole(GluuUserRole.MANAGER.getValue()) || identity.hasRole(GluuUserRole.USER.getValue())) {
if (StringHelper.equals("profile_management", action)) {
GluuAppliance appliance = applianceService.getAppliance();
GluuAppliance targetAppliance = (GluuAppliance) target;
if (((appliance.getProfileManagment() != null) && appliance.getProfileManagment().isBooleanValue()) && StringHelper.equals(applianceService.getAppliance().getInum(), targetAppliance.getInum())) {
return true;
} else {
return false;
}
}
if (StringHelper.equals("whitePagesEnabled", action)) {
GluuAppliance appliance = applianceService.getAppliance();
GluuAppliance targetAppliance = (GluuAppliance) target;
if (((appliance.getWhitePagesEnabled() != null) && appliance.getWhitePagesEnabled().isBooleanValue()) && StringHelper.equals(applianceService.getAppliance().getInum(), targetAppliance.getInum())) {
return true;
} else {
return false;
}
}
}
if (identity.hasRole(GluuUserRole.MANAGER.getValue())) {
for (String[] managerAction : managerActions) {
String targetString = (String) target;
if (StringHelper.equals(managerAction[0], targetString) && StringHelper.equals(managerAction[1], action)) {
return true;
}
}
}
return false;
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class StatusCheckerDaily method processInt.
/**
* Gather periodically site and server status
*
* @param when
* Date
* @param interval
* Interval
*/
private void processInt() {
log.debug("Starting daily status checker");
AppConfiguration appConfiguration = configurationFactory.getAppConfiguration();
if (!appConfiguration.isUpdateApplianceStatus()) {
return;
}
GluuAppliance appliance;
try {
appliance = applianceService.getAppliance();
} catch (LdapMappingException ex) {
log.error("Failed to load current appliance", ex);
return;
}
// Set LDAP attributes
setLdapAttributes(appliance);
Date currentDateTime = new Date();
appliance.setLastUpdate(currentDateTime);
try {
applianceService.updateAppliance(appliance);
} catch (LdapMappingException ex) {
log.error("Failed to update current appliance", ex);
return;
}
if (centralLdapService.isUseCentralServer()) {
try {
GluuAppliance tmpAppliance = new GluuAppliance();
tmpAppliance.setDn(appliance.getDn());
boolean existAppliance = centralLdapService.containsAppliance(tmpAppliance);
if (existAppliance) {
centralLdapService.updateAppliance(appliance);
} else {
centralLdapService.addAppliance(appliance);
}
} catch (LdapMappingException ex) {
log.error("Failed to update appliance at central server", ex);
return;
}
}
log.debug("Daily Appliance status update finished");
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ManagePersonAuthenticationAction method modify.
public String modify() {
if (this.initialized) {
return OxTrustConstants.RESULT_SUCCESS;
}
try {
GluuAppliance appliance = applianceService.getAppliance();
if (appliance == null) {
return OxTrustConstants.RESULT_FAILURE;
}
passportEnable = appliance.getPassportEnabled();
log.info("passport enabled value : '{}'", passportEnable);
this.customScripts = customScriptService.findCustomScripts(Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION), "displayName", "oxLevel", "gluuStatus");
OxIDPAuthConf idpConf = getIDPAuthConfOrNull(appliance);
if (idpConf != null) {
this.ldapConfig = mapLdapConfig(idpConf.getConfig());
}
this.existLdapConfigIdpAuthConf = this.ldapConfig != null;
if (this.ldapConfig == null) {
this.ldapConfig = new GluuLdapConfiguration();
}
this.authenticationMode = appliance.getAuthenticationMode();
this.oxTrustAuthenticationMode = appliance.getOxTrustAuthenticationMode();
ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
if (ldapOxPassportConfiguration == null) {
ldapOxPassportConfiguration = new LdapOxPassportConfiguration();
}
this.ldapPassportConfigurations = ldapOxPassportConfiguration.getPassportConfigurations();
} catch (Exception ex) {
log.error("Failed to load appliance configuration", ex);
return OxTrustConstants.RESULT_FAILURE;
}
this.initialized = true;
return OxTrustConstants.RESULT_SUCCESS;
}
use of org.gluu.oxtrust.model.GluuAppliance in project oxTrust by GluuFederation.
the class ManagePersonAuthenticationAction method save.
public String save() {
try {
// Reload entry to include latest changes
GluuAppliance appliance = applianceService.getAppliance();
boolean updateAuthenticationMode = false;
boolean updateOxTrustAuthenticationMode = false;
OxIDPAuthConf idpConf = getIDPAuthConfOrNull(appliance);
if (idpConf != null && idpConf.getName() != null) {
if (idpConf.getName().equals(this.authenticationMode)) {
updateAuthenticationMode = true;
}
if (idpConf.getName().equals(this.oxTrustAuthenticationMode)) {
updateOxTrustAuthenticationMode = true;
}
}
this.ldapConfig.updateStringsLists();
updateAuthConf(appliance);
String updatedAuthMode = updateAuthenticationMode ? this.ldapConfig.getConfigId() : this.authenticationMode;
String updatedOxTrustAuthMode = updateOxTrustAuthenticationMode ? this.ldapConfig.getConfigId() : this.oxTrustAuthenticationMode;
appliance.setAuthenticationMode(updatedAuthMode);
appliance.setOxTrustAuthenticationMode(updatedOxTrustAuthMode);
appliance.setPassportEnabled(passportEnable);
applianceService.updateAppliance(appliance);
ldapOxPassportConfiguration.setPassportConfigurations(ldapPassportConfigurations);
passportService.updateLdapOxPassportConfiguration(ldapOxPassportConfiguration);
} catch (LdapMappingException ex) {
log.error("Failed to update appliance configuration", ex);
facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to update appliance");
return OxTrustConstants.RESULT_FAILURE;
}
reset();
return modify();
}
Aggregations