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.fileauth;
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 File Authentication.
29 */
30 public class CreateForm {
31
32 /**
33 * Creates a new CreateForm instance.
34 */
35 public CreateForm() {
36 // Default constructor
37 }
38
39 /** The CRUD operation mode for this form. */
40 @ValidateTypeFailure
41 public Integer crudMode;
42
43 /** The hostname of the file server (maximum 100 characters). */
44 @Size(max = 100)
45 public String hostname;
46
47 /** The port number of the file server (0 to 2147483647). */
48 @Min(value = 0)
49 @Max(value = 2147483647)
50 @ValidateTypeFailure
51 public Integer port;
52
53 /** The protocol scheme for file access (maximum 10 characters). */
54 @Size(max = 10)
55 public String protocolScheme;
56
57 /** The username for file authentication (required, maximum 100 characters). */
58 @Required
59 @Size(max = 100)
60 public String username;
61
62 /** The password for file authentication (maximum 100 characters). */
63 @Size(max = 100)
64 public String password;
65
66 /** Additional parameters for file authentication (maximum 1000 characters). */
67 @Size(max = 1000)
68 public String parameters;
69
70 /** The ID of the associated file configuration (required, maximum 1000 characters). */
71 @Required
72 @Size(max = 1000)
73 public String fileConfigId;
74
75 /** The user who created this file authentication configuration (maximum 1000 characters). */
76 @Size(max = 1000)
77 public String createdBy;
78
79 /** The timestamp when this file authentication configuration was created. */
80 @ValidateTypeFailure
81 public Long createdTime;
82
83 /**
84 * Initializes the form with default values for creation mode.
85 */
86 public void initialize() {
87 crudMode = CrudMode.CREATE;
88 createdBy = ComponentUtil.getSystemHelper().getUsername();
89 createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
90 }
91
92 }