1 /*
2 * Copyright 2012-2025 CodeLibs Project and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.codelibs.fess.app.web.admin.webauth;
17
18 import org.codelibs.fess.app.web.CrudMode;
19 import org.codelibs.fess.util.ComponentUtil;
20 import org.lastaflute.web.validation.Required;
21 import org.lastaflute.web.validation.theme.conversion.ValidateTypeFailure;
22
23 import jakarta.validation.constraints.Max;
24 import jakarta.validation.constraints.Min;
25 import jakarta.validation.constraints.Size;
26
27 /**
28 * The create form for Web Authentication.
29 */
30 public class CreateForm {
31
32 /**
33 * Default constructor.
34 */
35 public CreateForm() {
36 // Empty constructor
37 }
38
39 /**
40 * The CRUD mode for the form.
41 */
42 @ValidateTypeFailure
43 public Integer crudMode;
44
45 /**
46 * The hostname for the web authentication.
47 */
48 @Size(max = 100)
49 public String hostname;
50
51 /**
52 * The port number for the web authentication.
53 */
54 @Min(value = 0)
55 @Max(value = 2147483647)
56 @ValidateTypeFailure
57 public Integer port;
58
59 /**
60 * The authentication realm.
61 */
62 @Size(max = 100)
63 public String authRealm;
64
65 /**
66 * The protocol scheme (http, https).
67 */
68 @Size(max = 10)
69 public String protocolScheme;
70
71 /**
72 * The username for authentication.
73 */
74 @Required
75 @Size(max = 100)
76 public String username;
77
78 /**
79 * The password for authentication.
80 */
81 @Size(max = 100)
82 public String password;
83
84 /**
85 * Additional parameters for the authentication.
86 */
87 @Size(max = 1000)
88 public String parameters;
89
90 /**
91 * The web configuration ID this authentication is associated with.
92 */
93 @Required
94 @Size(max = 1000)
95 public String webConfigId;
96
97 /**
98 * The user who created this authentication configuration.
99 */
100 @Size(max = 1000)
101 public String createdBy;
102
103 /**
104 * The timestamp when this authentication configuration was created.
105 */
106 @ValidateTypeFailure
107 public Long createdTime;
108
109 /**
110 * Initializes the form with default values for creating a new web authentication configuration.
111 */
112 public void initialize() {
113 crudMode = CrudMode.CREATE;
114 createdBy = ComponentUtil.getSystemHelper().getUsername();
115 createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
116 }
117 }