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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations