Search in sources :

Example 81 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager 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 82 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager 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 83 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager 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 84 with ServiceSchemaManager

use of com.sun.identity.sm.ServiceSchemaManager 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)

Example 85 with ServiceSchemaManager

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

the class AuthUtils method getAuthRevisionNumber.

public static int getAuthRevisionNumber() {
    try {
        SSOToken token = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
        ServiceSchemaManager scm = new ServiceSchemaManager(ISAuthConstants.AUTH_SERVICE_NAME, token);
        return scm.getRevisionNumber();
    } catch (Exception e) {
        if (utilDebug.messageEnabled()) {
            utilDebug.message("getAuthRevisionNumber error", e);
        }
    }
    return 0;
}
Also used : SSOToken(com.iplanet.sso.SSOToken) ServiceSchemaManager(com.sun.identity.sm.ServiceSchemaManager) AuthLoginException(com.sun.identity.authentication.spi.AuthLoginException) SSOException(com.iplanet.sso.SSOException) SMSException(com.sun.identity.sm.SMSException) SessionException(com.iplanet.dpro.session.SessionException)

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