123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- /**
- * Licensed Materials - Property of IBM
- *
- * IBM Cognos Products: CAMAAA
- *
- * (C) Copyright IBM Corp. 2005, 2012
- *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with
- * IBM Corp.
- */
- import java.util.Locale;
- import com.cognos.CAM_AAA.authentication.INamespace;
- import com.cognos.CAM_AAA.authentication.INamespaceConfiguration;
- import com.cognos.CAM_AAA.authentication.ISearchFilter;
- import com.cognos.CAM_AAA.authentication.ISearchFilterConditionalExpression;
- import com.cognos.CAM_AAA.authentication.ISearchFilterFunctionCall;
- import com.cognos.CAM_AAA.authentication.ISearchFilterRelationExpression;
- import com.cognos.CAM_AAA.authentication.UnrecoverableException;
- public class Namespace extends UiClass implements INamespace
- {
- /**
- *
- */
- public Namespace()
- {
- super(null);
- capabilities = new String[6];
- capabilities[0] = CapabilityCaseSensitive;
- capabilities[1] = CapabilityContains;
- capabilities[2] = CapabilityEquals;
- capabilities[3] = CapabilitySort;
- capabilities[4] = CapabilityStartsWith;
- capabilities[5] = CapabilityEndsWith;
- namespaceFormat = "http://developer.cognos.com/schemas/CAM/AAANamespaceFormat/2/";
- }
- /**
- * @param theObjectID
- */
- public Namespace(String theObjectID)
- {
- super(theObjectID);
- capabilities = new String[6];
- capabilities[0] = CapabilityCaseSensitive;
- capabilities[1] = CapabilityContains;
- capabilities[2] = CapabilityEquals;
- capabilities[3] = CapabilitySort;
- capabilities[4] = CapabilityStartsWith;
- capabilities[5] = CapabilityEndsWith;
- namespaceFormat = "http://developer.cognos.com/schemas/CAM/AAANamespaceFormat/2/";
- }
- /*
- * (non-Javadoc)
- *
- * @see com.cognos.CAM_AAA.authentication.INamespace#init(com.cognos.CAM_AAA.authentication.INamespaceConfiguration)
- */
- public void init(INamespaceConfiguration theNamespaceConfiguration)
- throws UnrecoverableException
- {
- setObjectID(theNamespaceConfiguration.getID());
- addName(theNamespaceConfiguration.getServerLocale(),
- theNamespaceConfiguration.getDisplayName());
- }
- /*
- * (non-Javadoc)
- *
- * @see com.cognos.CAM_AAA.authentication.INamespace#destroy()
- */
- public void destroy()
- {
- }
- /*
- * (non-Javadoc)
- *
- * @see com.cognos.CAM_AAA.authentication.INamespace#getNamespaceFormat()
- */
- public String getNamespaceFormat()
- {
- return namespaceFormat;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.cognos.CAM_AAA.authentication.INamespace#setNamespaceFormat(java.lang.String)
- */
- public void setNamespaceFormat(String theNamespaceFormat)
- {
- namespaceFormat = theNamespaceFormat;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.cognos.CAM_AAA.authentication.INamespace#getCapabilities()
- */
- public String[] getCapabilities()
- {
- return capabilities;
- }
- /*
- * (non-Javadoc)
- *
- * @see com.cognos.CAM_AAA.authentication.IBaseClass#getHasChildren()
- */
- public boolean getHasChildren()
- {
- return true;
- }
- /**
- * @param theFilter
- * @return
- */
- public boolean matchesFilter(ISearchFilter theFilter)
- {
- if (theFilter == null)
- {
- return true;
- }
- switch (theFilter.getSearchFilterType())
- {
- case ISearchFilter.ConditionalExpression :
- {
- ISearchFilterConditionalExpression item = (ISearchFilterConditionalExpression) theFilter;
- String operator = item.getOperator();
- ISearchFilter[] filters = item.getFilters();
- if (filters.length > 0)
- {
- boolean retval = false;
- for (int i = 1; i < filters.length; i++)
- {
- retval = this.matchesFilter(filters[i]);
- if (operator
- .equals(ISearchFilterConditionalExpression.ConditionalAnd))
- {
- if (retval == false)
- {
- return false;
- }
- }
- else if (operator
- .equals(ISearchFilterConditionalExpression.ConditionalOr))
- {
- if (retval == true)
- {
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- }
- }
- break;
- case ISearchFilter.FunctionCall :
- {
- ISearchFilterFunctionCall item = (ISearchFilterFunctionCall) theFilter;
- String functionName = item.getFunctionName();
- if (functionName.equals(ISearchFilterFunctionCall.Contains))
- {
- String[] parameter = item.getParameters();
- String propertyName = parameter[0];
- String value = parameter[1];
- if (propertyName.compareTo("@objectClass") == 0)
- {
- return ("namespace".indexOf(value) > 0);
- }
- else if (propertyName.equals("@defaultName")
- || propertyName.equals("@name"))
- {
- Locale[] locales = this.getAvailableNameLocales();
- if (locales != null)
- {
- for (int i = 0; i < locales.length; i++)
- {
- if (this.getName(locales[i]).indexOf(value) != -1)
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- else if (functionName
- .compareTo(ISearchFilterFunctionCall.StartsWith) == 0)
- {
- String[] parameter = item.getParameters();
- String propertyName = parameter[0];
- String value = parameter[1];
- if (propertyName.compareTo("@objectClass") == 0)
- {
- return ("namespace".startsWith(value));
- }
- else if (propertyName.compareTo("@defaultName") == 0
- || propertyName.compareTo("@name") == 0)
- {
- Locale[] locales = this.getAvailableNameLocales();
- if (locales != null)
- {
- for (int i = 0; i < locales.length; i++)
- {
- if (this.getName(locales[i]).startsWith(
- value))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- else if (functionName
- .compareTo(ISearchFilterFunctionCall.EndsWith) == 0)
- {
- String[] parameter = item.getParameters();
- String propertyName = parameter[0];
- String value = parameter[1];
- if (propertyName.compareTo("@objectClass") == 0)
- {
- return ("namespace".endsWith(value));
- }
- else if (propertyName.compareTo("@defaultName") == 0
- || propertyName.compareTo("@name") == 0)
- {
- Locale[] locales = this.getAvailableNameLocales();
- if (locales != null)
- {
- for (int i = 0; i < locales.length; i++)
- {
- if (this.getName(locales[i])
- .endsWith(value))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- else
- {
- return false;
- }
- }
- case ISearchFilter.RelationalExpression :
- {
- ISearchFilterRelationExpression item = (ISearchFilterRelationExpression) theFilter;
- String propertyName = item.getPropertyName();
- String constraint = item.getConstraint();
- String operator = item.getOperator();
- if (propertyName.equals("@objectClass"))
- {
- if (constraint.equals("namespace"))
- {
- return (operator
- .equals(ISearchFilterRelationExpression.EqualTo));
- }
- else
- {
- return false;
- }
- }
- else if (propertyName.equals("@defaultName")
- || propertyName.equals("@name"))
- {
- if (operator
- .equals(ISearchFilterRelationExpression.EqualTo))
- {
- Locale[] locales = this.getAvailableNameLocales();
- if (locales != null)
- {
- for (int i = 0; i < locales.length; i++)
- {
- if (this.getName(locales[i]).compareTo(
- constraint) == 0)
- {
- return true;
- }
- }
- }
- return false;
- }
- else if (operator
- .equals(ISearchFilterRelationExpression.NotEqual))
- {
- Locale[] locales = this.getAvailableNameLocales();
- if (locales != null)
- {
- for (int i = 0; i < locales.length; i++)
- {
- if (this.getName(locales[i]).compareTo(
- constraint) != 0)
- {
- return true;
- }
- }
- }
- return false;
- }
- }
- }
- }
- return false;
- }
- private String[] capabilities;
- private String namespaceFormat;
- }
|