Search in sources :

Example 1 with AMEntity

use of com.iplanet.am.sdk.AMEntity in project OpenAM by OpenRock.

the class AMClientCapData method removeClient.

/**
     * Remove a Client - removes the client from the externalDB. Valid only with
     * instance of externalDB.
     * 
     * @param token
     *            SSOToken to validate the user
     * @param clientType
     *            Client Type Name.
     * 
     * @return 0 on success
     * @exception AMClientCapException
     *                if Client could not be removed - permission problems
     */
public int removeClient(SSOToken token, String clientType) throws AMClientCapException {
    if (isInternalInstance()) {
        throw new AMClientCapException(BUNDLE_NAME, CANNOT_MOD_INT_DB, null);
    }
    try {
        AMStoreConnection localConn = new AMStoreConnection(token);
        String dn = generateClientDN(clientType);
        AMEntity amEntity = localConn.getEntity(dn);
        amEntity.delete();
    } catch (Exception e) {
        String[] errArgs = { clientType };
        AMClientCapException ace = new AMClientCapException(BUNDLE_NAME, DELETE_FAILED, errArgs);
        String msg = ace.getMessage();
        debug.error(dbStr + msg, e);
        throw ace;
    }
    return 0;
}
Also used : AMEntity(com.iplanet.am.sdk.AMEntity) AMStoreConnection(com.iplanet.am.sdk.AMStoreConnection) SSOException(com.iplanet.sso.SSOException)

Example 2 with AMEntity

use of com.iplanet.am.sdk.AMEntity in project OpenAM by OpenRock.

the class AMClientCapData method getProperties.

/**
     * Get a Map of all the properties for the Client. The Map contains key of
     * property names and a Set for the values.
     * 
     * @param clientType
     *            Client Type Name.
     * @return Map of the properties or null if client not found
     */
public Map getProperties(String clientType) {
    Map props = null;
    String dn = generateClientDN(clientType);
    try {
        AMEntity amEntity = amConnection.getEntity(dn);
        if (amEntity.isExists()) {
            Map attrsMap = amEntity.getAttributes();
            props = parsePropertyNames(attrsMap);
        }
    } catch (SSOException ssoe) {
        debug.error(dbStr + "Could not get Client, session invalid: " + clientType, ssoe);
        // admin token has timed out, retry
        adminToken = null;
        String dbName = null;
        if (isInternalInstance()) {
            dbName = INTERNAL_DATA;
        } else {
            dbName = EXTERNAL_DATA;
        }
        try {
            // call init after setting per-instance vars
            init(dbName);
            AMEntity amEntity = amConnection.getEntity(dn);
            if (amEntity.isExists()) {
                Map attrsMap = amEntity.getAttributes();
                props = parsePropertyNames(attrsMap);
            }
        } catch (Exception ex) {
            debug.error(dbStr + "Could not get Client, even after retry: " + clientType, ex);
        }
    } catch (Exception ex) {
        debug.warning(dbStr + "Could not get Client: " + clientType, ex);
    }
    return props;
}
Also used : AMEntity(com.iplanet.am.sdk.AMEntity) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map) SSOException(com.iplanet.sso.SSOException)

Example 3 with AMEntity

use of com.iplanet.am.sdk.AMEntity in project OpenAM by OpenRock.

the class EntityObjectImpl method getAMEntity.

/**
     * Method to get the AMEntity object from the storeconnection.
     */
protected AMEntity getAMEntity(String ssoToken, String entityName, String entityType, String entityLocation) throws EntityException, SSOException {
    checkInitialization();
    AMEntity amEntity;
    try {
        int type = 0;
        type = getIntTypeFromStr(entityType);
        String entDN = getEntityDN(entityName, type, entityLocation);
        String key = ssoToken + "/" + entDN;
        amEntity = (AMEntity) oCache.get(key);
        if (amEntity == null) {
            amEntity = amsc.getEntity(entDN);
            oCache.put(key, amEntity);
        }
    } catch (SSOException ssoe) {
        EntityUtils.debug.error("EntityObjectImpl.getAMEntity(): " + "Unable to convert SSOToken: " + ssoToken, ssoe);
        throw ssoe;
    }
    return amEntity;
}
Also used : AMEntity(com.iplanet.am.sdk.AMEntity) SSOException(com.iplanet.sso.SSOException)

Example 4 with AMEntity

use of com.iplanet.am.sdk.AMEntity in project OpenAM by OpenRock.

the class AMClientCapData method isClientPresent.

/**
     * Checks if the clientType exists in the db.
     * 
     * @return true if present, false otherwise
     */
public boolean isClientPresent(String clientType) {
    String dn = generateClientDN(clientType);
    boolean exists = false;
    try {
        AMEntity amEntity = amConnection.getEntity(dn);
        exists = amEntity.isExists();
    } catch (SSOException ssoe) {
    /**
             * Cannot happen since we are using the AdminToken
             */
    }
    return exists;
}
Also used : AMEntity(com.iplanet.am.sdk.AMEntity) SSOException(com.iplanet.sso.SSOException)

Example 5 with AMEntity

use of com.iplanet.am.sdk.AMEntity in project OpenAM by OpenRock.

the class AMClientCapData method loadMinimalClient.

/**
     * Gets the minimal client info for the specified client.
     */
public Map loadMinimalClient(String clientType) {
    Map props = null;
    String dn = generateClientDN(clientType);
    try {
        AMEntity amEntity = amConnection.getEntity(dn);
        if (amEntity.isExists()) {
            Map attrsMap = amEntity.getAttributes(minClient);
            props = parsePropertyNames(attrsMap);
        }
    } catch (Exception e) {
        debug.warning(dbStr + "Could not get Client: " + clientType, e);
    }
    return props;
}
Also used : AMEntity(com.iplanet.am.sdk.AMEntity) HashMap(java.util.HashMap) Map(java.util.Map) SSOException(com.iplanet.sso.SSOException)

Aggregations

AMEntity (com.iplanet.am.sdk.AMEntity)7 SSOException (com.iplanet.sso.SSOException)6 HashMap (java.util.HashMap)3 Map (java.util.Map)3 AMStoreConnection (com.iplanet.am.sdk.AMStoreConnection)2 AMException (com.iplanet.am.sdk.AMException)1