001/*
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: LogConstants.java,v 1.16 2008/09/18 22:56:31 veiming Exp $
026 *
027 * Portions Copyrighted 2011-2015 ForgeRock AS.
028 * Portions Copyrighted 2013 Cybernetica AS.
029 * Portions Copyrighted 2014 Nomura Research Institute, Ltd
030 */
031
032package com.sun.identity.log;
033
034import java.util.logging.Level;
035
036/**
037 * Defines constants used in the Logging service. <tt> LogConstants </TT>
038 * helps in maintaining a central repository of all the constants used in the
039 * package.
040 * @supported.api
041 */
042public class LogConstants {
043    /**
044     * Attribute defining the maximum (flat) file size, above which
045     * the files are either archived or rotated.
046     * @supported.api
047     */
048    public static final String MAX_FILE_SIZE =
049        "iplanet-am-logging-max-file-size";
050    /**
051     * Attribute defining the location where the logs go.
052     * @supported.api
053     */
054    public static final String LOG_LOCATION = "iplanet-am-logging-location";
055    /**
056     * Constant for the default base directory "prefix"
057     * for Flat File logging, indicating that the instance's
058     * Configuration directory + server URI should be used.
059     */
060    public static final String DEF_FF_LOG_LOC_BASE = "CONFIG_DIR_SERVER_URI";
061    /**
062     * Attribute defining whether the logs to be stored in
063     * flat-files or to a Database.
064     * @supported.api
065     */
066    public static final String BACKEND = "iplanet-am-logging-type";
067    /**
068     * Attribute defining the user name of the database (for
069     * authenticating to the Database)
070     */
071    public static final String DB_USER  = "iplanet-am-logging-db-user";
072    /**
073     * Attribute defining the password for the user of the db
074     * (for authenticating to DB)
075     */
076    public static final String DB_PASSWORD = "iplanet-am-logging-db-password";
077    /**
078     * Attribute defining the Database Driver.
079     * @supported.api
080     */
081    public static final String DB_DRIVER = "iplanet-am-logging-db-driver";
082    /**
083     * Attribute defining the currently present list of logs in the Directory.
084     */
085    public static final String LOG_LIST = "iplanet-am-logging-log-list";
086    /**
087     * Attribute defining the set of all fields being logged. These fields are
088     * predefined to be time, Date, LoginID, Domain, LogLevel, Data, IPAddr,
089     * and HostName.
090     * @supported.api
091     */
092    public static final String ALL_FIELDS = "iplanet-am-logging-allfields";
093    /**
094     * Attribute defining the fields currently selected by the administrator
095     * to be logged.
096     * @supported.api
097     */
098    public static final String LOG_FIELDS = "iplanet-am-logging-logfields";
099    /**
100     * Attribute defining the FileHandler class
101     */
102    public static final String FILE_HANDLER =
103        "iplanet-am-logging-file-handler";
104    /**
105     * Attribute defining the Database Handler class
106     */
107    public static final String DB_HANDLER = "iplanet-am-logging-jdbc-handler";
108    /**
109     * Attribute defining the Syslog Handler class.
110     */
111    public static final String SYSLOG_HANDLER = "iplanet-am-logging-syslog-handler";
112    /**
113     * Attribute defining the number of history files a (flat file)
114     * log should have.
115     * @supported.api
116     */
117    public static final String NUM_HISTORY_FILES =
118        "iplanet-am-logging-num-hist-file";
119    /**
120     * Attribute defining the RemoteHandler class
121     */
122    public static final String REMOTE_HANDLER =
123        "iplanet-am-logging-remote-handler";
124    /**
125     * Default value for remote handler class
126     */
127   public static final String DEFAULT_REMOTE_HANDER =
128       "com.sun.identity.log.handlers.RemoteHandler";
129
130    /**
131     * Attribute defining the ELFFormatter class.
132     * (OpenAM ELF Formatting. Hence FHandler
133     * should be associated with a ELFFormatter).
134     */
135    public static final String ELF_FORMATTER =
136        "iplanet-am-logging-elf-formatter";
137
138    /**
139     * Attribute defining the RemoteFormatter class which creates a
140     * xml string for a log action and sends it across to the remote
141     * OpenAM.
142     */
143    public static final String REMOTE_FORMATTER =
144        "iplanet-am-logging-remote-formatter";
145    /**
146     * Default value for remote formatter class
147     */
148    public static final String DEFAULT_REMOTE_FORMATTER =
149        "com.sun.identity.log.handlers.RemoteFormatter";
150    /**
151     * Attribute defining the DBFormatter class
152     */
153    public static final String DB_FORMATTER =
154        "iplanet-am-logging-db-formatter";
155    /**
156     * Attribute defining the SyslogFormatter class
157     */
158    public static final String SYSLOG_FORMATTER = "iplanet-am-logging-syslog-formatter";
159    /**
160     * Attribute defining the Authorization class used to see if a particular
161     * user is authorized to perform a particular task.
162     */
163    public static final String AUTHZ = "iplanet-am-logging-authz-class";
164    /**
165     * Attribute defining the Token Class used to generate a Token internally
166     * for use within the logging components.
167     */
168    public static final String TOKEN_PROVIDER =
169        "iplanet-am-logging-token-class";
170    /**
171     * Attribute defining the Archiver class
172     *
173     */
174    public static final String ARCHIVER = "iplanet-am-logging-archiver-class";
175    /**
176     * Platform attribute defining the locale
177     */
178    public static final String LOCALE =
179    "iplanet-am-platform-locale";
180    /**
181     * Naming attribute defining the logging service url.
182     */
183    public static final String LOGGING_SERVICE_URL =
184    "iplanet-am-naming-logging-url";
185    /**
186     * Defines CarriageReturn/LineFeed characters.
187     * @supported.api
188     */
189    public static final String CRLF = "\r\n";
190    /**
191     * Defines the LoggingService name.
192     * @supported.api
193     */
194    public static final String LOGGING_SERVICE = "Logging";
195    /**
196     * Defines the LoggingService name.
197     */
198    public static final String MAC_FIELDNAME = "MAC";
199    /**
200     * Defines the LoggingService name.
201     */
202    public static final String SIGNATURE_FIELDNAME = "Signature";
203    /**
204     * Defines the secure LoggingService log verify period.
205     */
206    public static final String LOGVERIFY_PERIODINSECONDS =
207        "iplanet-am-logging-verify-period-in-seconds";
208    
209    public static final long LOGVERIFY_PERIODINSECONDS_DEFAULT = 3600;
210
211    /**
212     * Defines the LogSign period in seconds.
213     */
214    public static final String LOGSIGN_PERIODINSECONDS         =
215        "iplanet-am-logging-signature-period-in-seconds";
216    
217    public static final long LOGSIGN_PERIODINSECONDS_DEFAULT = 600;
218    
219    /**
220     * Attribute defining the Log Security status; ON or OFF.
221     */
222    public static final String SECURITY_STATUS =
223        "iplanet-am-logging-security-status";
224    
225    /**
226     * Defines the File Read Handler class.
227     */
228    public static final String FILE_READ_HANDLER =
229        "iplanet-am-logging-file-read-handler";
230    /**
231     * Defines the Secure File Handler class.
232     */
233    public static final String SECURE_FILE_HANDLER =
234        "iplanet-am-logging-secure-file-handler";
235    /**
236     * Defines the Secure ELF Formatter class.
237     */
238    public static final String SECURE_ELF_FORMATTER =
239        "iplanet-am-logging-secure-elf-formatter";
240    /**
241     * Defines the DB Read Handler class.
242     */
243    public static final String DB_READ_HANDLER =
244        "sun-am-logging-db-read-handler";
245    
246    /**
247     * Attribute defining the maximum records for flat file logs.
248     * Also the default number of maximum records to be read.
249     */
250    public static final String MAX_RECORDS = "iplanet-am-logging-max-records";
251
252    /**
253     * Default max records if none entered
254     */
255    public static final String MAX_RECORDS_DEFAULT = "500";
256    /**
257     * Default max records, int version
258     */
259    public static final int MAX_RECORDS_DEFAULT_INT = 500;
260
261    /**
262     * Attribute defining the number of files per keystore after which
263     * the keystore should be reinitialized.
264     */
265    public static final String FILES_PER_KEYSTORE =
266        "iplanet-am-logging-files-per-keystore";
267
268    /**
269     * Attribute defining the Class that implements what the
270     * Verifier does when verification fails
271     */
272    public static final String VERIFIER_ACTION_CLASS =
273        "iplanet-am-logging-verifier-action-class";
274
275    /**
276     * Attribute defining the Directory where the logger certificate 
277     * store is stored.
278     */
279    public static final String LOGGER_CERT_STORE =
280        "iplanet-am-logging-secure-certificate-store";
281
282    /**
283     * Attribute defining the Class that implements the custom
284     * debug method in the case of log failure.
285     * @supported.api
286     */
287    public static final String DEBUG_IMPL_CLASS =
288    "iplanet-am-logging-debug-class";
289    /**
290     * Logging property prefix.
291     */
292    public static final String LOG_PROP_PREFIX =
293    "iplanet-am-logging";
294    /**
295     * Attribute defining the Buffer size.
296     * @supported.api
297     */
298    public static final String BUFFER_SIZE = "iplanet-am-logging-buffer-size";
299    /**
300     * Attribute defining the Maximum LogRecords held in memory if
301     * DB logging fails.
302     * @supported.api
303     */
304    public static final String DB_MEM_MAX_RECS =
305        "sun-am-logging-db-max-in-mem";
306    /**
307     * Attribute defining the Buffering time.
308     * @supported.api
309     */
310    public static final String BUFFER_TIME =
311        "iplanet-am-logging-buffer-time-in-seconds";
312    public static final long BUFFER_TIME_DEFAULT = 3600;
313    /**
314     * Attribute defining the Time Buffering Status; ON or OFF.
315     * @supported.api
316     */
317    public static final String TIME_BUFFERING_STATUS =
318        "iplanet-am-logging-time-buffering-status";
319    /**
320     * Attribute defining the Filter Class Name
321     */
322    public static final String FILTER_CLASS_NAME =
323        "iplanet-am-logging-filter-class-name";
324    
325    /**
326     * Attribute defining the Secure Timestamp generator class
327     */
328    public static final String SECURE_TIMESTAMP_GENERATOR =
329        "iplanet-am-logging-secure-timestamp-generator";
330    
331    /**
332     * Attribute defining the secure log helper class
333     */
334    public static final String SECURE_LOG_HELPER =
335        "iplanet-am-logging-secure-log-helper-class-name";
336    
337    /**
338     * Attribute defining the default secure log helper class
339     */
340    public static final String SECURE_DEFAULT_LOG_HELPER =
341        "com.sun.identity.log.secure.SecureLogHelperJSSImpl";
342
343    /**
344     * Attribute defining the security initializer class name
345     */
346    public static final String SECURITY_INITIALIZER =
347        "iplanet-am-logging-security-initializer-class-name";
348    
349    /**
350     * Attribute defining the security signing algorithm
351     */
352    public static final String SECURITY_SIGNING_ALGORITHM =
353        "iplanet-am-logging-secure-signing-algorithm";
354    
355    /**
356     * Attribute defining the default security signing algorithm
357     */
358    public static final String DEFAULT_SECURITY_SIGNING_ALGORITHM =
359        "SHA1withRSA";
360    
361    /**
362     * Attribute defining the log file logging level
363     */
364    public static final String LOGGING_LEVEL = "sun-am-log-level";
365    
366    /**
367     * Attribute defining the Oracle DB data type for the DATA field
368     */
369    public static final String ORA_DBDATA_FIELDTYPE =
370        "sun-am-logging-oradbdata-fieldtype";
371
372    /**
373     * Attribute defining the MySQL DB data type for the DATA field
374     */
375    public static final String MYSQL_DBDATA_FIELDTYPE =
376        "sun-am-logging-mysqldbdata-fieldtype";
377
378    /**
379     * Attribute defining the format for the Oracle DATE/TIME field
380     */
381    public static final String ORA_DBDATETIME_FORMAT =
382        "sun-am-logging-ora-dbdate-format";
383
384    /**
385     * Attribute defining the format for the MySQL DATE/TIME field
386     */
387    public static final String MYSQL_DBDATETIME_FORMAT =
388        "sun-am-logging-mysql-dbdate-format";
389
390    /**
391     * Attribute defining syslog host.
392     */
393    public static final String SYSLOG_HOST = "iplanet-am-logging-syslog-host";
394
395    /**
396     * Attribute defining syslog port.
397     */
398    public static final String SYSLOG_PORT = "iplanet-am-logging-syslog-port";
399    /**
400     * Attribute defining syslog protocol, UDP or TCP.
401     */
402    public static final String SYSLOG_PROTOCOL = "iplanet-am-logging-syslog-protocol";
403
404    /**
405     * Attribute defining syslog facility.
406     */
407    public static final String SYSLOG_FACILITY = "iplanet-am-logging-syslog-facility";
408    
409    /**
410     * Attribute defining syslog connection timeout.
411     */
412    public static final String SYSLOG_CONNECTION_TIMEOUT = "iplanet-am-logging-syslog-connection-timeout";
413
414    /**
415     * Property defining whether logging is enabled
416     * @supported.api
417     */
418    public static final String LOG_STATUS =
419        "com.iplanet.am.logstatus";
420
421    /**
422     * Property defining Logging subdirectory.
423     */
424    public static final String LOG_LOCATION_SUBDIR =
425        "com.sun.identity.log.logSubdir";
426
427    public static final String LOG_READ = "READ";
428    
429    public static final String LOG_WRITE = "WRITE";
430    
431    public static final String LOG_CREATE = "CREATE";
432    
433    public static final String LOG_DELETE  = "DELETE";
434    
435    /*
436     *logInfoMap keys
437     */
438
439    /**
440     * The Date/Time field. This field is one of the two required in
441     * any log record.
442     * @supported.api
443     */
444    public static final String TIME = "TIME";
445    /**
446     * The Data field. This field is one of the two required in
447     * any log record.
448     * @supported.api
449     */
450    public static final String DATA = "Data";
451    /**
452     * The LogLevel field. The level at which the log record was
453     * logged.
454     * @supported.api
455     */
456    public static final String LOG_LEVEL = "LogLevel";
457    /**
458     * The Domain field. The AM Domain pertaining to the log record's
459     * Data field.
460     * @supported.api
461     */
462    public static final String DOMAIN = "Domain";
463    /**
464     * The LoginID field. The AM Login ID pertaining to the log record's
465     * Data field.
466     * @supported.api
467     */
468    public static final String LOGIN_ID = "LoginID";
469    /**
470     * The IPAddr field. The IP Address pertaining to the log record's
471     * Data field.
472     * @supported.api
473     */
474    public static final String IP_ADDR = "IPAddr";
475    /**
476     * The HostName field. The HostName pertaining to the log record's
477     * Data field.
478     * @supported.api
479     */
480    public static final String HOST_NAME = "HostName";
481    /**
482     * The ModuleName field. The AM Module pertaining to the log record's
483     * Data field.
484     * @supported.api
485     */
486    public static final String MODULE_NAME = "ModuleName";
487    /**
488     * The LoggedBy field. The ID associated with who logged the record.
489     * @supported.api
490     */
491    public static final String LOGGED_BY = "LoggedBy";
492    /**
493     * The ContextID field. The ID associated with the user's session
494     * that is the subject of this log record.
495     * @supported.api
496     */
497    public static final String CONTEXT_ID = "ContextID";
498    /**
499     * The NoSession field. Whether the authentication request was made with the noSession query parameter
500     * and that no permanent session was created when the authentication was successful.
501     */
502    public static final String NO_SESSION = "NoSession";
503    /**
504     * The MessageID field. The unique Message Identifier associated with
505     * this particular log record data field.
506     * @supported.api
507     */
508    public static final String MESSAGE_ID = "MessageID";
509
510    /**
511     * The NameID field. The Name Identifier associated with
512     * this particular log record data field.
513     * @supported.api
514     */
515    public static final String NAME_ID = "NameID";
516
517    /**
518     * The maximum number of fields in a "regular" record.
519     * Includes Time, Data, LogLevel, Domain, LoginID, IPAddr,
520     * HostName, ModuleName, LoggedBy, ContextID, MessageID, NameID.
521     * Be sure to increment if more fields are added.
522     * @supported.api
523     */
524    public static final int MAX_FIELDS = 12;
525
526    public static final String LOGIN_ID_SID = "LoginIDSid";
527    public static final String LOGGED_BY_SID = "LoggedBySid";
528
529    public static final String DEFAULT_AGENT_FILE = "amAuthLog";
530    public static final String REST_ACCESS = "amRest.access";
531    public static final String REST_AUTHZ = "amRest.authz";
532    public static final String POLICY_ACCESS = "amPolicy.access";
533    public static final String CONSOLE_ACCESS = "amConsole.access";
534    public static final String AUTHENTICATION_ACCESS =
535        "amAuthentication.access";
536    public static final String AUTHENTICATION_ERROR =
537        "amAuthentication.error";
538    public static final String PASSWORDRESET_ACCESS =
539        "amPasswordReset.access";
540    public static final String SSO_ACCESS = "amSSO.access";
541    public static final String ADMIN_ACCESS = "amAdmin.access";
542    public static final String ADMIN_ERROR = "amAdmin.error";
543    public static final String [] LOGFILENAMES = {
544        DEFAULT_AGENT_FILE,
545        REST_ACCESS,
546        REST_AUTHZ,
547        POLICY_ACCESS,
548        CONSOLE_ACCESS,
549        AUTHENTICATION_ACCESS,
550        AUTHENTICATION_ERROR,
551        PASSWORDRESET_ACCESS,
552        SSO_ACCESS,
553        ADMIN_ACCESS,
554        ADMIN_ERROR };
555
556    public static final int NUM_RECORDS = 0;
557    public static final int NUM_BYTES = 1;
558
559    /**
560     * Key name for enable/disable Hostname resolution
561     */
562    public static final String LOG_RESOLVE_HOSTNAME =
563        "com.sun.identity.log.resolveHostName";
564
565    /**
566     * Attribute name for enable/disable Hostname resolution
567     */
568    public static final String LOG_RESOLVE_HOSTNAME_ATTR =
569        "resolveHostName";
570
571    /**
572     * Attribute name for logging status
573     */
574    public static final String LOG_STATUS_ATTR =
575        "logstatus";
576
577    /**
578     * the "Not Available" String for when a field is not provided
579     */
580    public static final String NOTAVAIL = "Not Available";
581
582    /**
583     * default logging level
584     */
585    public static final String DEFAULT_LOGGING_LEVEL_STR = "INFO"; 
586    public static final Level DEFAULT_LOGGING_LEVEL = Level.INFO;
587
588    /**
589     * logging start due to container starting
590     */
591    public static final String START_LOG_NEW_LOGGER_NAME =
592        "LOG_START_NEW_LOGGER";
593    /**
594     * logging ending due to container terminating
595     */
596    public static final String END_LOG_NAME = "LOG_END";
597    /**
598     * logging start due to logging configuration change
599     */
600    public static final String START_LOG_CONFIG_NAME = "LOG_START_CONFIG";
601    /**
602     * logging termination due to logging configuration change
603     */
604    public static final String END_LOG_CONFIG_NAME = "LOG_END_CONFIG";
605
606    /**
607     * System properties which specifies the log directory.
608     */
609    public static final String SYS_PROP_LOG_DIR = "com.sun.identity.log.dir";
610    /**
611     * Attribute defining the prefix for the logfiles
612     */
613    public static final String LOGFILE_PREFIX = "openam-logging-file-prefix";
614    /**
615     * Attribute defining the suffix for the logfiles. This should be a valid
616     * dateformat string.
617     */
618    public static final String LOGFILE_SUFFIX = "openam-logging-file-suffix";
619    /**
620     * Attribute defining the rotation interval in minutes.
621     */
622    public static final String LOGFILE_ROTATION = "openam-logging-file-rotation";
623
624    /**
625     * Key name for enable/disable log rotation.
626     */
627    public static final String ENABLE_ROTATION = "openam-logging-file-rotation-enabled";
628}