| | |
| | | */ |
| | | package org.opends.guitools.controlpanel.util; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import static org.opends.admin.ads.util.ConnectionUtils.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.quicksetup.Installation.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import java.awt.Color; |
| | | import java.awt.Component; |
| | |
| | | import org.opends.server.types.OpenDsException; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.SchemaUtils; |
| | | import org.opends.server.util.SchemaUtils.PasswordType; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.SchemaUtils.PasswordType; |
| | | |
| | | /** |
| | | * A static class that provides miscellaneous functions. |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the attribute name with no options (or subtypes). |
| | | * @param attrName the complete attribute name. |
| | | * @return the attribute name with no options (or subtypes). |
| | | */ |
| | | public static String getAttributeNameWithoutOptions(String attrName) |
| | | { |
| | | return AttributeDescription.valueOf(attrName).getNameOrOID(); |
| | | } |
| | | |
| | | /** |
| | | * Strings any potential "separator" from a given string. |
| | | * @param s string to strip |
| | | * @param separator the separator string to remove |
| | |
| | | */ |
| | | private static String stripStringToSingleLine(String s, String separator) |
| | | { |
| | | if (s != null) |
| | | { |
| | | return s.replaceAll(separator, ""); |
| | | } |
| | | return null; |
| | | return (s == null) ? null : s.replaceAll(separator, ""); |
| | | } |
| | | |
| | | /** The pattern for control characters. */ |
| | |
| | | */ |
| | | public static boolean hasImageSyntax(String attrName, Schema schema) |
| | | { |
| | | attrName = Utilities.getAttributeNameWithoutOptions(attrName); |
| | | if ("photo".equals(attrName)) |
| | | if ("photo".equals(AttributeDescription.valueOf(attrName).getNameOrOID())) |
| | | { |
| | | return true; |
| | | } |
| | | // Check all the attributes that we consider binaries. |
| | | if (schema != null && schema.hasAttributeType(attrName)) |
| | | if (schema != null) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName); |
| | | String syntaxOID = attr.getSyntax().getOID(); |
| | | return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID); |
| | | AttributeType attrType = AttributeDescription.valueOf(attrName, schema.getSchemaNG()).getAttributeType(); |
| | | if (!attrType.isPlaceHolder()) |
| | | { |
| | | String syntaxOID = attrType.getSyntax().getOID(); |
| | | return SchemaConstants.SYNTAX_JPEG_OID.equals(syntaxOID); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | |
| | | { |
| | | if (schema != null) |
| | | { |
| | | attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); |
| | | if (schema.hasAttributeType(attrName)) |
| | | AttributeType attrType = AttributeDescription.valueOf(attrName, schema.getSchemaNG()).getAttributeType(); |
| | | if (!attrType.isPlaceHolder()) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName); |
| | | PasswordType passwordType = SchemaUtils.checkPasswordType(attr); |
| | | PasswordType passwordType = SchemaUtils.checkPasswordType(attrType); |
| | | return passwordType.equals(PasswordType.USER_PASSWORD); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (schema != null) |
| | | { |
| | | attrName = Utilities.getAttributeNameWithoutOptions(attrName).toLowerCase(); |
| | | if (schema.hasAttributeType(attrName)) |
| | | AttributeType attrType = AttributeDescription.valueOf(attrName, schema.getSchemaNG()).getAttributeType(); |
| | | if (!attrType.isPlaceHolder()) |
| | | { |
| | | AttributeType attr = schema.getAttributeType(attrName); |
| | | return contains(oids, attr.getSyntax().getOID()); |
| | | return contains(oids, attrType.getSyntax().getOID()); |
| | | } |
| | | } |
| | | return false; |