/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: AttributeValidator.java,v 1.10 2009/11/03 00:06:31 hengming Exp $
*
* Portions Copyrighted 2015 ForgeRock AS.
*/
/**
* The class <code> AttributeValidator </code> provides methods by which
* ServiceConfig data to be stored in the Directory, can be validated against
* the relevant Service Schema. The validator needs to check against the
* relevant Schema to validate the attribute syntax and type.
*
*/
class AttributeValidator {
// Static variables
new MailAddressValidator();
// Instance variables
/**
* Constructor
*
* @param as
* the service schema which will be used to validate the
* attribute values
*/
}
/**
* This method validates the syntax of the Attribute values against what it
* is supposed to be in the ServiceSchema.
*
* @param values
* Set of all the values for this attribute.
* @param encodePassword
* if true, the values will be encrypted if the attribute's
* syntax is password
* @return boolean true or false depending on whether the values are valid.
* @throws SMSException
*/
throws SMSException {
return (true);
return (true);
}
/**
* This condition is required because console is
* passing a set of empty string. Without this check,
* mailValidator will validate empty string for email
* address and fail
*/
break;
}
return (false);
}
}
return (true);
}
if (encodePassword) {
// Encrypt the passwords
try {
} catch (Throwable e) {
}
}
}
return (true);
}
return (false);
}
}
return (true);
}
return (false);
}
}
return (true);
}
try {
return (true);
}
} catch (Exception e) {
return (false);
}
return (false);
}
}
return (true);
}
try {
f = Float.parseFloat(s);
return (true);
}
} catch (Exception e) {
return (false);
}
return (false);
}
}
return (true);
}
return (false);
}
return (true);
}
// Doesn't fit any of these supported syntax??
"sms-invalid_attribute_syntax", args);
}
/**
* This method validates the type of the Attribute values against what it is
* supposed to be in the ServiceSchema.
*
* @param values
* Set of all the values for this attribute.
* @return boolean true or false depending on whether the values are valid.
* @throws SMSException
*/
return (true);
return (false);
} else {
return (true);
}
}
return (false);
}
}
return (true);
}
return (false);
} else {
// we may not be able validate choice type attribute values
// correctly during installation time or when importing
// service configuration.
return true;
}
return (true);
}
return (true);
}
}
return (false);
}
}
// we may not be able validate choice type attribute values
// correctly during installation time or when importing
// service configuration.
return true;
}
return (false);
}
}
if (size == 0) {
return (true);
}
return false;
}
boolean match = false;
for (int i = 0; i < arraySize; i++) {
match = true;
break;
}
}
if (!match) {
return (false);
}
}
return (true);
}
return (true);
}
return (true);
}
// Doesn't fit any of these supported type??
"sms-invalid_attribute_type", args);
}
/**
* Validates a map of Attributes and values against Service Schema
* definition.
*
* @param attrVals
* a Set of attribute values
* @param i18nFileName
* Resource bundle file name
* @param encodePassword
* if true, the values will be encrypted if the attribute's
* syntax is password
* @return boolean true or false depending on whether the values are valid.
* @throws SMSException
* if values is invalid.
*/
throws SMSException {
}
/**
* Validates a map of Attributes and values against Service Schema
* definition.
*
* @param attrVals
* a Set of attribute values
* @param i18nFileName
* Resource bundle file name
* @param encodePassword
* if true, the values will be encrypted if the attribute's
* syntax is password
* @param envParam
* a Map of environment parameters
* @return boolean true or false depending on whether the values are valid.
* @throws SMSException
* if values is invalid.
*/
// removing old values, no need to validate
return true;
}
if (debug.messageEnabled()) {
+ envParam);
}
if (i18nFileName != null) {
throw (new InvalidAttributeValueException(
"sms-attribute-values-does-not-match-schema", args));
} else {
throw (new InvalidAttributeValueException(
"sms-attribute-values-does-not-match-schema", args));
}
}
return (true);
}
/**
* This method checks if the attribute name (as given by the
* AttributeSchema) is present, and if missings adds the defaults values.
*
* @param attrs
* A map of the attributes and their values
* @return A map which is a union of the attributes provided and default
* attribute values
*/
// Inherit the default values
// Decrypt the password
try {
tString)));
} catch (Throwable e) {
}
}
}
return (attrs);
}
/**
* This method checks if attribute schema is of syntax password or
* encoded_password, if so it decrypts the password when it is stored in the
* cache.
*
* @param attrs
* a Map of the attributes and their values
* @return A map which is has replaced encrypted values with decrypted ones.
*/
return attrs;
}
// Decrypt the password
try {
tString)));
} catch (Throwable e) {
}
}
}
return (attrs);
}
/**
* Encodes attribute value if it is of syntax password or encoded_password.
*
* @param attrs Map of the attributes and their values
* @param encryptObj Encryptor
* @return A map which is has replaced values with encrypted ones.
*/
return attrs;
}
// Encrypt the password
try {
tString, encryptObj)));
} catch (Throwable e) {
"AttributeValidator.encodedAttrs: Unable to encode", e);
}
}
}
return (attrs);
}
}