source: josm/trunk/src/oauth/signpost/signature/OAuthMessageSigner.java@ 16334

Last change on this file since 16334 was 10746, checked in by Don-vip, 8 years ago

see #11390, see #11924 - replace javax.xml.bind.DatatypeConverter (not visible by default in Java 9) by java.util.Base64 (new in Java 8)

File size: 1.9 KB
Line 
1/* Copyright (c) 2009 Matthias Kaeppler
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15package oauth.signpost.signature;
16
17import java.io.IOException;
18import java.io.Serializable;
19import java.util.Base64;
20
21import oauth.signpost.exception.OAuthMessageSignerException;
22import oauth.signpost.http.HttpRequest;
23import oauth.signpost.http.HttpParameters;
24
25public abstract class OAuthMessageSigner implements Serializable {
26
27 private static final long serialVersionUID = 4445779788786131202L;
28
29 private String consumerSecret;
30
31 private String tokenSecret;
32
33
34 public abstract String sign(HttpRequest request, HttpParameters requestParameters)
35 throws OAuthMessageSignerException;
36
37 public abstract String getSignatureMethod();
38
39 public String getConsumerSecret() {
40 return consumerSecret;
41 }
42
43 public String getTokenSecret() {
44 return tokenSecret;
45 }
46
47 public void setConsumerSecret(String consumerSecret) {
48 this.consumerSecret = consumerSecret;
49 }
50
51 public void setTokenSecret(String tokenSecret) {
52 this.tokenSecret = tokenSecret;
53 }
54
55 protected byte[] decodeBase64(String s) {
56 return Base64.getDecoder().decode(s);
57 }
58
59 protected String base64Encode(byte[] b) {
60 return Base64.getEncoder().encodeToString(b);
61 }
62
63 private void readObject(java.io.ObjectInputStream stream)
64 throws IOException, ClassNotFoundException {
65 stream.defaultReadObject();
66 }
67}
Note: See TracBrowser for help on using the repository browser.