001: /*
002: * Copyright 2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: */
013: package com.pentaho.security.ldap.search;
014:
015: import javax.naming.directory.SearchControls;
016:
017: import org.springframework.beans.factory.InitializingBean;
018: import org.springframework.util.Assert;
019:
020: public class LdapSearchParamsFactoryImpl implements
021: LdapSearchParamsFactory, InitializingBean {
022:
023: // ~ Static fields/initializers ============================================
024:
025: // private static final Log logger = LogFactory.getLog(LdapSearchParamsFactoryImpl.class);
026:
027: // ~ Instance fields =======================================================
028:
029: private String base;
030:
031: private String filter;
032:
033: private SearchControls searchControls;
034:
035: // ~ Constructors ==========================================================
036:
037: public LdapSearchParamsFactoryImpl() {
038: super ();
039: }
040:
041: // ~ Methods ===============================================================
042:
043: public LdapSearchParamsFactoryImpl(final String base,
044: final String filter) {
045: this (base, filter, new SearchControls());
046: }
047:
048: public LdapSearchParamsFactoryImpl(final String base,
049: final String filter, final SearchControls searchControls) {
050: this .base = base;
051: this .filter = filter;
052: this .searchControls = searchControls;
053: }
054:
055: public void afterPropertiesSet() throws Exception {
056: Assert.notNull(base);
057: Assert.hasLength(filter);
058: }
059:
060: /**
061: * Private so it cannot be instantiated except by this class.
062: */
063: private class LdapSearchParamsImpl implements LdapSearchParams {
064: private String implBase;
065:
066: private String implFilter;
067:
068: private Object[] filterArgs;
069:
070: private SearchControls implSearchControls;
071:
072: private LdapSearchParamsImpl(final String base,
073: final String filter, final Object[] filterArgs,
074: final SearchControls searchControls) {
075: this .implBase = base;
076: this .implFilter = filter;
077: this .filterArgs = filterArgs;
078: this .implSearchControls = searchControls;
079: }
080:
081: public String getBase() {
082: return implBase;
083: }
084:
085: public String getFilter() {
086: return implFilter;
087: }
088:
089: public Object[] getFilterArgs() {
090: return filterArgs;
091: }
092:
093: public SearchControls getSearchControls() {
094: return implSearchControls;
095: }
096:
097: }
098:
099: public LdapSearchParams createParams(Object[] filterArgs) {
100: return new LdapSearchParamsImpl(base, filter, filterArgs,
101: searchControls);
102: }
103:
104: }
|