// --- BEGIN COPYRIGHT BLOCK --- // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; version 2 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // // (C) 2007 Red Hat, Inc. // All rights reserved. // --- END COPYRIGHT BLOCK --- package com.netscape.cms.policy.constraints; import java.util.Enumeration; import java.util.Hashtable; import java.util.Locale; import java.util.Vector; import netscape.ldap.LDAPAttribute; import netscape.ldap.LDAPConnection; import netscape.ldap.LDAPEntry; import netscape.ldap.LDAPException; import netscape.ldap.LDAPSearchResults; import netscape.ldap.LDAPv2; import com.netscape.certsrv.apps.CMS; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.base.IConfigStore; import com.netscape.certsrv.base.IExtendedPluginInfo; import com.netscape.certsrv.base.ISubsystem; import com.netscape.certsrv.ldap.ILdapConnFactory; import com.netscape.certsrv.logging.ILogger; import com.netscape.certsrv.policy.IEnrollmentPolicy; import com.netscape.certsrv.request.IRequest; import com.netscape.certsrv.request.PolicyResult; import com.netscape.cms.policy.APolicyRule; /** * This checks if attribute present. *
* *
* NOTE: The Policy Framework has been replaced by the Profile Framework. **
*
* @deprecated
* @version $Revision$, $Date$
*/
public class AttributePresentConstraints extends APolicyRule
implements IEnrollmentPolicy, IExtendedPluginInfo {
protected static final String PROP_ENABLED = "enabled";
protected static final String PROP_LDAP = "ldap";
protected String mName = null;
protected String mImplName = null;
private ILogger mLogger = CMS.getLogger();
private IConfigStore mConfig = null;
private IConfigStore mLdapConfig = null;
private ILdapConnFactory mConnFactory = null;
private LDAPConnection mCheckAttrLdapConnection = null;
public AttributePresentConstraints() {
DESC = "Rejects request if ldap attribute is not present in the " +
"directory.";
}
public String[] getExtendedPluginInfo(Locale locale) {
String params[] = {
PROP_ATTR + ";string,required;Ldap attribute to check presence of (default " +
DEF_ATTR + ")",
PROP_VALUE + ";string;if this parameter is non-empty, the attribute must " +
"match this value for the request to proceed ",
PROP_LDAP_BASE + ";string,required;Base DN to start searching " +
"under. If your user's DN is 'uid=jsmith, o=company', you " +
"might want to use 'o=company' here",
PROP_LDAP_HOST + ";string,required;" +
"LDAP host to connect to",
PROP_LDAP_PORT + ";number,required;" +
"LDAP port number (use 389, or 636 if SSL)",
PROP_LDAP_SSL + ";boolean;" +
"Use SSL to connect to directory?",
PROP_LDAP_VER + ";choice(3,2),required;" +
"LDAP protocol version",
PROP_LDAP_BIND + ";string;DN to bind as for attribute checking. " +
"For example 'CN=Pincheck User'",
PROP_LDAP_PW + ";password;Enter password used to bind as " +
"the above user",
PROP_LDAP_AUTH + ";choice(BasicAuth,SslClientAuth),required;" +
"How to bind to the directory",
PROP_LDAP_CERT + ";string;If you want to use " +
"SSL client auth to the directory, set the client " +
"cert nickname here",
PROP_LDAP_BASE + ";string,required;Base DN to start searching " +
"under. If your user's DN is 'uid=jsmith, o=company', you " +
"might want to use 'o=company' here",
PROP_LDAP_MINC + ";number;number of connections " +
"to keep open to directory server. Default " + DEF_LDAP_MINC,
PROP_LDAP_MAXC + ";number;when needed, connection " +
"pool can grow to this many (multiplexed) connections. Default " + DEF_LDAP_MAXC,
IExtendedPluginInfo.HELP_TOKEN +
";configuration-policyrules-pinpresent",
IExtendedPluginInfo.HELP_TEXT +
";" + DESC + " This plugin can be used to " +
"check the presence (and, optionally, the value) of any LDAP " +
"attribute for the user. "
};
return params;
}
public String getName() {
return mName;
}
public String getImplName() {
return mImplName;
}
public IConfigStore getConfigStore() {
return mConfig;
}
public void shutdown() {
}
// Parameters
protected static final String PROP_LDAP_HOST = "ldap.ldapconn.host";
protected static final String DEF_LDAP_HOST = "localhost";
protected static final String PROP_LDAP_PORT = "ldap.ldapconn.port";
protected static final Integer DEF_LDAP_PORT = Integer.valueOf(389);
protected static final String PROP_LDAP_SSL = "ldap.ldapconn.secureConn";
protected static final Boolean DEF_LDAP_SSL = Boolean.FALSE;
protected static final String PROP_LDAP_VER = "ldap.ldapconn.version";
protected static final Integer DEF_LDAP_VER = Integer.valueOf(3);
protected static final String PROP_LDAP_BIND = "ldap.ldapauth.bindDN";
protected static final String DEF_LDAP_BIND = "CN=Directory Manager";
protected static final String PROP_LDAP_PW = "ldap.ldapauth.bindPWPrompt";
protected static final String DEF_LDAP_PW = "";
protected static final String PROP_LDAP_CERT = "ldap.ldapauth.clientCertNickname";
protected static final String DEF_LDAP_CERT = "";
protected static final String PROP_LDAP_AUTH = "ldap.ldapauth.authtype";
protected static final String DEF_LDAP_AUTH = "BasicAuth";
protected static final String PROP_LDAP_BASE = "ldap.ldapconn.basedn";
protected static final String DEF_LDAP_BASE = "";
protected static final String PROP_LDAP_MINC = "ldap.ldapconn.minConns";
protected static final Integer DEF_LDAP_MINC = Integer.valueOf(1);
protected static final String PROP_LDAP_MAXC = "ldap.ldapconn.maxConns";
protected static final Integer DEF_LDAP_MAXC = Integer.valueOf(5);
protected static final String PROP_ATTR = "attribute";
protected static final String DEF_ATTR = "pin";
protected static final String PROP_VALUE = "value";
protected static final String DEF_VALUE = "";
protected static Vector