1 /*
2 * Copyright (c) 2023. Roland T. Lichti, Kaiserpfalz EDV-Service.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18 package de.kaiserpfalzedv.commons.api.libravatar;
19
20 import java.io.Serializable;
21
22 import org.springframework.boot.context.properties.ConfigurationProperties;
23
24 import lombok.Builder;
25 import lombok.Data;
26 import lombok.RequiredArgsConstructor;
27 import lombok.experimental.Accessors;
28 import lombok.experimental.SuperBuilder;
29
30 /**
31 * <p>AvatarOptions -- The configuration for libravatar.</p>
32 *
33 * @author rlichti {@literal <rlichti@kaiserpfalz-edv.de>}
34 * @since 3.0.0 2023-01-19
35 */
36 @ConfigurationProperties("libravatar")
37 @SuperBuilder(toBuilder = true)
38 @RequiredArgsConstructor
39 @Data
40 @Accessors(fluent = true, chain = true)
41 public class AvatarOptions implements Serializable {
42 private static final long serialVersionUID = 0L;
43
44 /**
45 * Specifies a custom base URI for HTTP use. The default is to use the
46 * official libravatar HTTP server. If you *really* wanted to use a non-free
47 * server, you could set this to "http://gravatar.com/avatar/", but why
48 * would you do such a thing?
49 */
50 @Builder.Default
51 private String baseUri = "http://cdn.libravatar.org/avatar/";
52
53 /**
54 * Specifies a custom base URI for HTTPS use. The default is to use the
55 * official libravatar HTTPS server.
56 */
57 @Builder.Default
58 private String secureBaseUri = "https://seccdn.libravatar.org/avatar/";
59
60 /**
61 * Produce https:// URIs where possible. This avoids mixed-content warnings
62 * in browsers when using libravatar-sharp from within a page served via
63 * HTTPS.
64 **/
65 @Builder.Default
66 private boolean useHttps = true;
67
68 /**
69 * Use the SHA256 hash algorithm, rather than MD5. SHA256 is significantly
70 * stronger, but is not supported by Gravatar, so libravatar's fallback to
71 * Gravatar for missing images will not work. Note that using
72 * Avatar.FromOpenID implicitly uses SHA256.
73 */
74 @Builder.Default
75 private boolean useSHA256 = false;
76
77 /**
78 * URI for a default image, if no image is found for the user. This also
79 * accepts any of the "special" values in AvatarDefaultImages
80 */
81 @Builder.Default
82 private LibravatarDefaultImage defaultImage = LibravatarDefaultImage.IDENTICON;
83
84 /**
85 * Size of the image requested. Valid values are between 1 and 512 pixels.
86 * The default size is 80 pixels.
87 */
88 @Builder.Default
89 private Integer imageSize = 80;
90 }