1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.gbif.ws.security;
15
16 import javax.annotation.Nullable;
17
18 public class RequestDataToSign {
19
20
21 private String method;
22
23
24 private String url;
25
26
27 @Nullable private String contentType;
28
29
30 @Nullable private String contentTypeMd5;
31
32
33 private String user;
34
35 public String getMethod() {
36 return method;
37 }
38
39 public void setMethod(String method) {
40 this.method = method;
41 }
42
43 public String getUrl() {
44 return url;
45 }
46
47 public void setUrl(String url) {
48 this.url = url;
49 }
50
51 public String getContentType() {
52 return contentType;
53 }
54
55 public void setContentType(String contentType) {
56 this.contentType = contentType;
57 }
58
59 public String getContentTypeMd5() {
60 return contentTypeMd5;
61 }
62
63 public void setContentTypeMd5(String contentTypeMd5) {
64 this.contentTypeMd5 = contentTypeMd5;
65 }
66
67 public String getUser() {
68 return user;
69 }
70
71 public void setUser(String user) {
72 this.user = user;
73 }
74
75
76
77
78
79
80
81
82
83
84
85 public String stringToSign() {
86 StringBuilder sb = new StringBuilder();
87
88 sb.append(method);
89 sb.append('\n');
90 sb.append(url);
91 if (contentType != null) {
92 sb.append('\n');
93 sb.append(contentType.toLowerCase());
94 }
95 if (contentTypeMd5 != null) {
96 sb.append('\n');
97 sb.append(contentTypeMd5);
98 }
99 sb.append('\n');
100 sb.append(user);
101
102 return sb.toString();
103 }
104 }