Search in sources :

Example 46 with AttributeSchema

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

the class AMCrypt method decryptPasswords.

public static Set decryptPasswords(Set values, String attributeName, ServiceSchema serviceSchema) {
    if (values == null || values.isEmpty()) {
        return values;
    }
    AttributeSchema as = serviceSchema.getAttributeSchema(attributeName);
    if (as == null || (!as.getSyntax().equals(AttributeSchema.Syntax.PASSWORD) && !as.getSyntax().equals(AttributeSchema.Syntax.ENCRYPTED_PASSWORD))) {
        return values;
    }
    HashSet result = new HashSet();
    Iterator iter = values.iterator();
    while (iter.hasNext()) {
        String value = (String) iter.next();
        if (value != null) {
            value = (String) AccessController.doPrivileged(new DecodeAction(value));
        }
        result.add(value);
    }
    return result;
}
Also used : AttributeSchema(com.sun.identity.sm.AttributeSchema) Iterator(java.util.Iterator) DecodeAction(com.sun.identity.security.DecodeAction) HashSet(java.util.HashSet)

Example 47 with AttributeSchema

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

the class AgentConfigInheritViewBean method populatePropertyNameTableModel.

private void populatePropertyNameTableModel(Collection propertyNames) {
    if (!submitCycle && (propertyNames != null)) {
        tblPropertyNamesModel.clearAll();
        SerializedField szCache = (SerializedField) getChild(SZ_CACHE);
        String universalId = (String) getPageSessionAttribute(AgentProfileViewBean.UNIVERSAL_ID);
        String agentType = getAgentType();
        String curRealm = (String) getPageSessionAttribute(AMAdminConstants.CURRENT_REALM);
        AgentsModel model = (AgentsModel) getModel();
        Set inheritedPropertyNames = model.getInheritedPropertyNames(curRealm, universalId);
        Map nameToSchemas = model.getAttributeSchemas(agentType, propertyNames);
        removeNonInheritable(nameToSchemas, propertyNames);
        try {
            ResourceBundle rb = AgentConfiguration.getServiceResourceBundle(model.getUserLocale());
            String groupName = model.getAgentGroup(curRealm, universalId);
            Map groupValues = model.getGroupAttributeValues(curRealm, groupName);
            ArrayList cache = new ArrayList();
            int counter = 0;
            for (Iterator i = propertyNames.iterator(); i.hasNext(); counter++) {
                if (counter > 0) {
                    tblPropertyNamesModel.appendRow();
                }
                String name = (String) i.next();
                AttributeSchema as = (AttributeSchema) nameToSchemas.get(name);
                if (as != null) {
                    String displayName = rb.getString(as.getI18NKey());
                    tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_NAME, displayName);
                    try {
                        String help = rb.getString(as.getI18NKey() + ".help");
                        tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_HELP, help);
                    } catch (MissingResourceException e) {
                        // need to clear the help value
                        tblPropertyNamesModel.setValue(TBL_DATA_PROPERTY_HELP, "");
                    }
                    Object oValue = groupValues.get(name);
                    String value = "";
                    if (oValue != null) {
                        value = oValue.toString();
                        if (value.length() >= 2) {
                            value = value.substring(1, value.length() - 1);
                        }
                    }
                    tblPropertyNamesModel.setValue(TBL_DATA_VALUE, value);
                    tblPropertyNamesModel.setSelectionVisible(counter, true);
                    tblPropertyNamesModel.setRowSelected(inheritedPropertyNames.contains(name));
                    cache.add(name);
                }
            }
            szCache.setValue(cache);
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        } catch (SMSException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        } catch (SSOException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    }
}
Also used : Set(java.util.Set) SMSException(com.sun.identity.sm.SMSException) MissingResourceException(java.util.MissingResourceException) ArrayList(java.util.ArrayList) SSOException(com.iplanet.sso.SSOException) SerializedField(com.sun.identity.console.components.view.html.SerializedField) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ResourceBundle(java.util.ResourceBundle) AgentsModel(com.sun.identity.console.agentconfig.model.AgentsModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 48 with AttributeSchema

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

the class ModifyAttributeSchemaI18nKey method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
    String i18nkey = getStringOptionValue(ARGUMENT_I18N_KEY);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, i18nkey };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ATTRIBUTE_SCHEMA_I18N_KEY", params);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, i18nkey, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeSchemaName, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_I18N_KEY", args);
        }
        attrSchema.setI18NKey(i18nkey);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_ATTRIBUTE_SCHEMA_I18N_KEY", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-modify-i18n-key-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, i18nkey, e.getMessage() };
        debugError("ModifyAttributeSchemaI18nKey.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_I18N_KEY", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, i18nkey, e.getMessage() };
        debugError("ModifyAttributeSchemaI18nKey.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_I18N_KEY", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 49 with AttributeSchema

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

the class ModifyAttributeSchemaPropertiesViewBeanURL method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
    String url = getStringOptionValue(ARGUMENT_URL);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, url };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ATTRIBUTE_SCHEMA_PROPERTIES_VIEW_BEAN_URL", params);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, url, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeSchemaName, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_PROPERTIES_VIEW_BEAN_URL", args);
        }
        attrSchema.setPropertiesViewBeanUR(url);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_ATTRIBUTE_SCHEMA_PROPERTIES_VIEW_BEAN_URL", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-modify-properties-view-bean-url-key-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, url, e.getMessage() };
        debugError("ModifyAttributeSchemaPropertiesViewBeanURL.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_PROPERTIES_VIEW_BEAN_URL", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, url, e.getMessage() };
        debugError("ModifyAttributeSchemaPropertiesViewBeanURL.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_PROPERTIES_VIEW_BEAN_URL", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Example 50 with AttributeSchema

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

the class ModifyAttributeSchemaSyntax method handleRequest.

/**
     * Services a Commandline Request.
     *
     * @param rc Request Context.
     * @throws CLIException if the request cannot serviced.
     */
public void handleRequest(RequestContext rc) throws CLIException {
    super.handleRequest(rc);
    ldapLogin();
    String schemaType = getStringOptionValue(IArgument.SCHEMA_TYPE);
    String serviceName = getStringOptionValue(IArgument.SERVICE_NAME);
    String subSchemaName = getStringOptionValue(IArgument.SUBSCHEMA_NAME);
    String attributeSchemaName = getStringOptionValue(IArgument.ATTRIBUTE_SCHEMA);
    String syntax = getStringOptionValue(ARGUMENT_SYNTAX);
    ServiceSchema ss = getServiceSchema();
    IOutput outputWriter = getOutputWriter();
    try {
        String[] params = { serviceName, schemaType, subSchemaName, attributeSchemaName, syntax };
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_MODIFY_ATTRIBUTE_SCHEMA_SYNTAX", params);
        AttributeSchema attrSchema = ss.getAttributeSchema(attributeSchemaName);
        if (attrSchema == null) {
            String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, syntax, "attribute schema does not exist" };
            attributeSchemaNoExist(attributeSchemaName, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_SYNTAX", args);
        }
        attrSchema.setSyntax(syntax);
        writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEED_MODIFY_ATTRIBUTE_SCHEMA_SYNTAX", params);
        outputWriter.printlnMessage(MessageFormat.format(getResourceString("attribute-schema-modify-syntax-succeed"), (Object[]) params));
    } catch (SSOException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, syntax, e.getMessage() };
        debugError("ModifyAttributeSchemaSyntax.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_SYNTAX", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    } catch (SMSException e) {
        String[] args = { serviceName, schemaType, subSchemaName, attributeSchemaName, syntax, e.getMessage() };
        debugError("ModifyAttributeSchemaSyntax.handleRequest", e);
        writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_MODIFY_ATTRIBUTE_SCHEMA_SYNTAX", args);
        throw new CLIException(e, ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
    }
}
Also used : ServiceSchema(com.sun.identity.sm.ServiceSchema) SMSException(com.sun.identity.sm.SMSException) IOutput(com.sun.identity.cli.IOutput) AttributeSchema(com.sun.identity.sm.AttributeSchema) CLIException(com.sun.identity.cli.CLIException) SSOException(com.iplanet.sso.SSOException)

Aggregations

AttributeSchema (com.sun.identity.sm.AttributeSchema)149 Iterator (java.util.Iterator)80 ServiceSchema (com.sun.identity.sm.ServiceSchema)76 Set (java.util.Set)75 SMSException (com.sun.identity.sm.SMSException)67 HashSet (java.util.HashSet)59 SSOException (com.iplanet.sso.SSOException)58 ServiceSchemaManager (com.sun.identity.sm.ServiceSchemaManager)46 HashMap (java.util.HashMap)36 Map (java.util.Map)34 CLIException (com.sun.identity.cli.CLIException)28 CLIRequest (com.sun.identity.cli.CLIRequest)18 AfterTest (org.testng.annotations.AfterTest)18 BeforeTest (org.testng.annotations.BeforeTest)18 Parameters (org.testng.annotations.Parameters)18 Test (org.testng.annotations.Test)18 IOutput (com.sun.identity.cli.IOutput)14 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)10 CaseInsensitiveHashMap (com.sun.identity.common.CaseInsensitiveHashMap)9 SSOToken (com.iplanet.sso.SSOToken)8