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

Last change on this file since 4231 was 4231, checked in by stoecker, 13 years ago

add signpost and metadata extractor code to repository directly

File size: 2.1 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;
19
20import oauth.signpost.exception.OAuthMessageSignerException;
21import oauth.signpost.http.HttpRequest;
22import oauth.signpost.http.HttpParameters;
23
24import org.apache.commons.codec.binary.Base64;
25
26public abstract class OAuthMessageSigner implements Serializable {
27
28 private static final long serialVersionUID = 4445779788786131202L;
29
30 private transient Base64 base64;
31
32 private String consumerSecret;
33
34 private String tokenSecret;
35
36 public OAuthMessageSigner() {
37 this.base64 = new Base64();
38 }
39
40 public abstract String sign(HttpRequest request, HttpParameters requestParameters)
41 throws OAuthMessageSignerException;
42
43 public abstract String getSignatureMethod();
44
45 public String getConsumerSecret() {
46 return consumerSecret;
47 }
48
49 public String getTokenSecret() {
50 return tokenSecret;
51 }
52
53 public void setConsumerSecret(String consumerSecret) {
54 this.consumerSecret = consumerSecret;
55 }
56
57 public void setTokenSecret(String tokenSecret) {
58 this.tokenSecret = tokenSecret;
59 }
60
61 protected byte[] decodeBase64(String s) {
62 return base64.decode(s.getBytes());
63 }
64
65 protected String base64Encode(byte[] b) {
66 return new String(base64.encode(b));
67 }
68
69 private void readObject(java.io.ObjectInputStream stream)
70 throws IOException, ClassNotFoundException {
71 stream.defaultReadObject();
72 this.base64 = new Base64();
73 }
74}
Note: See TracBrowser for help on using the repository browser.