[4231] | 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 | */
|
---|
| 15 | package oauth.signpost.signature;
|
---|
| 16 |
|
---|
| 17 | import java.io.IOException;
|
---|
| 18 | import java.io.Serializable;
|
---|
[10746] | 19 | import java.util.Base64;
|
---|
[4231] | 20 |
|
---|
| 21 | import oauth.signpost.exception.OAuthMessageSignerException;
|
---|
| 22 | import oauth.signpost.http.HttpRequest;
|
---|
| 23 | import oauth.signpost.http.HttpParameters;
|
---|
| 24 |
|
---|
| 25 | public 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) {
|
---|
[10746] | 56 | return Base64.getDecoder().decode(s);
|
---|
[4231] | 57 | }
|
---|
| 58 |
|
---|
| 59 | protected String base64Encode(byte[] b) {
|
---|
[10746] | 60 | return Base64.getEncoder().encodeToString(b);
|
---|
[4231] | 61 | }
|
---|
| 62 |
|
---|
| 63 | private void readObject(java.io.ObjectInputStream stream)
|
---|
| 64 | throws IOException, ClassNotFoundException {
|
---|
| 65 | stream.defaultReadObject();
|
---|
| 66 | }
|
---|
| 67 | }
|
---|