Search in sources :

Example 6 with DataStoreProvider

use of com.sun.identity.plugin.datastore.DataStoreProvider in project OpenAM by OpenRock.

the class FSDefaultAttributePlugin method getAttributeValue.

private String getAttributeValue(Object token, String attrName) {
    if (attrName == null) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Value: attribute Name is null. Check the attribute map");
        return null;
    }
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        String userID = sessionProvider.getPrincipalName(token);
        DataStoreProvider dsProvider = DataStoreProviderManager.getInstance().getDataStoreProvider(IFSConstants.IDFF);
        Set attrValues = dsProvider.getAttribute(userID, attrName);
        if (attrValues == null || attrValues.isEmpty()) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Value: values not found for : " + attrName);
            }
            return null;
        }
        return (String) attrValues.iterator().next();
    } catch (SessionException se) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttributeValue: exception:", se);
    } catch (DataStoreProviderException dspe) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttributeValue: exception: ", dspe);
    }
    return null;
}
Also used : DataStoreProviderException(com.sun.identity.plugin.datastore.DataStoreProviderException) Set(java.util.Set) DataStoreProvider(com.sun.identity.plugin.datastore.DataStoreProvider) SessionException(com.sun.identity.plugin.session.SessionException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Example 7 with DataStoreProvider

use of com.sun.identity.plugin.datastore.DataStoreProvider in project OpenAM by OpenRock.

the class UserDiscoEntryHandler method getDiscoEntries.

/**
     * Finds discovery entries for a user under user entry.
     * @param userID The user whose discovery entries will be returned.
     * @param reqServiceTypes List of
     *  <code>com.sun.identity.liberty.ws.disco.jaxb.RequestedServiceType</code>
     *  objects from discovery query.
     * @return Map of <code>entryId</code> and 
     *  <code>com.sun.identity.liberty.ws.disco.plugins.jaxb.DiscoEntryElement
     *  </code> for this user. For each <code>DiscoEntry</code> element in the
     *  List, the <code>entryId</code> attribute of ResourceOffering need to
     *  be set.
     */
public Map getDiscoEntries(String userID, List reqServiceTypes) {
    DiscoEntryHandlerImplUtils.debug.message("in UserDiscoEntryHandler.getDiscoEntries");
    Map results = new HashMap();
    try {
        DataStoreProvider store = DataStoreProviderManager.getInstance().getDataStoreProvider(DISCO);
        if (DiscoEntryHandlerImplUtils.getUserDiscoEntries(store, userID, USER_ATTR_NAME, results)) {
            // or amadmin, and entryID was not set
            if (!DiscoEntryHandlerImplUtils.setUserDiscoEntries(store, userID, USER_ATTR_NAME, results.values())) {
                DiscoEntryHandlerImplUtils.debug.error("UserDiscoEntryHandler.getDiscoEntries: " + "couldn't set missing entryID to entry.");
            }
        }
        results = DiscoEntryHandlerImplUtils.getQueryResults(results, reqServiceTypes);
    } catch (Exception e) {
        DiscoEntryHandlerImplUtils.debug.error("UserDiscoEntryHandler.getDiscoEntries:", e);
    }
    return results;
}
Also used : HashMap(java.util.HashMap) DataStoreProvider(com.sun.identity.plugin.datastore.DataStoreProvider) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with DataStoreProvider

use of com.sun.identity.plugin.datastore.DataStoreProvider in project OpenAM by OpenRock.

the class FSDefaultRealmAttributePlugin method getAttributeValue.

private String getAttributeValue(Object token, String attrName) {
    if (attrName == null) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttribute" + "Value: attribute Name is null. Check the attribute map");
        return null;
    }
    try {
        SessionProvider sessionProvider = SessionManager.getProvider();
        String userID = sessionProvider.getPrincipalName(token);
        DataStoreProvider dsProvider = DataStoreProviderManager.getInstance().getDataStoreProvider(IFSConstants.IDFF);
        Set attrValues = dsProvider.getAttribute(userID, attrName);
        if (attrValues == null || attrValues.isEmpty()) {
            if (FSUtils.debug.messageEnabled()) {
                FSUtils.debug.message("FSDefaultAttributePlugin.getAttribute" + "Value: values not found for : " + attrName);
            }
            return null;
        }
        return (String) attrValues.iterator().next();
    } catch (SessionException se) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttributeValue: exception:", se);
    } catch (DataStoreProviderException dspe) {
        FSUtils.debug.error("FSDefaultAttributePlugin.getAttributeValue: exception: ", dspe);
    }
    return null;
}
Also used : DataStoreProviderException(com.sun.identity.plugin.datastore.DataStoreProviderException) Set(java.util.Set) DataStoreProvider(com.sun.identity.plugin.datastore.DataStoreProvider) SessionException(com.sun.identity.plugin.session.SessionException) SessionProvider(com.sun.identity.plugin.session.SessionProvider)

Aggregations

DataStoreProvider (com.sun.identity.plugin.datastore.DataStoreProvider)8 Set (java.util.Set)7 DataStoreProviderException (com.sun.identity.plugin.datastore.DataStoreProviderException)5 SessionException (com.sun.identity.plugin.session.SessionException)5 Map (java.util.Map)5 SAMLException (com.sun.identity.saml.common.SAMLException)4 List (java.util.List)4 Attribute (com.sun.identity.saml.assertion.Attribute)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 SessionProvider (com.sun.identity.plugin.session.SessionProvider)2 HashMap (java.util.HashMap)2 StringTokenizer (java.util.StringTokenizer)2 FSException (com.sun.identity.federation.common.FSException)1 BaseConfigType (com.sun.identity.federation.jaxb.entityconfig.BaseConfigType)1 IDFFMetaException (com.sun.identity.federation.meta.IDFFMetaException)1 IDFFMetaManager (com.sun.identity.federation.meta.IDFFMetaManager)1 AttributeDesignator (com.sun.identity.saml.assertion.AttributeDesignator)1 AttributeStatement (com.sun.identity.saml.assertion.AttributeStatement)1