yangys
2024-04-04 ed4a5236bab800094be4a8378f5098eebe3de6ac
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
package com.qianwen.core.secure.registry;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.qianwen.core.secure.props.AuthSecure;
import com.qianwen.core.secure.props.BasicSecure;
import com.qianwen.core.secure.props.SignSecure;
import com.qianwen.core.secure.provider.HttpMethod;
 
public class SecureRegistry {
    private boolean enabled = false;
    private boolean authEnabled = true;
    private boolean basicEnabled = true;
    private boolean signEnabled = true;
    private boolean clientEnabled = true;
    private final List<String> defaultExcludePatterns = new ArrayList<>();
    private final List<String> excludePatterns = new ArrayList<>();
    private final List<AuthSecure> authSecures = new ArrayList<>();
    private final List<BasicSecure> basicSecures = new ArrayList<>();
    private final List<SignSecure> signSecures = new ArrayList<>();
 
    public void setEnabled(final boolean enabled) {
        this.enabled = enabled;
    }
 
    public void setAuthEnabled(final boolean authEnabled) {
        this.authEnabled = authEnabled;
    }
 
    public void setBasicEnabled(final boolean basicEnabled) {
        this.basicEnabled = basicEnabled;
    }
 
    public void setSignEnabled(final boolean signEnabled) {
        this.signEnabled = signEnabled;
    }
 
    public void setClientEnabled(final boolean clientEnabled) {
        this.clientEnabled = clientEnabled;
    }
 
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (o instanceof SecureRegistry) {
            SecureRegistry other = (SecureRegistry) o;
            if (other.canEqual(this) && isEnabled() == other.isEnabled() && isAuthEnabled() == other.isAuthEnabled() && isBasicEnabled() == other.isBasicEnabled() && isSignEnabled() == other.isSignEnabled() && isClientEnabled() == other.isClientEnabled()) {
                Object this$defaultExcludePatterns = getDefaultExcludePatterns();
                Object other$defaultExcludePatterns = other.getDefaultExcludePatterns();
                if (this$defaultExcludePatterns == null) {
                    if (other$defaultExcludePatterns != null) {
                        return false;
                    }
                } else if (!this$defaultExcludePatterns.equals(other$defaultExcludePatterns)) {
                    return false;
                }
                Object this$excludePatterns = getExcludePatterns();
                Object other$excludePatterns = other.getExcludePatterns();
                if (this$excludePatterns == null) {
                    if (other$excludePatterns != null) {
                        return false;
                    }
                } else if (!this$excludePatterns.equals(other$excludePatterns)) {
                    return false;
                }
                Object this$authSecures = getAuthSecures();
                Object other$authSecures = other.getAuthSecures();
                if (this$authSecures == null) {
                    if (other$authSecures != null) {
                        return false;
                    }
                } else if (!this$authSecures.equals(other$authSecures)) {
                    return false;
                }
                Object this$basicSecures = getBasicSecures();
                Object other$basicSecures = other.getBasicSecures();
                if (this$basicSecures == null) {
                    if (other$basicSecures != null) {
                        return false;
                    }
                } else if (!this$basicSecures.equals(other$basicSecures)) {
                    return false;
                }
                Object this$signSecures = getSignSecures();
                Object other$signSecures = other.getSignSecures();
                return this$signSecures == null ? other$signSecures == null : this$signSecures.equals(other$signSecures);
            }
            return false;
        }
        return false;
    }
 
    protected boolean canEqual(final Object other) {
        return other instanceof SecureRegistry;
    }
 
    public int hashCode() {
        int result = (1 * 59) + (isEnabled() ? 79 : 97);
        int result2 = (((((((result * 59) + (isAuthEnabled() ? 79 : 97)) * 59) + (isBasicEnabled() ? 79 : 97)) * 59) + (isSignEnabled() ? 79 : 97)) * 59) + (isClientEnabled() ? 79 : 97);
        Object $defaultExcludePatterns = getDefaultExcludePatterns();
        int result3 = (result2 * 59) + ($defaultExcludePatterns == null ? 43 : $defaultExcludePatterns.hashCode());
        Object $excludePatterns = getExcludePatterns();
        int result4 = (result3 * 59) + ($excludePatterns == null ? 43 : $excludePatterns.hashCode());
        Object $authSecures = getAuthSecures();
        int result5 = (result4 * 59) + ($authSecures == null ? 43 : $authSecures.hashCode());
        Object $basicSecures = getBasicSecures();
        int result6 = (result5 * 59) + ($basicSecures == null ? 43 : $basicSecures.hashCode());
        Object $signSecures = getSignSecures();
        return (result6 * 59) + ($signSecures == null ? 43 : $signSecures.hashCode());
    }
 
    public String toString() {
        return "SecureRegistry(enabled=" + isEnabled() + ", authEnabled=" + isAuthEnabled() + ", basicEnabled=" + isBasicEnabled() + ", signEnabled=" + isSignEnabled() + ", clientEnabled=" + isClientEnabled() + ", defaultExcludePatterns=" + getDefaultExcludePatterns() + ", excludePatterns=" + getExcludePatterns() + ", authSecures=" + getAuthSecures() + ", basicSecures=" + getBasicSecures() + ", signSecures=" + getSignSecures() + ")";
    }
 
    public boolean isEnabled() {
        return this.enabled;
    }
 
    public boolean isAuthEnabled() {
        return this.authEnabled;
    }
 
    public boolean isBasicEnabled() {
        return this.basicEnabled;
    }
 
    public boolean isSignEnabled() {
        return this.signEnabled;
    }
 
    public boolean isClientEnabled() {
        return this.clientEnabled;
    }
 
    public List<String> getDefaultExcludePatterns() {
        return this.defaultExcludePatterns;
    }
 
    public List<String> getExcludePatterns() {
        return this.excludePatterns;
    }
 
    public SecureRegistry() {
        this.defaultExcludePatterns.add("/actuator/health/**");
        this.defaultExcludePatterns.add("/v2/api-docs/**");
        this.defaultExcludePatterns.add("/auth/**");
        this.defaultExcludePatterns.add("/token/**");
        this.defaultExcludePatterns.add("/log/**");
        this.defaultExcludePatterns.add("/menu/routes");
        this.defaultExcludePatterns.add("/menu/auth-routes");
        this.defaultExcludePatterns.add("/menu/top-menu");
        this.defaultExcludePatterns.add("/process/resource-view");
        this.defaultExcludePatterns.add("/process/diagram-view");
        this.defaultExcludePatterns.add("/manager/check-upload");
        this.defaultExcludePatterns.add("/error/**");
        this.defaultExcludePatterns.add("/assets/**");
    }
 
    public SecureRegistry excludePathPattern(String pattern) {
        this.excludePatterns.add(pattern);
        return this;
    }
 
    public SecureRegistry excludePathPatterns(String... patterns) {
        this.excludePatterns.addAll(Arrays.asList(patterns));
        return this;
    }
 
    public SecureRegistry excludePathPatterns(List<String> patterns) {
        this.excludePatterns.addAll(patterns);
        return this;
    }
 
    public SecureRegistry addAuthPattern(HttpMethod method, String pattern, String expression) {
        this.authSecures.add(new AuthSecure(method, pattern, expression));
        return this;
    }
 
    public SecureRegistry addAuthPatterns(List<AuthSecure> authSecures) {
        this.authSecures.addAll(authSecures);
        return this;
    }
 
    public List<AuthSecure> getAuthSecures() {
        return this.authSecures;
    }
 
    public SecureRegistry addBasicPattern(HttpMethod method, String pattern, String username, String password) {
        this.basicSecures.add(new BasicSecure(method, pattern, username, password));
        return this;
    }
 
    public SecureRegistry addBasicPatterns(List<BasicSecure> basicSecures) {
        this.basicSecures.addAll(basicSecures);
        return this;
    }
 
    public List<BasicSecure> getBasicSecures() {
        return this.basicSecures;
    }
 
    public SecureRegistry addSignPattern(HttpMethod method, String pattern, String crypto) {
        this.signSecures.add(new SignSecure(method, pattern, crypto));
        return this;
    }
 
    public SecureRegistry addSignPatterns(List<SignSecure> signSecures) {
        this.signSecures.addAll(signSecures);
        return this;
    }
 
    public List<SignSecure> getSignSecures() {
        return this.signSecures;
    }
}