Search in sources :

Example 11 with SMSEntry

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();
}
Also used : SMSEntry(com.sun.identity.sm.SMSEntry) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry)

Example 12 with SMSEntry

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();
}
Also used : SMSEntry(com.sun.identity.sm.SMSEntry) CachedSMSEntry(com.sun.identity.sm.CachedSMSEntry)

Example 13 with SMSEntry

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

Example 14 with SMSEntry

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);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) JSONObject(org.json.JSONObject) SMSException(com.sun.identity.sm.SMSException) JSONArray(org.json.JSONArray) CoreTokenException(com.sun.identity.coretoken.CoreTokenException) SMSEntry(com.sun.identity.sm.SMSEntry) SSOException(com.iplanet.sso.SSOException)

Example 15 with SMSEntry

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

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