Search in sources :

Example 21 with SMSEntry

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);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) SMSException(com.sun.identity.sm.SMSException) SMSEntry(com.sun.identity.sm.SMSEntry) SSOException(com.iplanet.sso.SSOException)

Example 22 with SMSEntry

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);
    }
}
Also used : EntitlementException(com.sun.identity.entitlement.EntitlementException) SSOToken(com.iplanet.sso.SSOToken) HashMap(java.util.HashMap) SMSException(com.sun.identity.sm.SMSException) JSONObject(org.json.JSONObject) SMSEntry(com.sun.identity.sm.SMSEntry) SSOException(com.iplanet.sso.SSOException)

Example 23 with SMSEntry

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;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceConfig(com.sun.identity.sm.ServiceConfig) SMSEntry(com.sun.identity.sm.SMSEntry) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry) Properties(java.util.Properties) SystemProperties(com.iplanet.am.util.SystemProperties) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) MissingResourceException(java.util.MissingResourceException) SSOException(com.iplanet.sso.SSOException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) NamingException(javax.naming.NamingException) UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) PolicyException(com.sun.identity.policy.PolicyException) LDAPServiceException(com.iplanet.services.ldap.LDAPServiceException) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) IdRepoException(com.sun.identity.idm.IdRepoException) SMSException(com.sun.identity.sm.SMSException) MalformedURLException(java.net.MalformedURLException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry)

Aggregations

SMSEntry (com.sun.identity.sm.SMSEntry)23 SSOException (com.iplanet.sso.SSOException)18 SMSException (com.sun.identity.sm.SMSException)18 SSOToken (com.iplanet.sso.SSOToken)16 EntitlementException (com.sun.identity.entitlement.EntitlementException)11 Set (java.util.Set)10 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 CoreTokenException (com.sun.identity.coretoken.CoreTokenException)5 PolicyException (com.sun.identity.policy.PolicyException)5 ApplicationPrivilegeManager (com.sun.identity.entitlement.ApplicationPrivilegeManager)4 PrivilegeIndexStore (com.sun.identity.entitlement.PrivilegeIndexStore)4 CachedSMSEntry (com.sun.identity.sm.CachedSMSEntry)4 JSONObject (org.json.JSONObject)4 IPrivilege (com.sun.identity.entitlement.IPrivilege)3 ResourceSaveIndexes (com.sun.identity.entitlement.ResourceSaveIndexes)2 Policy (com.sun.identity.policy.Policy)2 Collections.emptySet (java.util.Collections.emptySet)2 SystemProperties (com.iplanet.am.util.SystemProperties)1 LDAPServiceException (com.iplanet.services.ldap.LDAPServiceException)1