Search in sources :

Example 16 with ServiceManager

use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.

the class AMClientCapData method init.

/**
     * 1. get the admin token (or create one) 2. Create a ServiceManager 3. Get
     * the ServiceSchemaManager for the service 4. Get the ServiceSchema for the
     * Global schema 5. Get the schema for the "internalData" schema. (temp
     * var). 6. Get the schema for the "clientData" schema id. (overwrite 8). 7.
     * Get the ROOT_SUFFIX 8. Read config info & properties schema from
     * ServiceSchema 9. Add Listeners to EventService.
     */
private synchronized void init(String instanceRDN) throws Exception {
    // "SunAMClientData"
    String srvcName = getServiceName();
    if (adminToken == null) {
        // single static instance
        adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
        // (2)
        sManager = new ServiceManager(adminToken);
        ServiceSchemaManager schemaManager = sManager.getSchemaManager(srvcName, // (3)
        SERVICE_VERSION);
        // (4)
        clientServiceSchema = schemaManager.getGlobalSchema();
        //
        // the internalDB & externalDB share the same schema (5)
        //
        clientSchema = clientServiceSchema.getSubSchema(DBSTORE_SUBSCHEMA_ID);
        //(6)
        clientSchema = clientSchema.getSubSchema(CLIENT_SUBSCHEMA_ID);
        amConnection = new AMStoreConnection(adminToken);
        // (7)
        topLevelDN = amConnection.getOrganizationDN(null, null);
        // (8)
        initClientSchema();
        initConfigurationInfo(clientServiceSchema);
        clientDataDN = CLIENT_DATA_DN_PREFIX + COMMA + topLevelDN;
    // TBD : Commented so that persistant search is not setup to
    // directory server when running in remote client SDK mode.
    // This is temporary fix. Proper fix for this problem is TBD.
    // initEventListeners (adminToken, clientDataDN); // (9)
    }
    databaseDN = instanceRDN + COMMA + clientDataDN;
    amClientOrg = amConnection.getOrganizationalUnit(databaseDN);
}
Also used : AMStoreConnection(com.iplanet.am.sdk.AMStoreConnection) ServiceManager(com.sun.identity.sm.ServiceManager) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 17 with ServiceManager

use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.

the class ImportConfig method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("usage: serverAdmin import xmlFile");
        System.exit(1);
    }
    if (args[0].equals("import")) {
        try {
            FileInputStream fisSchema = new FileInputStream(args[1]);
            DSConfigMgr cfgMgr = DSConfigMgr.getDSConfigMgr();
            ServerInstance sInst = cfgMgr.getServerInstance(LDAPUser.Type.AUTH_ADMIN);
            authPcpl = new AuthPrincipal(sInst.getAuthID());
            AuthContext authCtx = new AuthContext(authPcpl, sInst.getPasswd().toCharArray());
            SSOToken userSSOToken = authCtx.getSSOToken();
            ServiceManager smsMgr = new ServiceManager(userSSOToken);
            smsMgr.registerServices(fisSchema);
        } catch (Exception e) {
            e.printStackTrace();
            System.err.println(e);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceManager(com.sun.identity.sm.ServiceManager) DSConfigMgr(com.iplanet.services.ldap.DSConfigMgr) AuthContext(com.sun.identity.authentication.internal.AuthContext) AuthPrincipal(com.sun.identity.authentication.internal.AuthPrincipal) ServerInstance(com.iplanet.services.ldap.ServerInstance) FileInputStream(java.io.FileInputStream)

Example 18 with ServiceManager

use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.

the class AMIdentity method getAssignableServices.

/**
     * Returns all services which can be assigned to this entity.
     *
     * This method is only valid for AMIdentity object of type User.
     *
     * @return Set of service names
     * @throws IdRepoException
     *             if there are repository related error conditions.
     * @throws SSOException
     *             If user's single sign on token is invalid.
     * @supported.api
     */
public Set getAssignableServices() throws IdRepoException, SSOException {
    // Get all service names for the type from SMS
    ServiceManager sm;
    try {
        sm = new ServiceManager(token);
    } catch (SMSException smse) {
        throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.SERVICE_MANAGER_INITIALIZATION_FAILED, null);
    }
    Map sMap = sm.getServiceNamesAndOCs(type.getName());
    // Get the list of assigned services
    IdServices idServices = IdServicesFactory.getDataStoreServices();
    Set assigned = Collections.EMPTY_SET;
    try {
        assigned = idServices.getAssignedServices(token, type, name, sMap, orgName, univDN);
    } catch (IdRepoException ide) {
        // Check if this is permission denied exception
        if (!ide.getErrorCode().equals(IdRepoErrorCode.ACCESS_DENIED)) {
            throw (ide);
        } else {
            // Return the empty set
            return (assigned);
        }
    }
    // Return the difference
    Set keys = sMap.keySet();
    keys.removeAll(assigned);
    return (keys);
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) ServiceManager(com.sun.identity.sm.ServiceManager) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map)

Example 19 with ServiceManager

use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.

the class AMIdentity method getAssignedServices.

// SERVICE RELATED APIS
/**
     * Returns the set of services already assigned to this identity.
     *
     * This method is only valid for AMIdentity object of type User.
     *
     * @return Set of serviceNames
     * @throws IdRepoException
     *             If there are repository related error conditions.
     * @throws SSOException
     *             If user's single sign on token is invalid.
     * @supported.api
     */
public Set getAssignedServices() throws IdRepoException, SSOException {
    // Get all service names for the type from SMS
    ServiceManager sm;
    try {
        sm = new ServiceManager(token);
    } catch (SMSException smse) {
        debug.error("Error while creating Service manager:", smse);
        throw new IdRepoException(IdRepoBundle.BUNDLE_NAME, IdRepoErrorCode.SERVICE_MANAGER_INITIALIZATION_FAILED, null);
    }
    Map sMap = sm.getServiceNamesAndOCs(type.getName());
    // Get the list of assigned services
    IdServices idServices = IdServicesFactory.getDataStoreServices();
    Set assigned = Collections.EMPTY_SET;
    try {
        assigned = idServices.getAssignedServices(token, type, name, sMap, orgName, univDN);
    } catch (IdRepoException ide) {
        // Check if this is permission denied exception
        if (!ide.getErrorCode().equals(IdRepoErrorCode.ACCESS_DENIED)) {
            throw (ide);
        }
    }
    return (assigned);
}
Also used : CaseInsensitiveHashSet(com.sun.identity.common.CaseInsensitiveHashSet) HashSet(java.util.HashSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) ServiceManager(com.sun.identity.sm.ServiceManager) AMHashMap(com.iplanet.am.sdk.AMHashMap) HashMap(java.util.HashMap) CaseInsensitiveHashMap(com.sun.identity.common.CaseInsensitiveHashMap) Map(java.util.Map)

Example 20 with ServiceManager

use of com.sun.identity.sm.ServiceManager in project OpenAM by OpenRock.

the class UpgradeUtils method createService.

public static void createService(String xml, SSOToken adminSSOToken) throws UpgradeException {
    String classMethod = "UpgradeUtils:createService : ";
    InputStream serviceStream = null;
    try {
        ServiceManager serviceManager = new ServiceManager(adminSSOToken);
        serviceStream = (InputStream) new ByteArrayInputStream(xml.getBytes());
        serviceManager.registerServices(serviceStream);
    } catch (SSOException ssoe) {
        debug.error(classMethod + ssoe.getMessage());
        throw new UpgradeException(ssoe);
    } catch (SMSException smse) {
        debug.error(classMethod + smse.getMessage());
        throw new UpgradeException(smse);
    } finally {
        if (serviceStream != null) {
            try {
                serviceStream.close();
            } catch (IOException ioe) {
                throw new UpgradeException(ioe);
            }
        }
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) SMSException(com.sun.identity.sm.SMSException) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ServiceManager(com.sun.identity.sm.ServiceManager) SSOException(com.iplanet.sso.SSOException) ByteString(org.forgerock.opendj.ldap.ByteString) IOException(java.io.IOException)

Aggregations

ServiceManager (com.sun.identity.sm.ServiceManager)34 SMSException (com.sun.identity.sm.SMSException)20 SSOException (com.iplanet.sso.SSOException)17 SSOToken (com.iplanet.sso.SSOToken)11 IOException (java.io.IOException)10 CLIException (com.sun.identity.cli.CLIException)7 Iterator (java.util.Iterator)7 Set (java.util.Set)7 IOutput (com.sun.identity.cli.IOutput)6 FileInputStream (java.io.FileInputStream)6 HashSet (java.util.HashSet)6 ByteString (org.forgerock.opendj.ldap.ByteString)5 AMEncryption (com.iplanet.services.util.AMEncryption)4 ConfigurableKey (com.iplanet.services.util.ConfigurableKey)4 JCEEncryption (com.iplanet.services.util.JCEEncryption)4 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 InputStream (java.io.InputStream)4 List (java.util.List)4 AMException (com.iplanet.am.sdk.AMException)3