use of com.sun.identity.sm.CachedSMSEntry in project OpenAM by OpenRock.
the class AMSetupServlet method configure.
private static boolean configure(IHttpServletRequest request, Map<String, Object> map, Map<String, Object> userRepo) throws Exception {
boolean configured;
boolean existingConfiguration = false;
try {
String basedir = (String) map.get(SetupConstants.CONFIG_VAR_BASE_DIR);
checkBaseDir(basedir, request);
boolean isDITLoaded = setupSMDatastore(map);
String serverURL = (String) map.get(SetupConstants.CONFIG_VAR_SERVER_URL);
String deployuri = (String) map.get(SetupConstants.CONFIG_VAR_SERVER_URI);
// do this here since initializeConfigProperties needs the dir
setupSecurIDDirs(basedir, deployuri);
SetupProgress.reportStart("configurator.progress.reinit.system", null);
Map mapFileNameToConfig = initializeConfigProperties();
String strAMConfigProperties = (String) mapFileNameToConfig.get(SetupConstants.AMCONFIG_PROPERTIES);
String strServerConfigXML = (String) mapFileNameToConfig.get(SystemProperties.CONFIG_FILE_NAME);
Properties propAMConfig = ServerConfiguration.getProperties(strAMConfigProperties);
// Set the install property since reInitConfigProperties
// initializes SMS which inturn initializes EventService
propAMConfig.put(Constants.SYS_PROPERTY_INSTALL_TIME, "true");
String serverInstanceName = serverURL + deployuri;
reInitConfigProperties(serverInstanceName, propAMConfig, strServerConfigXML);
// SystemProperties gets reinitialized and installTime property
// has to set again
SystemProperties.initializeProperties(Constants.SYS_PROPERTY_INSTALL_TIME, "true");
SetupProgress.reportEnd("emb.done", null);
SSOToken adminSSOToken = getAdminSSOToken();
if (!isDITLoaded) {
RegisterServices regService = new RegisterServices();
boolean bUseExtUMDS = userRepo != null && !userRepo.isEmpty();
regService.registers(adminSSOToken, bUseExtUMDS);
processDataRequests("/WEB-INF/template/sms");
}
// Set installTime to false, to avoid in-memory notification from
// SMS in cases where not needed, and to denote that service
// registration got completed during configuration phase and it
// has passed installtime.
SystemProperties.initializeProperties(Constants.SYS_PROPERTY_INSTALL_TIME, "false");
configureServerInstance(adminSSOToken, serverInstanceName, strAMConfigProperties, isDITLoaded, basedir, strServerConfigXML, propAMConfig, map);
// Embedded :get our serverid and configure embedded idRepo
String dataStore = (String) map.get(SetupConstants.CONFIG_VAR_DATA_STORE);
boolean embedded = dataStore.equals(SetupConstants.SMS_EMBED_DATASTORE);
// Ensure this service are initialized before continuing
WebtopNaming.initialize();
NamingService.initialize();
if (embedded) {
try {
String serverID = WebtopNaming.getAMServerID();
String entry = map.get(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_HOST) + ":" + map.get(SetupConstants.CONFIG_VAR_DIRECTORY_SERVER_PORT) + "|" + (serverID == null ? "" : serverID);
String orgName = (String) map.get(SetupConstants.SM_CONFIG_ROOT_SUFFIX);
updateEmbeddedIdRepo(orgName, "embedded", entry);
} catch (Exception ex) {
Debug.getInstance(SetupConstants.DEBUG_NAME).error("EmbeddedDS : failed to setup serverid", ex);
throw ex;
}
}
SystemProperties.setServerInstanceName(serverInstanceName);
LDIFTemplates.copy(basedir, servletCtx);
ServiceXMLTemplates.copy(basedir + "/template/xml", servletCtx);
createDotVersionFile(basedir);
handlePostPlugins(adminSSOToken);
if (!isDITLoaded && userRepo != null && !userRepo.isEmpty()) {
// Construct the SMSEntry for the node to check to
// see if this is an existing configuration store,
// or new store.
ServiceConfig sc = UserIdRepo.getOrgConfig(adminSSOToken);
if (sc != null) {
CachedSMSEntry cEntry = CachedSMSEntry.getInstance(adminSSOToken, "ou=" + userRepo.get("userStoreHostName") + "," + sc.getDN());
SMSEntry entry = cEntry.getClonedSMSEntry();
if (entry.isNewEntry()) {
UserIdRepo.getInstance().configure(userRepo, basedir, servletCtx, adminSSOToken);
} else {
existingConfiguration = true;
}
}
}
// postInitialize requires the user repo to be configured
postInitialize(adminSSOToken);
/*
* Requiring the keystore.jks file in OpenAM workspace.
* The createIdentitiesForWSSecurity is for the
* JavaEE/NetBeans integration that we had done.
*/
createPasswordFiles(basedir, deployuri);
if (!isDITLoaded) {
if ((userRepo == null) || userRepo.isEmpty()) {
createDemoUser();
}
}
String aceDataDir = basedir + "/" + deployuri + "/auth/ace/data";
copyAuthSecurIDFiles(aceDataDir);
createMonitoringAuthFile(basedir, deployuri);
isConfiguredFlag = true;
configured = true;
} catch (Exception e) {
// catch all because we want all exception to be logged
Debug.getInstance(SetupConstants.DEBUG_NAME).error("AMSetupServlet.configure: error", e);
errorMessage = e.getMessage();
throw e;
}
return configured;
}
use of com.sun.identity.sm.CachedSMSEntry in project OpenAM by OpenRock.
the class SMSJAXRPCObjectImpl method read.
/**
* Returns the attribute names and values of the provided object using the
* identity of the provided SSO Token
*/
public Map read(String tokenID, String objName) throws SMSException, SSOException, RemoteException {
initialize();
if (debug.messageEnabled()) {
debug.message("SMSJAXRPCObjectImpl::read dn: " + objName);
}
Map returnAttributes = null;
if (objName.equals("o=" + SMSJAXRPCObject.AMJAXRPCVERSIONSTR)) {
returnAttributes = new HashMap();
returnAttributes.put(SMSJAXRPCObject.AMJAXRPCVERSIONSTR, SMSJAXRPCObject.AMJAXRPCVERSION);
} else {
CachedSMSEntry ce = CachedSMSEntry.getInstance(getToken(tokenID), objName);
if (ce.isDirty()) {
ce.refresh();
}
Map attrs = ce.getSMSEntry().getAttributes();
if ((attrs != null) && (attrs instanceof CaseInsensitiveHashMap)) {
returnAttributes = new HashMap();
for (Iterator items = attrs.keySet().iterator(); items.hasNext(); ) {
String attrName = items.next().toString();
Object o = attrs.get(attrName);
returnAttributes.put(attrName, o);
}
} else {
// could be null or instance of HashMap - return as it is.
returnAttributes = attrs;
}
}
return returnAttributes;
}
use of com.sun.identity.sm.CachedSMSEntry in project OpenAM by OpenRock.
the class SMSJAXRPCObjectImpl method entryExists.
/**
* Checks if the provided DN exists. Used by PolicyManager.
*/
public boolean entryExists(String tokenID, String objName) throws SSOException, RemoteException {
initialize();
if (debug.messageEnabled()) {
debug.message("SMSJAXRPCObjectImpl::exists dn: " + objName);
}
boolean entryExists = false;
try {
CachedSMSEntry ce = CachedSMSEntry.getInstance(getToken(tokenID), objName);
if (ce.isDirty()) {
ce.refresh();
}
entryExists = !(ce.getSMSEntry().isNewEntry());
} catch (SMSException smse) {
// Ignore the exception
}
return (entryExists);
}
Aggregations