use of javax.servlet.ServletContext in project OpenAM by OpenRock.
the class CreateFedlet method execute.
public String execute(Locale locale, Map params) throws WorkflowException {
validateParameters(params);
String entityId = getString(params, ParameterKeys.P_ENTITY_ID);
Pattern patern = Pattern.compile("[/:\\.?|*]");
Matcher match = patern.matcher(entityId);
String folderName = match.replaceAll("");
String workDir = SystemProperties.get(SystemProperties.CONFIG_PATH) + "/myfedlets/" + folderName;
File dir = new File(workDir);
if (dir.exists()) {
throw new WorkflowException("directory.already.exist", workDir);
}
if (!dir.getParentFile().exists()) {
dir.getParentFile().mkdir();
}
dir.mkdir();
String warDir = workDir + "/war";
dir = new File(warDir);
dir.mkdir();
String confDir = warDir + "/conf";
dir = new File(confDir);
dir.mkdir();
loadMetaData(params, confDir);
exportIDPMetaData(params, confDir);
createCOTProperties(params, confDir);
ServletContext servletCtx = (ServletContext) params.get(ParameterKeys.P_SERVLET_CONTEXT);
copyBits(servletCtx, workDir);
extractJars(servletCtx, warDir);
createFederationConfigProperties(servletCtx, confDir);
createWar(workDir);
String zipFileName = createZip(workDir);
return MessageFormat.format(getMessage("Fedlet.created", locale), zipFileName);
}
use of javax.servlet.ServletContext in project OpenAM by OpenRock.
the class AMSetupFilterTest method initShouldNotSetEncryptionPasswordIfConfigured.
@Test
public void initShouldNotSetEncryptionPasswordIfConfigured() throws Exception {
//Given
FilterConfig config = mock(FilterConfig.class);
ServletContext context = mock(ServletContext.class);
given(config.getServletContext()).willReturn(context);
systemIsConfigured();
//When
setupFilter.init(config);
//Then
verifyZeroInteractions(context);
}
use of javax.servlet.ServletContext in project OpenAM by OpenRock.
the class AMSetupUtilsTest method readFileShouldThrowIOExceptionIfFileNotFound.
@Test(expectedExceptions = IOException.class)
public void readFileShouldThrowIOExceptionIfFileNotFound() throws IOException {
//Given
ServletContext context = mock(ServletContext.class);
String file = "INVALID_FILE_NAME";
//When
readFile(context, file);
//Then
failBecauseExceptionWasNotThrown(IOException.class);
}
use of javax.servlet.ServletContext in project OpenAM by OpenRock.
the class IDRepoAddViewBean method handleButton2Request.
/**
* Handles create realm request.
*
* @param event Request invocation event
*/
public void handleButton2Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
IDRepoModel model = (IDRepoModel) getModel();
AMPropertySheet prop = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
String idRepoType = (String) propertySheetModel.getValue(IDREPO_TYPE);
String idRepoName = (String) propertySheetModel.getValue(IDREPO_NAME);
Map defaultValues = model.getDefaultAttributeValues(idRepoType);
if (idRepoName.trim().length() > 0) {
try {
boolean LoadSchema = false;
Map values = prop.getAttributeValues(defaultValues.keySet());
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
Set set = (HashSet) values.get("idRepoLoadSchema");
if (set != null) {
Iterator i = set.iterator();
if (i.hasNext()) {
String loadingSchemaFlag = (String) i.next();
if (loadingSchemaFlag.equals("true") && IdRepoUtils.hasIdRepoSchema(idRepoType)) {
LoadSchema = true;
}
}
}
model.createIDRepo(realmName, idRepoName, idRepoType, values);
if (LoadSchema == true) {
ServletContext servletCtx = event.getRequestContext().getServletContext();
model.loadIdRepoSchema(idRepoName, realmName, servletCtx);
}
forwardToIDRepoViewBean();
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
forwardTo();
}
} else {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "idrepo.missing.idRepoName");
forwardTo();
}
}
use of javax.servlet.ServletContext in project OpenAM by OpenRock.
the class IDRepoEditViewBean method handleButton1Request.
/**
* Handles save request when editing the properties of a data store
* entry for a realm.
*
* @param event Request invocation event
*/
public void handleButton1Request(RequestInvocationEvent event) throws ModelControlException {
submitCycle = true;
IDRepoModel model = (IDRepoModel) getModel();
AMPropertySheet prop = (AMPropertySheet) getChild(PROPERTY_ATTRIBUTE);
String idRepoType = (String) propertySheetModel.getValue(IDREPO_TYPE);
String idRepoName = (String) propertySheetModel.getValue(IDREPO_NAME);
Map defaultValues = model.getDefaultAttributeValues(idRepoType);
if (idRepoName.trim().length() > 0) {
try {
boolean LoadSchema = false;
Map values = prop.getAttributeValues(defaultValues.keySet());
String realmName = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
values.remove(IdConstants.SERVICE_ATTRS);
Set set = (HashSet) values.get("idRepoLoadSchema");
if (set != null) {
Iterator i = set.iterator();
if (i.hasNext()) {
String loadingSchemaFlag = (String) i.next();
if (loadingSchemaFlag.equals("true") && IdRepoUtils.hasIdRepoSchema(idRepoType)) {
LoadSchema = true;
}
}
}
model.editIDRepo(realmName, idRepoName, values);
if (LoadSchema == true) {
ServletContext servletCtx = event.getRequestContext().getServletContext();
model.loadIdRepoSchema(idRepoName, realmName, servletCtx);
}
setInlineAlertMessage(CCAlert.TYPE_INFO, "message.information", "message.updated");
} catch (AMConsoleException e) {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
}
} else {
setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", "idrepo.missing.idRepoName");
}
forwardTo();
}
Aggregations