use of com.sun.identity.sm.SMSEntry in project OpenAM by OpenRock.
the class SMSJAXRPCObjectImpl method create.
/**
* Creates an entry in the persistent store. Throws an exception if the
* entry already exists
*/
public void create(String tokenID, String objName, Map attributes) throws SMSException, SSOException, RemoteException {
initialize();
if (debug.messageEnabled()) {
debug.message("SMSJAXRPCObjectImpl::create dn: " + objName);
}
SMSEntry entry = new SMSEntry(getToken(tokenID), objName);
entry.setAttributes(attributes);
entry.save();
}
use of com.sun.identity.sm.SMSEntry in project OpenAM by OpenRock.
the class SMSJAXRPCObjectImpl method modify.
/**
* Modifies the attributes to the object.
*/
public void modify(String tokenID, String objName, String mods) throws SMSException, SSOException, RemoteException {
initialize();
if (debug.messageEnabled()) {
debug.message("SMSJAXRPCObjectImpl::modify dn: " + objName);
}
SMSEntry entry = new SMSEntry(getToken(tokenID), objName);
entry.modifyAttributes(getModItems(mods));
entry.save();
}
use of com.sun.identity.sm.SMSEntry in project OpenAM by OpenRock.
the class OpenSSOCoreTokenStore method deleteToken.
/**
*
* @param subject
* @param tokenId
* @throws CoreTokenException
* @throws JSONException
*/
public void deleteToken(Subject subject, String tokenId) throws CoreTokenException {
SSOToken adminToken = SubjectUtils.getSSOToken(subject);
String dn = getCoreTokenDN(tokenId);
if (adminToken == null) {
throw new CoreTokenException(211, null, 401);
}
if (!SMSEntry.checkIfEntryExists(dn, adminToken)) {
throw new CoreTokenException(203, null, 404);
}
try {
SMSEntry s = new SMSEntry(adminToken, dn);
s.delete();
} catch (SSOException ex) {
CoreTokenUtils.debug.error("OpenSSOCoreTokenStore.deleteToken", ex);
throw new CoreTokenException(205, null, ex);
} catch (SMSException ex) {
CoreTokenUtils.debug.error("OpenSSOCoreTokenStore.deleteToken", ex);
throw new CoreTokenException(205, null, ex);
}
}
use of com.sun.identity.sm.SMSEntry in project OpenAM by OpenRock.
the class OpenSSOCoreTokenStore method createToken.
/**
*
* @param subject
* @param attributes
* @return the created token in JSON format
* @throws CoreTokenException
* @throws JSONException
*/
public String createToken(Subject subject, JSONObject attributes) throws CoreTokenException, JSONException {
SSOToken adminToken = SubjectUtils.getSSOToken(subject);
if (adminToken == null) {
throw new CoreTokenException(212, null, 401);
}
String tokenId = null;
try {
// validate attribute names and convert to lower case
attributes = validateAndToLowerCase(attributes);
if (attributes.has(CoreTokenConstants.TOKEN_ID)) {
throw new CoreTokenException(201, null, 409);
}
tokenId = UUID.randomUUID().toString();
String dn = getCoreTokenDN(tokenId);
SMSEntry s = new SMSEntry(adminToken, dn);
Map<String, Set<String>> map = validateAndCreateMap(tokenId, attributes);
s.setAttributes(map);
s.save();
JSONObject json = new JSONObject();
JSONArray jArray = new JSONArray();
jArray.put(tokenId);
json.put(CoreTokenConstants.TOKEN_ID, jArray);
return json.toString();
} catch (SSOException e) {
CoreTokenUtils.debug.error("OpenSSOTokenStore.createToken", e);
throw new CoreTokenException(202, null, e);
} catch (SMSException e) {
CoreTokenUtils.debug.error("OpenSSOTokenStore.createToken", e);
throw new CoreTokenException(202, null, e);
}
}
use of com.sun.identity.sm.SMSEntry in project OpenAM by OpenRock.
the class OpenSSOCoreTokenStore method readToken.
/**
*
* @param adminSubject
* @param tokenId
* @return token value from SM with the given tokenId
* @throws CoreTokenException
*/
public String readToken(Subject adminSubject, String tokenId) throws CoreTokenException {
SSOToken adminToken = SubjectUtils.getSSOToken(adminSubject);
if (adminToken == null) {
throw new CoreTokenException(209, null, 401);
}
String dn = getCoreTokenDN(tokenId);
if (!SMSEntry.checkIfEntryExists(dn, adminToken)) {
throw new CoreTokenException(203, null, 404);
}
try {
SMSEntry s = new SMSEntry(adminToken, dn);
return getTokenAttributeValueFromSM(s, JSON_ATTR);
} catch (SSOException ex) {
CoreTokenUtils.debug.error("OpenSSOCoreTokenStore.read", ex);
throw new CoreTokenException(204, null, ex);
} catch (SMSException ex) {
CoreTokenUtils.debug.error("OpenSSOCoreTokenStore.read", ex);
throw new CoreTokenException(204, null, ex);
}
}
Aggregations