Search in sources :

Example 86 with ServiceSchema

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

the class SetConfigurations method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
@Override
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String datafile = getStringOptionValue(IArgument.DATA_FILE);
    List attrValues = rc.getOption(IArgument.ATTRIBUTE_VALUES);
    if ((datafile == null) && (attrValues == null)) {
        throw new CLIException(getResourceString("missing-attributevalues"), ExitCodes.INCORRECT_OPTION, rc.getSubCommand().getName());
    }
    Map<String, Set<String>> attributeValues = AttributeValues.parse(getCommandManager(), datafile, attrValues);
    writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ENTITLEMENT_SVC", null);
    try {
        ServiceSchemaManager ssm = new ServiceSchemaManager(EntitlementService.SERVICE_NAME, getAdminSSOToken());
        validateData(attributeValues, ssm);
        ServiceSchema gss = ssm.getGlobalSchema();
        gss.setAttributeDefaults(attributeValues);
        getOutputWriter().printlnMessage(getResourceString("set-entitlement-config-succeeded"));
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_MODIFY_ENTITLEMENT_SVC", null);
    } catch (SMSException e) {
        String[] paramExs = { e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SSOException e) {
        String[] paramExs = { e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (CLIException e) {
        String[] paramExs = { e.getMessage() };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "FAILED_MODIFY_ENTITLEMENT_SVC", paramExs);
        throw e;
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) CLIException(com.sun.identity.cli.CLIException) List(java.util.List) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 87 with ServiceSchema

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

the class GetAssignableServices method discardServicesWithoutAttributeSchema.

private void discardServicesWithoutAttributeSchema(SSOToken adminSSOToken, Set serviceNames, IdType type) throws SMSException, SSOException {
    for (Iterator iter = serviceNames.iterator(); iter.hasNext(); ) {
        String serviceName = (String) iter.next();
        ServiceSchemaManager mgr = new ServiceSchemaManager(serviceName, adminSSOToken);
        String url = mgr.getPropertiesViewBeanURL();
        if (url == null) {
            ServiceSchema serviceSchema = mgr.getSchema(type.getName());
            Set attributes = serviceSchema.getAttributeSchemas();
            if ((attributes == null) || attributes.isEmpty()) {
                iter.remove();
            } else if (!hasI18nKeys(attributes)) {
                iter.remove();
            }
        }
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) Iterator(java.util.Iterator) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 88 with ServiceSchema

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

the class AMServiceProfileModelImpl method setAttributeValues.

/**
     * Set attribute values.
     *
     * @param map Map of attribute name to Set of attribute values.
     * @throws AMConsoleException if values cannot be set.
     */
public void setAttributeValues(Map map) throws AMConsoleException {
    Set attributeSchemas = new HashSet();
    attributeSchemas.addAll(xmlBuilder.getAttributeSchemas());
    addMoreAttributeSchemasForModification(attributeSchemas);
    // Need to find the service schema for each attributeSchema
    Map mapSvcSchemaToMapNameToValues = new HashMap();
    for (Iterator i = attributeSchemas.iterator(); i.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) i.next();
        String name = as.getName();
        Set values = (Set) map.get(name);
        if (values != null) {
            ServiceSchema ss = as.getServiceSchema();
            Map m = (Map) mapSvcSchemaToMapNameToValues.get(ss);
            if (m == null) {
                m = new HashMap();
                mapSvcSchemaToMapNameToValues.put(ss, m);
            }
            m.put(name, values);
        }
    }
    if (!mapSvcSchemaToMapNameToValues.isEmpty()) {
        for (Iterator i = mapSvcSchemaToMapNameToValues.keySet().iterator(); i.hasNext(); ) {
            ServiceSchema ss = (ServiceSchema) i.next();
            setDefaultValues(ss, (Map) mapSvcSchemaToMapNameToValues.get(ss));
        }
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 89 with ServiceSchema

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

the class TabControllerBase method updateStatus.

protected void updateStatus() {
    boolean status = false;
    SSOToken adminSSOToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
    try {
        ServiceSchemaManager mgr = new ServiceSchemaManager(AMAdminConstants.ADMIN_CONSOLE_SERVICE, adminSSOToken);
        ServiceSchema schema = mgr.getSchema(SchemaType.GLOBAL);
        AttributeSchema as = schema.getAttributeSchema(getConfigAttribute());
        Set defaultValue = as.getDefaultValues();
        if ((defaultValue != null) && !defaultValue.isEmpty()) {
            String val = (String) defaultValue.iterator().next();
            status = (val != null) && val.equals("true");
        }
    } catch (SMSException e) {
        AMModelBase.debug.error("TabControllerBase.updateStatus", e);
    } catch (SSOException e) {
        AMModelBase.debug.error("TabControllerBase.updateStatus", e);
    }
    visible = status;
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SSOToken(com.iplanet.sso.SSOToken) Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) AttributeSchema(com.sun.identity.sm.AttributeSchema) SSOException(com.iplanet.sso.SSOException) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Example 90 with ServiceSchema

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

the class AMOrganizationImpl method createGroup.

protected AMGroup createGroup(String name, Map attributes, Map serviceNameAndAttrs, int type) throws AMException, SSOException {
    String groupDN = AMNamingAttrManager.getNamingAttr(GROUP) + "=" + name + "," + super.entryDN;
    AMObjectImpl groupImpl;
    switch(type) {
        case AMObject.STATIC_GROUP:
            groupImpl = new AMStaticGroupImpl(super.token, groupDN);
            break;
        case AMObject.DYNAMIC_GROUP:
            groupImpl = new AMDynamicGroupImpl(super.token, groupDN);
            break;
        case AMObject.ASSIGNABLE_DYNAMIC_GROUP:
            groupImpl = new AMAssignableDynamicGroupImpl(super.token, groupDN);
            break;
        default:
            throw new UnsupportedOperationException();
    }
    if (serviceNameAndAttrs != null && !serviceNameAndAttrs.isEmpty()) {
        Set serviceNames = serviceNameAndAttrs.keySet();
        Set registered = dsServices.getRegisteredServiceNames(null, entryDN);
        Iterator it = serviceNames.iterator();
        while (it.hasNext()) {
            String tmpS = (String) it.next();
            if (!registered.contains(tmpS)) {
                Object[] args = { tmpS };
                throw new AMException(AMSDKBundle.getString("459", args, super.locale), "459", args);
            }
        }
        Set objectClasses = null;
        if ((serviceNames != null) && (!serviceNames.isEmpty())) {
            objectClasses = AMServiceUtils.getServiceObjectClasses(token, serviceNames);
            Set userOCs = (Set) attributes.get("objectclass");
            objectClasses = AMCommonUtils.combineOCs(userOCs, objectClasses);
        }
        it = serviceNames.iterator();
        while (it.hasNext()) {
            String thisService = (String) it.next();
            Map sAttrMap = (Map) serviceNameAndAttrs.get(thisService);
            // validate the attributes and add pick the defaults.
            try {
                ServiceSchemaManager ssm = new ServiceSchemaManager(thisService, token);
                ServiceSchema ss = ssm.getSchema(SchemaType.GROUP);
                sAttrMap = ss.validateAndInheritDefaults(sAttrMap, true);
                sAttrMap = AMCommonUtils.removeEmptyValues(sAttrMap);
                groupImpl.setAttributes(sAttrMap);
            } catch (SMSException se) {
                debug.error("AMGroupContainerImpl.createStaticGroup: " + "Data validation failed.. ", se);
            }
            Object[] args = { thisService };
            throw new AMException(AMSDKBundle.getString("976", args, super.locale), "976", args);
        }
        if (objectClasses != null && !objectClasses.isEmpty()) {
            groupImpl.setAttribute("objectclass", objectClasses);
        }
    }
    groupImpl.setAttributes(attributes);
    groupImpl.create();
    return ((AMGroup) groupImpl);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) SMSException(com.sun.identity.sm.SMSException) ServiceSchema(com.sun.identity.sm.ServiceSchema) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager)

Aggregations

ServiceSchema (com.sun.identity.sm.ServiceSchema)216 SMSException (com.sun.identity.sm.SMSException)152 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)131 SSOException (com.iplanet.sso.SSOException)117 Set (java.util.Set)101 AttributeSchema (com.sun.identity.sm.AttributeSchema)76 HashSet (java.util.HashSet)71 Map (java.util.Map)70 HashMap (java.util.HashMap)57 Iterator (java.util.Iterator)56 CLIException (com.sun.identity.cli.CLIException)46 SSOToken (com.iplanet.sso.SSOToken)27 IOutput (com.sun.identity.cli.IOutput)26 BeforeTest (org.testng.annotations.BeforeTest)22 CLIRequest (com.sun.identity.cli.CLIRequest)21 ByteString (org.forgerock.opendj.ldap.ByteString)21 AfterTest (org.testng.annotations.AfterTest)21 Test (org.testng.annotations.Test)21 Parameters (org.testng.annotations.Parameters)18 TreeSet (java.util.TreeSet)15