1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
// --- 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.extensions;
import java.util.*;
import java.io.*;
import java.security.cert.*;
import com.netscape.certsrv.request.IRequest;
import com.netscape.certsrv.request.PolicyResult;
import com.netscape.certsrv.policy.*;
import com.netscape.certsrv.base.*;
import com.netscape.certsrv.ca.*;
import com.netscape.certsrv.authority.*;
import com.netscape.certsrv.authentication.*;
import com.netscape.certsrv.common.*;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.extensions.*;
import com.netscape.certsrv.ca.*;
import netscape.ldap.*;
import netscape.security.extensions.*;
import com.netscape.cms.policy.APolicyRule;
/**
* Checks extension presence.
*
* @version $Revision$, $Date$
*/
public class PresenceExt extends APolicyRule {
private static Vector mDefParams = new Vector();
private IConfigStore mConfig = null;
private String mOID = null;
private boolean mCritical;
private int mVersion = 0;
private String mStreetAddress;
private String mTelephoneNumber;
private String mRFC822Name;
private String mID;
private String mHostName;
private int mPortNumber = 0;
private int mMaxUsers = 0;
private int mServiceLevel = 0;
public static final String PROP_IS_CRITICAL = "critical";
public static final String PROP_OID = "oid";
public static final String PROP_VERSION = "version";
public static final String PROP_STREET_ADDRESS = "streetAddress";
public static final String PROP_TELEPHONE_NUMBER = "telephoneNumber";
public static final String PROP_RFC822_NAME = "rfc822Name";
public static final String PROP_ID = "id";
public static final String PROP_HOSTNAME = "hostName";
public static final String PROP_PORT_NUMBER = "portNumber";
public static final String PROP_MAX_USERS = "maxUsers";
public static final String PROP_SERVICE_LEVEL = "serviceLevel";
static {
mDefParams.addElement(PROP_IS_CRITICAL + "=false");
}
public PresenceExt() {
NAME = "PresenceExtPolicy";
DESC = "Sets Presence Server Extension in certificates.";
}
public void init(ISubsystem owner, IConfigStore config)
throws EBaseException {
mConfig = config;
mCritical = config.getBoolean(PROP_IS_CRITICAL, false);
mOID = config.getString(PROP_OID, "");
mVersion = config.getInteger(PROP_VERSION, 0);
mStreetAddress = config.getString(PROP_STREET_ADDRESS, "");
mTelephoneNumber = config.getString(PROP_TELEPHONE_NUMBER, "");
mRFC822Name = config.getString(PROP_RFC822_NAME, "");
mID = config.getString(PROP_ID, "");
mHostName = config.getString(PROP_HOSTNAME, "");
mPortNumber = config.getInteger(PROP_PORT_NUMBER, 0);
mMaxUsers = config.getInteger(PROP_MAX_USERS, 0);
mServiceLevel = config.getInteger(PROP_SERVICE_LEVEL, 0);
}
public PolicyResult apply(IRequest req) {
PolicyResult res = PolicyResult.ACCEPTED;
/*
PresenceServerExtension ext = new PresenceServerExtension(mCritical,
mOID, mVersion, mStreetAddress,
mTelephoneNumber, mRFC822Name, mID,
mHostName, mPortNumber, mMaxUsers, mServiceLevel);
*/
return res;
}
public Vector getInstanceParams() {
Vector params = new Vector();
params.addElement(PROP_IS_CRITICAL + "=" + mCritical);
params.addElement(PROP_OID + "=" + mOID);
params.addElement(PROP_VERSION + "=" + mVersion);
params.addElement(PROP_STREET_ADDRESS + "=" + mStreetAddress);
params.addElement(PROP_TELEPHONE_NUMBER + "=" + mTelephoneNumber);
params.addElement(PROP_RFC822_NAME + "=" + mRFC822Name);
params.addElement(PROP_ID + "=" + mID);
params.addElement(PROP_HOSTNAME + "=" + mHostName);
params.addElement(PROP_PORT_NUMBER + "=" + mPortNumber);
params.addElement(PROP_MAX_USERS + "=" + mMaxUsers);
params.addElement(PROP_SERVICE_LEVEL + "=" + mServiceLevel);
return params;
}
public String[] getExtendedPluginInfo(Locale locale) {
String[] params = {
PROP_IS_CRITICAL + ";boolean;Criticality",
PROP_OID + ";string; Object identifier of this extension",
PROP_VERSION + ";string; version",
PROP_STREET_ADDRESS + ";string; street address",
PROP_TELEPHONE_NUMBER + ";string; telephone number",
PROP_RFC822_NAME + ";string; rfc822 name",
PROP_ID + ";string; identifier",
PROP_HOSTNAME + ";string; host name",
PROP_PORT_NUMBER + ";string; port number",
PROP_MAX_USERS + ";string; max users",
PROP_SERVICE_LEVEL + ";string; service level",
IExtendedPluginInfo.HELP_TOKEN +
";configuration-policyrules-presenceext",
IExtendedPluginInfo.HELP_TEXT +
";Adds Presence Server Extension;"
};
return params;
}
/**
* Return default parameters for a policy implementation.
*
* @return nvPairs A Vector of name/value pairs.
*/
public Vector getDefaultParams() {
return mDefParams;
}
}
|