use of org.gluu.oxtrust.model.GluuOrganization in project oxTrust by GluuFederation.
the class RegistrationInterceptionService method runPostRegistrationScripts.
public boolean runPostRegistrationScripts(GluuCustomPerson person, Map<String, String[]> requestParameters) {
GluuOrganization org = organizationService.getOrganization();
RegistrationConfiguration config = org.getOxRegistrationConfiguration();
if (config != null && config.isRegistrationInterceptorsConfigured()) {
List<RegistrationInterceptorScript> scripts = config.getRegistrationInterceptorScripts();
List<RegistrationInterceptorScript> sortedEnabledPostRegistrationScripts = sort(getActive(getPostRegistrationScripts(scripts)));
if (sortedEnabledPostRegistrationScripts != null) {
boolean result = true;
for (RegistrationInterceptorScript script : sortedEnabledPostRegistrationScripts) {
RegistrationScript registrationScript = createRegistrationScriptFromStringWithPythonException(script);
result &= registrationScript.execute(script.getCustomAttributes(), person, requestParameters);
}
return result;
} else {
return true;
}
} else {
return true;
}
}
use of org.gluu.oxtrust.model.GluuOrganization in project oxTrust by GluuFederation.
the class RegistrationInterceptionService method runPreRegistrationScripts.
public boolean runPreRegistrationScripts(GluuCustomPerson person, Map<String, String[]> requestParameters) {
GluuOrganization org = organizationService.getOrganization();
RegistrationConfiguration config = org.getOxRegistrationConfiguration();
if (config != null && config.isRegistrationInterceptorsConfigured()) {
List<RegistrationInterceptorScript> scripts = config.getRegistrationInterceptorScripts();
List<RegistrationInterceptorScript> sortedEnabledPreRegistrationScripts = sort(getActive(getPreRegistrationScripts(scripts)));
if (sortedEnabledPreRegistrationScripts != null) {
boolean result = true;
for (RegistrationInterceptorScript script : sortedEnabledPreRegistrationScripts) {
RegistrationScript registrationScript = createRegistrationScriptFromStringWithPythonException(script);
result &= registrationScript.execute(script.getCustomAttributes(), person, requestParameters);
}
return result;
} else {
return true;
}
} else {
return true;
}
}
use of org.gluu.oxtrust.model.GluuOrganization in project oxTrust by GluuFederation.
the class AuthOrganizationService method getOrganizationCustomMessage.
/**
* Returns custom message defined for the organization
*
* @param customMessageId
* message id
* @return custom message
*/
public String getOrganizationCustomMessage(String customMessageId) throws Exception {
GluuOrganization organization = getOrganization();
String key = OxTrustConstants.CACHE_ORGANIZATION_CUSTOM_MESSAGE_KEY + "_" + organization.getInum();
@SuppressWarnings("unchecked") Map<String, String> organizationCustomMessage = (Map<String, String>) cacheService.get(OxConstants.CACHE_APPLICATION_NAME, key);
if (organizationCustomMessage == null) {
organizationCustomMessage = new HashMap<String, String>();
String[] customMessages = organization.getCustomMessages();
if (ArrayHelper.isNotEmpty(customMessages)) {
for (String customMessage : customMessages) {
int idx = customMessage.indexOf(':');
if ((idx > 0) && (idx + 1 < customMessage.length())) {
String msgKey = customMessage.substring(0, idx).trim();
String msgValue = customMessage.substring(idx + 1).trim();
if (StringHelper.isNotEmpty(msgKey) && StringHelper.isNotEmpty(msgValue)) {
organizationCustomMessage.put(msgKey, msgValue);
}
}
}
}
cacheService.put(OxConstants.CACHE_APPLICATION_NAME, key, organizationCustomMessage);
}
return organizationCustomMessage.get(customMessageId);
}
use of org.gluu.oxtrust.model.GluuOrganization in project oxTrust by GluuFederation.
the class OrganizationService method getOrganizationCustomMessage.
/**
* Returns custom message defined for the organization
*
* @param customMessageId
* message id
* @return custom message
*/
public String getOrganizationCustomMessage(String customMessageId) {
GluuOrganization organization = getOrganization();
String key = OxTrustConstants.CACHE_ORGANIZATION_CUSTOM_MESSAGE_KEY + "_" + organization.getInum();
@SuppressWarnings("unchecked") Map<String, String> organizationCustomMessage = (Map<String, String>) cacheService.get(OxConstants.CACHE_APPLICATION_NAME, key);
if (organizationCustomMessage == null) {
organizationCustomMessage = new HashMap<String, String>();
String[] customMessages = organization.getCustomMessages();
if (ArrayHelper.isNotEmpty(customMessages)) {
for (String customMessage : customMessages) {
int idx = customMessage.indexOf(':');
if ((idx > 0) && (idx + 1 < customMessage.length())) {
String msgKey = customMessage.substring(0, idx).trim();
String msgValue = customMessage.substring(idx + 1).trim();
if (StringHelper.isNotEmpty(msgKey) && StringHelper.isNotEmpty(msgValue)) {
organizationCustomMessage.put(msgKey, msgValue);
}
}
}
}
cacheService.put(OxConstants.CACHE_APPLICATION_NAME, key, organizationCustomMessage);
}
return organizationCustomMessage.get(customMessageId);
}
use of org.gluu.oxtrust.model.GluuOrganization 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();
try {
PropertyUtils.copyProperties(this.organization, tmpOrganization);
} catch (Exception ex) {
log.error("Failed to load organization", ex);
this.organization = null;
}
} catch (BasePersistenceException ex) {
log.error("Failed to load organization", ex);
}
if (this.organization == null) {
return OxTrustConstants.RESULT_FAILURE;
}
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);
initOxAuthSetting();
configurations = new ArrayList<GluuConfiguration>();
configurations.addAll(configurationService.getConfigurations());
return OxTrustConstants.RESULT_SUCCESS;
}
Aggregations