Search in sources :

Example 91 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.

the class NamingService method initialize.

public static void initialize() {
    namingDebug = Debug.getInstance("amNaming");
    platformProperties = SystemProperties.getAll();
    server_proto = platformProperties.getProperty("com.iplanet.am.server.protocol", "");
    server_host = platformProperties.getProperty("com.iplanet.am.server.host", "");
    server_port = platformProperties.getProperty(Constants.AM_SERVER_PORT, "");
    PrivilegedAction<SSOToken> adminAction = InjectorHolder.getInstance(Key.get(new TypeLiteral<PrivilegedAction<SSOToken>>() {
    }));
    sso = AccessController.doPrivileged(adminAction);
    try {
        ssmNaming = new ServiceSchemaManager(NAMING_SERVICE, sso);
        ssmPlatform = new ServiceSchemaManager(PLATFORM_SERVICE, sso);
        serviceRevNumber = ssmPlatform.getRevisionNumber();
    } catch (SMSException | SSOException e) {
        throw new IllegalStateException(e);
    }
    ServiceListeners.Action action = new ServiceListeners.Action() {

        @Override
        public void performUpdate() {
            try {
                updateNamingTable();
                WebtopNaming.updateNamingTable();
            } catch (Exception ex) {
                namingDebug.error("Error occured in updating naming table", ex);
            }
        }
    };
    ServiceListeners builder = InjectorHolder.getInstance(ServiceListeners.class);
    builder.config(NAMING_SERVICE).global(action).schema(action).listen();
    builder.config(PLATFORM_SERVICE).global(action).schema(action).listen();
}
Also used : ServiceListeners(com.iplanet.services.naming.ServiceListeners) PrivilegedAction(java.security.PrivilegedAction) SSOToken(com.iplanet.sso.SSOToken) TypeLiteral(com.google.inject.TypeLiteral) SMSException(com.sun.identity.sm.SMSException) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) ServerEntryNotFoundException(com.iplanet.services.naming.ServerEntryNotFoundException) SMSException(com.sun.identity.sm.SMSException) MalformedURLException(java.net.MalformedURLException) SSOException(com.iplanet.sso.SSOException)

Example 92 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.

the class CLIUtil method getPasswordFields.

/**
     * Returns a set of attributes (of password syntax) of a given service.
     *
     * @param serviceName Name of service.
     * @return a set of attributes (of password syntax) of a given service.
     * @throws SMSException if error occurs when reading the service schema 
     *         layer
     * @throws SSOException if Single sign-on token is invalid.
     */
public static Set getPasswordFields(String serviceName) throws SMSException, SSOException {
    Set setPasswords = new HashSet();
    SSOToken ssoToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, ssoToken);
    if (ssm != null) {
        ServiceSchema schema = ssm.getOrganizationSchema();
        if (schema != null) {
            Set attributeSchemas = schema.getAttributeSchemas();
            for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
                AttributeSchema as = (AttributeSchema) i.next();
                if (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD)) {
                    setPasswords.add(as.getName());
                }
            }
        }
    }
    return setPasswords;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) SSOToken(com.iplanet.sso.SSOToken) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) HashSet(java.util.HashSet)

Example 93 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.

the class CLIUtil method getPasswordFields.

/**
     * Returns a set of attributes (of password syntax) of a given service.
     *
     * @param serviceName Name of service.
     * @param schemaType Type of Schema.
     * @param subSchema Name of SubSchema
     * @return a set of attributes (of password syntax) of a given service.
     * @throws SMSException if error occurs when reading the service schema 
     *         layer
     * @throws SSOException if Single sign-on token is invalid.
     */
public static Set getPasswordFields(String serviceName, SchemaType schemaType, String subSchema) throws SMSException, SSOException {
    Set setPasswords = new HashSet();
    SSOToken ssoToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, ssoToken);
    if (ssm != null) {
        ServiceSchema schema = ssm.getSchema(schemaType);
        if (schema != null) {
            ServiceSchema ss = schema.getSubSchema(subSchema);
            Set attributeSchemas = ss.getAttributeSchemas();
            for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
                AttributeSchema as = (AttributeSchema) i.next();
                if (as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD)) {
                    setPasswords.add(as.getName());
                }
            }
        }
    }
    return setPasswords;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) SSOToken(com.iplanet.sso.SSOToken) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) HashSet(java.util.HashSet)

Example 94 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.

the class ComplianceServicesImpl method getDeletedObjectFilter.

/**
     * Protected method to get the search filter to be used for searching for
     * deleted objects.
     * 
     */
public String getDeletedObjectFilter(int objectType) throws AMException, SSOException {
    Set values = new HashSet();
    try {
        if (gsc == null) {
            ServiceSchemaManager scm = new ServiceSchemaManager(ADMINISTRATION_SERVICE, internalToken);
            gsc = scm.getGlobalSchema();
        }
        Map attrMap = gsc.getAttributeDefaults();
        if (attrMap != null)
            values = (Set) attrMap.get(COMPLIANCE_SPECIAL_FILTER_ATTR);
        if (debug.messageEnabled()) {
            debug.message("Compliance.getDeletedObjectSearchFilter = " + values.toString());
        }
    } catch (SMSException ex) {
        debug.error(AMSDKBundle.getString("359"), ex);
        throw new AMException(AMSDKBundle.getString("359"), "359");
    } catch (SSOException ex) {
        debug.error(AMSDKBundle.getString("359"), ex);
        throw new AMException(AMSDKBundle.getString("359"), "359");
    }
    String org_filter = null;
    String group_filter = null;
    String user_filter = null;
    String def_filter = null;
    String res_filter = null;
    Iterator iter = values.iterator();
    while (iter.hasNext()) {
        String thisFilter = (String) iter.next();
        if (thisFilter.startsWith("Organization=")) {
            org_filter = thisFilter.substring(13);
        } else if (thisFilter.startsWith("Group=")) {
            group_filter = thisFilter.substring(6);
        } else if (thisFilter.startsWith("User=")) {
            user_filter = thisFilter.substring(5);
        } else if (thisFilter.startsWith("Misc=")) {
            def_filter = thisFilter.substring(5);
        } else if (thisFilter.startsWith("Resource=")) {
            res_filter = thisFilter.substring(9);
        }
    }
    org_filter = (org_filter == null) ? DEFAULT_DELETED_ORG_FILTER : org_filter;
    group_filter = (group_filter == null) ? DEFAULT_DELETED_GROUP_FILTER : group_filter;
    user_filter = (user_filter == null) ? DEFAULT_DELETED_USER_FILTER : user_filter;
    def_filter = (def_filter == null) ? DEFAULT_DELETED_OBJECT_FILTER : def_filter;
    res_filter = (res_filter == null) ? DEFAULT_DELETED_RESOURCE_FILTER : res_filter;
    switch(objectType) {
        case AMObject.ORGANIZATION:
            return (org_filter);
        case AMObject.USER:
            return (user_filter);
        case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
        case AMObject.DYNAMIC_GROUP:
        case AMObject.STATIC_GROUP:
        case AMObject.GROUP:
            return (group_filter);
        case AMObject.RESOURCE:
            return (res_filter);
        default:
            return ("(|" + org_filter + group_filter + user_filter + def_filter + res_filter + ")");
    }
}
Also used : HashSet(java.util.HashSet) AttrSet(com.iplanet.services.ldap.AttrSet) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) AMException(com.iplanet.am.sdk.AMException) SSOException(com.iplanet.sso.SSOException) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) HashSet(java.util.HashSet)

Example 95 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager in project OpenAM by OpenRock.

the class DirectoryServicesImpl method getServiceAttributesWithQualifier.

/**
     * Method to get the attribute names of a service with CosQualifier. For
     * example: Return set could be ["iplanet-am-web-agent-allow-list
     * merge-schemes", "iplanet-am-web-agent-deny-list merge-schemes"] This only
     * returns Dynamic attributes
     */
private Set getServiceAttributesWithQualifier(SSOToken token, String serviceName) throws SMSException, SSOException {
    ServiceSchemaManager ssm = new ServiceSchemaManager(serviceName, token);
    ServiceSchema ss = null;
    try {
        ss = ssm.getSchema(SchemaType.DYNAMIC);
    } catch (SMSException sme) {
        if (debug.warningEnabled()) {
            debug.warning("DirectoryServicesImpl.getServiceNames(): No " + "schema defined for SchemaType.DYNAMIC type");
        }
    }
    if (ss == null) {
        return Collections.EMPTY_SET;
    }
    Set attrNames = new HashSet();
    Set attrSchemaNames = ss.getAttributeSchemaNames();
    Iterator itr = attrSchemaNames.iterator();
    while (itr.hasNext()) {
        String attrSchemaName = (String) itr.next();
        AttributeSchema attrSchema = ss.getAttributeSchema(attrSchemaName);
        String name = attrSchemaName + " " + attrSchema.getCosQualifier();
        attrNames.add(name);
    }
    return attrNames;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) AttrSet(com.iplanet.services.ldap.AttrSet) SMSException(com.sun.identity.sm.SMSException) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) HashSet(java.util.HashSet)

Aggregations

ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)209 SMSException (com.sun.identity.sm.SMSException)146 ServiceSchema (com.sun.identity.sm.ServiceSchema)131 SSOException (com.iplanet.sso.SSOException)119 Set (java.util.Set)87 HashSet (java.util.HashSet)60 Map (java.util.Map)56 HashMap (java.util.HashMap)49 AttributeSchema (com.sun.identity.sm.AttributeSchema)46 SSOToken (com.iplanet.sso.SSOToken)43 Iterator (java.util.Iterator)40 CLIException (com.sun.identity.cli.CLIException)33 BeforeTest (org.testng.annotations.BeforeTest)27 AfterTest (org.testng.annotations.AfterTest)26 Test (org.testng.annotations.Test)26 CLIRequest (com.sun.identity.cli.CLIRequest)25 Parameters (org.testng.annotations.Parameters)18 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)15 TreeSet (java.util.TreeSet)12 ByteString (org.forgerock.opendj.ldap.ByteString)11