summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/policy/GeneralNameUtil.java
blob: 8f16548db22b883ea8987ae0c82a4a148ede8fd7 (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
// --- 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.cmscore.policy;


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;

import netscape.security.util.DerValue;
import netscape.security.util.ObjectIdentifier;
import netscape.security.x509.DNSName;
import netscape.security.x509.EDIPartyName;
import netscape.security.x509.GeneralName;
import netscape.security.x509.GeneralNameInterface;
import netscape.security.x509.GeneralNames;
import netscape.security.x509.IPAddressName;
import netscape.security.x509.InvalidIPAddressException;
import netscape.security.x509.OIDName;
import netscape.security.x509.RFC822Name;
import netscape.security.x509.URIName;
import netscape.security.x509.X500Name;

import com.netscape.certsrv.apps.CMS;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.EPropertyNotFound;
import com.netscape.certsrv.base.IConfigStore;
import com.netscape.certsrv.policy.IGeneralNameAsConstraintsConfig;
import com.netscape.certsrv.policy.IGeneralNameConfig;
import com.netscape.certsrv.policy.IGeneralNameUtil;
import com.netscape.certsrv.policy.IGeneralNamesAsConstraintsConfig;
import com.netscape.certsrv.policy.IGeneralNamesConfig;
import com.netscape.certsrv.policy.ISubjAltNameConfig;
import com.netscape.cmscore.util.Debug;


/** 
 * Class that can be used to form general names from configuration file. 
 * Used by policies and extension commands.
 */
public class GeneralNameUtil implements IGeneralNameUtil {

    private static final String DOT = ".";

    /**
     * GeneralName can be used in the context of Constraints. Examples
     * are NameConstraints, CertificateScopeOfUse extensions. In such
     * cases, IPAddress may contain netmask component.
     */
    static public GeneralName 
    form_GeneralNameAsConstraints(String generalNameChoice, String value)
        throws EBaseException {
        try {
            if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_IPADDRESS)) {
                StringTokenizer st = new StringTokenizer(value, ",");
                String ip = st.nextToken();
                String netmask = null;

                if (st.hasMoreTokens()) {
                    netmask = st.nextToken();
                }
                return new GeneralName(new IPAddressName(ip, netmask));
            } else {
                return form_GeneralName(generalNameChoice, value);
            }
        } catch (InvalidIPAddressException e) {
            throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_IP_ADDR", value));
        }
    }

    /**
     * Form a General Name from a General Name choice and value.
     * The General Name choice must be one of the General Name Choice Strings 
     * defined in this class.
     * @param generalNameChoice General Name choice. Must be one of the General 
     * Name choices defined in this class.
     * @param value String value of the general name to form.
     */
    static public GeneralName 
    form_GeneralName(String generalNameChoice, String value)
        throws EBaseException {
        GeneralNameInterface generalNameI = null;
        DerValue derVal = null;
        GeneralName generalName = null;

        try {
            if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_OTHERNAME)) {
                byte[] val = com.netscape.osutil.OSUtil.AtoB(value);

                derVal = new DerValue(new ByteArrayInputStream(val));
                Debug.trace("otherName formed");
            } else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_RFC822NAME)) {
                generalNameI = new RFC822Name(value);
                Debug.trace("rfc822Name formed ");
            } else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_DNSNAME)) {
                generalNameI = new DNSName(value);
                Debug.trace("dnsName formed");
            } /** not supported -- no sun class 
             else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_X400ADDRESS)) {
             }
             **/ else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_DIRECTORYNAME)) {
                generalNameI = new X500Name(value);
                Debug.trace("X500Name formed");
            } else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_EDIPARTYNAME)) {
                generalNameI = new EDIPartyName(value);
                Debug.trace("ediPartyName formed");
            } else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_URL)) {
                generalNameI = new URIName(value);
                Debug.trace("url formed");
            } else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_IPADDRESS)) {
                generalNameI = new IPAddressName(value);
                Debug.trace("ipaddress formed");
            } else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_REGISTEREDID)) {
                ObjectIdentifier oid;

                try {
                    oid = new ObjectIdentifier(value);
                } catch (Exception e) {
                    throw new EBaseException(
                            CMS.getUserMessage("CMS_BASE_INVALID_VALUE_FOR_TYPE",
                                generalNameChoice,
                                "value must be a valid OID in the form n.n.n.n"));
                }
                generalNameI = new OIDName(oid);
                Debug.trace("oidname formed");
            } else {
                throw new EBaseException(
                        CMS.getUserMessage("CMS_BASE_INVALID_ATTR_VALUE",
                            new String[] { 
                                PROP_GENNAME_CHOICE,
                                "value must be one of: " +
                                GENNAME_CHOICE_OTHERNAME + ", " +
                                GENNAME_CHOICE_RFC822NAME + ", " +
                                GENNAME_CHOICE_DNSNAME + ", " +
                            
                                /* GENNAME_CHOICE_X400ADDRESS +", "+ */
                                GENNAME_CHOICE_DIRECTORYNAME + ", " +
                                GENNAME_CHOICE_EDIPARTYNAME + ", " +
                                GENNAME_CHOICE_URL + ", " +
                                GENNAME_CHOICE_IPADDRESS + ", or " +
                                GENNAME_CHOICE_REGISTEREDID + "."
                            }
                        ));
            }
        } catch (IOException e) {
            Debug.printStackTrace(e);
            throw new EBaseException(
                    CMS.getUserMessage("CMS_BASE_INVALID_VALUE_FOR_TYPE",
                        generalNameChoice, e.toString()));
        } catch (InvalidIPAddressException e) {
            Debug.printStackTrace(e);
            throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_IP_ADDR", value));
        } catch (RuntimeException e) {
            Debug.printStackTrace(e);
            throw e;
        }

        try {
            if (generalNameI != null)
                generalName = new GeneralName(generalNameI);
            else
                generalName = new GeneralName(derVal);
            Debug.trace("general name formed");
            return generalName;
        } catch (IOException e) {
            Debug.printStackTrace(e);
            throw new EBaseException(
                    CMS.getUserMessage("CMS_BASE_INTERNAL_ERROR", "Could not form GeneralName. Error: " + e));
        }
    }

    /**
     * Checks if given string is a valid General Name choice and returns 
     * the actual string that can be passed into form_GeneralName().
     * @param generalNameChoice a General Name choice string.
     * @return one of General Name choices defined in this class that can be 
     * passed into form_GeneralName().
     */
    static public String check_GeneralNameChoice(String generalNameChoice) 
        throws EBaseException {
        String theGeneralNameChoice = null;

        if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_OTHERNAME)) 
            theGeneralNameChoice = GENNAME_CHOICE_OTHERNAME;
        else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_RFC822NAME)) 
            theGeneralNameChoice = GENNAME_CHOICE_RFC822NAME;
        else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_DNSNAME)) 
            theGeneralNameChoice = GENNAME_CHOICE_DNSNAME;

            /* X400Address not supported.
             else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_X400ADDRESS)) 
             theGeneralNameChoice = GENNAME_CHOICE_X400ADDRESS;
             */
        else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_DIRECTORYNAME)) 
            theGeneralNameChoice = GENNAME_CHOICE_DIRECTORYNAME;
        else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_EDIPARTYNAME)) 
            theGeneralNameChoice = GENNAME_CHOICE_EDIPARTYNAME;
        else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_URL)) 
            theGeneralNameChoice = GENNAME_CHOICE_URL;
        else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_IPADDRESS)) 
            theGeneralNameChoice = GENNAME_CHOICE_IPADDRESS;
        else if (generalNameChoice.equalsIgnoreCase(GENNAME_CHOICE_REGISTEREDID)) 
            theGeneralNameChoice = GENNAME_CHOICE_REGISTEREDID;
        else {
            throw new EBaseException(
                    CMS.getUserMessage("CMS_BASE_INVALID_ATTR_VALUE",
                        new String[] { 
                            PROP_GENNAME_CHOICE + "=" + generalNameChoice,
                            "value must be one of: " +
                            GENNAME_CHOICE_OTHERNAME + ", " +
                            GENNAME_CHOICE_RFC822NAME + ", " +
                            GENNAME_CHOICE_DNSNAME + ", " +
                        
                            /* GENNAME_CHOICE_X400ADDRESS +", "+ */
                            GENNAME_CHOICE_DIRECTORYNAME + ", " +
                            GENNAME_CHOICE_EDIPARTYNAME + ", " +
                            GENNAME_CHOICE_URL + ", " +
                            GENNAME_CHOICE_IPADDRESS + ", " +
                            GENNAME_CHOICE_REGISTEREDID + "."
                        }
                    ));
        }
        return theGeneralNameChoice;
    }

    static public class GeneralNamesConfig implements IGeneralNamesConfig {
        public String mName = null; // substore name of config if any.
        public GeneralNameConfig[] mGenNameConfigs = null; 
        public IConfigStore mConfig = null;
        public boolean mIsValueConfigured = true;
        public boolean mIsPolicyEnabled = true;
        public int mDefNumGenNames = DEF_NUM_GENERALNAMES;
        public GeneralNames mGeneralNames = null;

        private String mNameDotGeneralName = mName + DOT + PROP_GENERALNAME;

        public GeneralNamesConfig(
            String name, 
            IConfigStore config, 
            boolean isValueConfigured,
            boolean isPolicyEnabled)
            throws EBaseException {
            mIsValueConfigured = isValueConfigured;
            mIsPolicyEnabled = isPolicyEnabled;
            mName = name;
            if (mName != null) 
                mNameDotGeneralName = mName + DOT + PROP_GENERALNAME;
            else 
                mNameDotGeneralName = PROP_GENERALNAME;
            mConfig = config;

            int numGNs = mConfig.getInteger(PROP_NUM_GENERALNAMES);

            if (numGNs < 0) {
                throw new EBaseException(
                        CMS.getUserMessage("CMS_BASE_INVALID_ATTR_VALUE",
                            new String[] { 
                                PROP_NUM_GENERALNAMES + "=" + numGNs, 
                                "value must be greater than or equal to 0."}
                        ));
            }
            mGenNameConfigs = new GeneralNameConfig[numGNs];
            for (int i = 0; i < numGNs; i++) {
                String storeName = mNameDotGeneralName + i;

                mGenNameConfigs[i] = 
                        newGeneralNameConfig(
                            storeName, mConfig.getSubStore(storeName), 
                            mIsValueConfigured, mIsPolicyEnabled);
            }

            if (mIsValueConfigured && mIsPolicyEnabled) {
                mGeneralNames = new GeneralNames();
                for (int j = 0; j < numGNs; j++) {
                    mGeneralNames.addElement(mGenNameConfigs[j].mGeneralName);
                }
            }
        }

        public GeneralNames getGeneralNames() {
            return mGeneralNames;
        }

        protected GeneralNameConfig newGeneralNameConfig(
            String name, IConfigStore config, 
            boolean isValueConfigured, boolean isPolicyEnabled) 
            throws EBaseException {
            return new GeneralNameConfig(
                    name, config, isValueConfigured, isPolicyEnabled);
        }

        public GeneralNameConfig[] getGenNameConfig() {
            return (GeneralNameConfig[]) mGenNameConfigs.clone();
        }

        public int getNumGeneralNames() {
            return mGenNameConfigs.length;
        }

        public IConfigStore getConfig() {
            return mConfig;
        }

        public String getName() {
            return mName;
        }

        public boolean isValueConfigured() {
            return mIsValueConfigured;
        }

        public void setDefNumGenNames(int defNum) {
            mDefNumGenNames = defNum;
        }

        public int getDefNumGenNames() {
            return mDefNumGenNames;
        }

        /** 
         * adds params to default 
         */
        public static void getDefaultParams(
            String name, boolean isValueConfigured, Vector params) {
            String nameDot = "";

            if (name != null) 
                nameDot = name + DOT;
            params.addElement(
                nameDot + PROP_NUM_GENERALNAMES + '=' + DEF_NUM_GENERALNAMES);
            for (int i = 0; i < DEF_NUM_GENERALNAMES; i++) {
                GeneralNameConfig.getDefaultParams(
                    nameDot + PROP_GENERALNAME + i, isValueConfigured, params);
            }
        }

        /**
         * Get instance params.
         */
        public void getInstanceParams(Vector params) {
            params.addElement(
                PROP_NUM_GENERALNAMES + '=' + mGenNameConfigs.length);
            for (int i = 0; i < mGenNameConfigs.length; i++) {
                mGenNameConfigs[i].getInstanceParams(params);
            }
        }

        /**
         * Get extended plugin info.
         */
        public static void getExtendedPluginInfo(
            String name, boolean isValueConfigured, Vector info) {
            String nameDot = "";

            if (name != null && name.length() > 0)
                nameDot = name + ".";
            info.addElement(PROP_NUM_GENERALNAMES + ";" + NUM_GENERALNAMES_INFO);
            for (int i = 0; i < DEF_NUM_GENERALNAMES; i++) {
                GeneralNameConfig.getExtendedPluginInfo(
                    nameDot + PROP_GENERALNAME + i, isValueConfigured, info);
            }
        }

    }


    static public class GeneralNamesAsConstraintsConfig extends GeneralNamesConfig implements IGeneralNamesAsConstraintsConfig {
        public GeneralNamesAsConstraintsConfig(
            String name, 
            IConfigStore config, 
            boolean isValueConfigured,
            boolean isPolicyEnabled)
            throws EBaseException {
            super(name, config, isValueConfigured, isPolicyEnabled);
        }

        protected GeneralNameConfig newGeneralNameConfig(
            String name, IConfigStore config, 
            boolean isValueConfigured, boolean isPolicyEnabled) 
            throws EBaseException {
            return new GeneralNameAsConstraintsConfig(name, config, 
                    isValueConfigured, isPolicyEnabled);
        }
    }


    /**
     * convenience class for policies use.
     */
    static public class GeneralNameConfig implements IGeneralNameConfig {
        public String mName = null;
        public String mNameDot = null;
        public IConfigStore mConfig = null;
        public String mGenNameChoice = null;
        public boolean mIsValueConfigured = true;
        public String mValue = null; // used only if isValueConfigured
        public GeneralName mGeneralName = null; // used only if isValueConfiged.
        public boolean mIsPolicyEnabled = true;

        public String mNameDotChoice = null;
        public String mNameDotValue = null;

        public GeneralNameConfig(
            String name, 
            IConfigStore config, 
            boolean isValueConfigured, 
            boolean isPolicyEnabled) 
            throws EBaseException {
            mIsValueConfigured = isValueConfigured;
            mIsPolicyEnabled = isPolicyEnabled;
            mName = name;
            if (mName != null && mName.length() > 0) {
                mNameDot = mName + DOT;
                mNameDotChoice = mNameDot + PROP_GENNAME_CHOICE;
                mNameDotValue = mNameDot + PROP_GENNAME_VALUE;
            } else {
                mNameDot = "";
                mNameDotChoice = PROP_GENNAME_CHOICE;
                mNameDotValue = PROP_GENNAME_VALUE;
            }
            mConfig = config;

            // necessary to expand/shrink # general names from console.
            if (mConfig.size() == 0) {
                config.putString(mNameDotChoice, "");
                if (mIsValueConfigured)
                    config.putString(mNameDotValue, "");
            }

            String choice = null;

            if (mIsPolicyEnabled) {
                choice = mConfig.getString(PROP_GENNAME_CHOICE);
                mGenNameChoice = check_GeneralNameChoice(choice);
            } else {
                choice = mConfig.getString(PROP_GENNAME_CHOICE, "");
                if (choice.length() > 0 && !choice.equals("null")) {
                    mGenNameChoice = check_GeneralNameChoice(choice);
                }
            }
            if (mIsValueConfigured) {
                if (mIsPolicyEnabled) {
                    mValue = mConfig.getString(PROP_GENNAME_VALUE);
                    mGeneralName = formGeneralName(mGenNameChoice, mValue);
                } else {
                    mValue = mConfig.getString(PROP_GENNAME_VALUE, "");
                    if (mValue != null && mValue.length() > 0) 
                        mGeneralName = formGeneralName(mGenNameChoice, mValue);
                }
            }
        }

        /**
         * Form a general name from the value string.
         */
        public GeneralName formGeneralName(String value) 
            throws EBaseException {
            return formGeneralName(mGenNameChoice, value);
        }

        public GeneralName formGeneralName(String choice, String value) 
            throws EBaseException {
            return form_GeneralName(choice, value);
        }

        /** 
         * @return a vector of General names from a value that can be 
         * either a Vector of strings, string array or just a string.
         * Returned Vector can be null if value is not of expected type.
         */
        public Vector formGeneralNames(Object value) 
            throws EBaseException {
            Vector gns = new Vector();
            GeneralName gn = null;

            if (value instanceof String) {
                if (((String) (value = ((String) value).trim())).length() > 0) {
                    gn = formGeneralName(mGenNameChoice, (String) value);
                    gns.addElement(gn);
                }
            } else if (value instanceof String[]) {
                String[] vals = (String[]) value;

                for (int i = 0; i < vals.length; i++) {
                    String val = vals[i].trim();

                    if (val != null && val.length() > 0) {
                        gn = formGeneralName(mGenNameChoice, val);
                        gns.addElement(gn);
                    }
                }
            } else if (value instanceof Vector) {
                Vector vals = (Vector) value;

                for (Enumeration n = vals.elements(); n.hasMoreElements();) {
                    Object val = n.nextElement();

                    if (val != null && (val instanceof String) &&
                        ((String) (val = ((String) val).trim())).length() > 0) {
                        gn = formGeneralName(mGenNameChoice, (String) val);
                        gns.addElement(gn);
                    }
                }
            }
            return gns;
        }

        public String getName() {
            return mName;
        }

        public IConfigStore getConfig() {
            return mConfig;
        }

        public String getGenNameChoice() {
            return mGenNameChoice;
        }

        public String getValue() {
            return mValue;
        }

        /*
         public GeneralNameInterface getGeneralName() {
         return mGeneralName;
         }

         */
        public boolean isValueConfigured() {
            return mIsValueConfigured;
        }

        /**
         * Get default params
         */

        public static void getDefaultParams(
            String name, boolean isValueConfigured, Vector params) {
            String nameDot = "";

            if (name != null)
                nameDot = name + ".";
            Debug.trace("GeneralnameConfig getDefaultParams");
            params.addElement(nameDot + PROP_GENNAME_CHOICE + "=");
            if (isValueConfigured)
                params.addElement(nameDot + PROP_GENNAME_VALUE + "=");
        }

        /**
         * Get instance params 
         */
        public void getInstanceParams(Vector params) {
            String value = (mValue == null) ? "" : mValue;
            String choice = (mGenNameChoice == null) ? "" : mGenNameChoice;

            params.addElement(mNameDotChoice + "=" + choice);
            if (mIsValueConfigured) 
                params.addElement(mNameDotValue + "=" + value);
        }

        /**
         * Get extended plugin info
         */
        public static void getExtendedPluginInfo(
            String name, boolean isValueConfigured, Vector info) {
            String nameDot = "";

            if (name != null && name.length() > 0) 
                nameDot = name + ".";
            info.addElement(
                nameDot + PROP_GENNAME_CHOICE + ";" + GENNAME_CHOICE_INFO);
            if (isValueConfigured) 
                info.addElement(
                    nameDot + PROP_GENNAME_VALUE + ";" + GENNAME_VALUE_INFO);
        }
    }


    /**
     * convenience class for policies use.
     */
    static public class GeneralNameAsConstraintsConfig extends GeneralNameConfig implements IGeneralNameAsConstraintsConfig {
		
        public GeneralNameAsConstraintsConfig(
            String name,
            IConfigStore config,
            boolean isValueConfigured,
            boolean isPolicyEnabled)
            throws EBaseException {
            super(name, config, isValueConfigured, isPolicyEnabled);
        }

        public GeneralName getGeneralName() {
            return mGeneralName;
        }

        /**
         * Form a general name from the value string.
         */
        public GeneralName formGeneralName(String choice, String value) 
            throws EBaseException {
            return form_GeneralNameAsConstraints(choice, value);
        }
    }


    public static class SubjAltNameGN extends GeneralNameUtil.GeneralNameConfig implements ISubjAltNameConfig {
        static final String REQUEST_ATTR_INFO =
            "string;Request attribute name. " +
            "The value of the request attribute will be used to form a " +
            "General Name in the Subject Alternative Name extension.";

        static final String PROP_REQUEST_ATTR = "requestAttr";

        String mRequestAttr = null;
        String mPfx = null;
        String mAttr = null;

        public SubjAltNameGN(
            String name, IConfigStore config, boolean isPolicyEnabled)
            throws EBaseException {
            super(name, config, false, isPolicyEnabled);

            mRequestAttr = mConfig.getString(PROP_REQUEST_ATTR, null);
            if (mRequestAttr == null) {
                mConfig.putString(mNameDot + PROP_REQUEST_ATTR, "");
                mRequestAttr = "";
            }
            if (isPolicyEnabled && mRequestAttr.length() == 0) {
                throw new EPropertyNotFound(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", 
                            mConfig.getName() + "." + PROP_REQUEST_ATTR));
            }
            int x = mRequestAttr.indexOf('.');

            if (x == -1)
                mAttr = mRequestAttr;
            else {
                mPfx = mRequestAttr.substring(0, x).trim();
                mAttr = mRequestAttr.substring(x + 1).trim();
            }
        }

        public String getPfx() {
            return mPfx;
        }

        public String getAttr() {
            return mAttr;
        }

        public void getInstanceParams(Vector params) {
            params.addElement(mNameDot + PROP_REQUEST_ATTR + "=" + mRequestAttr);
            super.getInstanceParams(params);
        }

        public static void getDefaultParams(String name, Vector params) {
            String nameDot = "";

            if (name != null && name.length() > 0)
                nameDot = name + ".";
            params.addElement(nameDot + PROP_REQUEST_ATTR + "=");
            GeneralNameUtil.GeneralNameConfig.getDefaultParams(name, false, params);
        }

        public static void getExtendedPluginInfo(String name, Vector params) {
            String nameDot = "";

            if (name != null && name.length() > 0)
                nameDot = name + ".";
            params.addElement(nameDot + PROP_REQUEST_ATTR + ";" + REQUEST_ATTR_INFO);
            GeneralNameUtil.GeneralNameConfig.getExtendedPluginInfo(name, false, params);
        }
    }
}