ResourceComparatorValidator.java revision 11981d1f8bcb261776f7d9d46f3f5b4b4545f63e
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 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: ResourceComparatorValidator.java,v 1.5 2008/06/25 05:43:45 qcheng Exp $
*
*/
/**
* This validator checks the wildcard and oneLevelWildcard defined
* for a resource comparator. If they are equal or overlapping
* then they are invalid values.
*/
public class ResourceComparatorValidator implements ServiceAttributeValidator {
// dereference debug object from Policy Manager so that Policy Manager
// class will not be initialized.
public ResourceComparatorValidator() {
}
/**
* Validates a set of values for rules built into this method.
* Returns <code>true</code> if "wildcard" and "oneLevelWildcard"
* are either equal or overlapping in values.
*
* @param values the set of values to be validated
* @return <code>true</code> if "wildcard" and "oneLevelWildcard"
* are either equal or overlapping in values, <code>false</code>
* otherwise
*/
// values is a set. each element in the set is of the form
// serviceType=1|class=com.sun.identity.policy.Class|wildcard=*|
// caseSensitive=true|one_level_wildcard=-*-
while (valIterator.hasNext()) {
int count = 0;
while (st.hasMoreTokens()) {
break;
}
}
for (int i = 0; i < count; i++) {
+"validate(): name is null");
continue;
}
+"validate(): value is null");
continue;
}
if (debug.messageEnabled()) {
"validate():Attr Name = " + name +
" Attr Value = " + value);
}
if (name.equalsIgnoreCase(
}
}
if ((wildcardPattern != null) &&
(oneLevelPattern != null))
{
+"Wildcard and one level wildcard pattern "
+ "cannot be same");
return false;
}
boolean overlap = false;
if (debug.messageEnabled()) {
+"validate():about to do overlap check");
}
// find if the wildcard and one level wildcard
// patterns overlap
j++)
{
if (wildcard[i] == oneWildcard[j]) {
wildcard, i,wildcardLength -i);
oneWildcard, j,
oneLevelWildLength -j);
remString1) ||
{
overlap = true;
break;
}
}
}
if (overlap) {
break;
}
}
if (overlap) {
+"validate():Wildcard and one level "
+"wildcard pattern cannot be overlapping");
return false;
}
} // if either of the patterns not nested
} // end if both patterns are not null
} // if elemVal != null
} // while
} // if values not empty
return true;
}
}