use of com.sun.identity.sm.SMSEntry in project OpenAM by OpenRock.
the class ResourceTypeConfigurationImpl method storeResourceType.
/**
* {@inheritDoc}
*/
@Override
public void storeResourceType(Subject subject, String realm, ResourceType resourceType) throws EntitlementException {
final String uuid = resourceType.getUUID();
createResourceTypeCollectionConfig(subject, realm, uuid);
final SSOToken token = SubjectUtils.getSSOToken(subject);
try {
final SMSEntry entry = new SMSEntry(token, getResourceTypeDN(realm, uuid));
final String[] logParams = { realm, uuid };
entry.setAttributes(getResourceTypeData(resourceType));
OpenSSOLogger.log(MESSAGE, Level.INFO, ATTEMPT_SAVE_RESOURCE_TYPE, logParams, subject);
entry.save();
OpenSSOLogger.log(MESSAGE, Level.INFO, SUCCEEDED_SAVE_RESOURCE_TYPE, logParams, subject);
} catch (SMSException ex) {
handleSaveException(subject, realm, uuid, ex);
} catch (SSOException ex) {
handleSaveException(subject, realm, uuid, ex);
}
}
use of com.sun.identity.sm.SMSEntry in project OpenAM by OpenRock.
the class DataStore method removeReferral.
/**
* Removes referral privilege.
*
* @param adminSubject Admin Subject who has the rights to write to
* datastore.
* @param realm Realm name.
* @param name Referral privilege name.
* @throws EntitlementException if privilege cannot be removed.
*/
public void removeReferral(Subject adminSubject, String realm, String name) throws EntitlementException {
SSOToken token = getSSOToken(adminSubject);
if (token == null) {
Object[] arg = { name };
throw new EntitlementException(55, arg);
}
String dn = null;
try {
dn = getPrivilegeDistinguishedName(name, realm, REFERRAL_STORE);
if (SMSEntry.checkIfEntryExists(dn, token)) {
SMSEntry s = new SMSEntry(token, dn);
s.delete();
updateIndexCount(realm, -1, true);
Map<String, String> params = new HashMap<String, String>();
params.put(NotificationServlet.ATTR_NAME, name);
params.put(NotificationServlet.ATTR_REALM_NAME, realm);
Notifier.submit(NotificationServlet.REFERRAL_DELETED, params);
}
} catch (SMSException e) {
Object[] arg = { dn };
throw new EntitlementException(51, arg, e);
} catch (SSOException e) {
throw new EntitlementException(10, null, e);
}
}
use of com.sun.identity.sm.SMSEntry 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;
}
Aggregations