| | |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.schema; |
| | | import org.opends.messages.Message; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.ErrorLogCategory; |
| | | import org.opends.server.types.ErrorLogSeverity; |
| | | |
| | | |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.loggers.ErrorLogger.*; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.SchemaMessages.*; |
| | | import static org.opends.messages.SchemaMessages.*; |
| | | import org.opends.messages.MessageBuilder; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines an attribute syntax used for storing values that have been |
| | | * encoded using a password storage scheme. The format for attribute values |
| | |
| | | DirectoryServer.getEqualityMatchingRule(EMR_USER_PASSWORD_EXACT_OID); |
| | | if (defaultEqualityMatchingRule == null) |
| | | { |
| | | logError(ErrorLogCategory.SCHEMA, ErrorLogSeverity.SEVERE_ERROR, |
| | | MSGID_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE, |
| | | EMR_USER_PASSWORD_EXACT_NAME, SYNTAX_USER_PASSWORD_NAME); |
| | | logError(ERR_ATTR_SYNTAX_UNKNOWN_EQUALITY_MATCHING_RULE.get( |
| | | EMR_USER_PASSWORD_EXACT_NAME, SYNTAX_USER_PASSWORD_NAME)); |
| | | } |
| | | } |
| | | |
| | |
| | | * this syntax, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean valueIsAcceptable(ByteString value, |
| | | StringBuilder invalidReason) |
| | | MessageBuilder invalidReason) |
| | | { |
| | | // We have to accept any value here because in many cases the value will not |
| | | // have been encoded by the time this method is called. |
| | |
| | | // Make sure that there actually is a value to decode. |
| | | if ((userPasswordValue == null) || (userPasswordValue.length() == 0)) |
| | | { |
| | | int msgID = MSGID_ATTR_SYNTAX_USERPW_NO_VALUE; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | msgID); |
| | | Message message = ERR_ATTR_SYNTAX_USERPW_NO_VALUE.get(); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | | // The first character of an encoded value must be an opening curly brace. |
| | | if (userPasswordValue.charAt(0) != '{') |
| | | { |
| | | int msgID = MSGID_ATTR_SYNTAX_USERPW_NO_OPENING_BRACE; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | msgID); |
| | | Message message = ERR_ATTR_SYNTAX_USERPW_NO_OPENING_BRACE.get(); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | |
| | | int closePos = userPasswordValue.indexOf('}'); |
| | | if (closePos < 0) |
| | | { |
| | | int msgID = MSGID_ATTR_SYNTAX_USERPW_NO_CLOSING_BRACE; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | msgID); |
| | | Message message = ERR_ATTR_SYNTAX_USERPW_NO_CLOSING_BRACE.get(); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | if (schemeName.length() == 0) |
| | | { |
| | | int msgID = MSGID_ATTR_SYNTAX_USERPW_NO_SCHEME; |
| | | String message = getMessage(msgID); |
| | | throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, message, |
| | | msgID); |
| | | Message message = ERR_ATTR_SYNTAX_USERPW_NO_SCHEME.get(); |
| | | throw new DirectoryException( |
| | | ResultCode.INVALID_ATTRIBUTE_SYNTAX, message); |
| | | } |
| | | |
| | | |