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.basic;
|
---|
16 |
|
---|
17 | import java.net.HttpURLConnection;
|
---|
18 |
|
---|
19 | import oauth.signpost.AbstractOAuthConsumer;
|
---|
20 | import oauth.signpost.http.HttpRequest;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * The default implementation for an OAuth consumer. Only supports signing
|
---|
24 | * {@link java.net.HttpURLConnection} type requests.
|
---|
25 | *
|
---|
26 | * @author Matthias Kaeppler
|
---|
27 | */
|
---|
28 | public class DefaultOAuthConsumer extends AbstractOAuthConsumer {
|
---|
29 |
|
---|
30 | private static final long serialVersionUID = 1L;
|
---|
31 |
|
---|
32 | public DefaultOAuthConsumer(String consumerKey, String consumerSecret) {
|
---|
33 | super(consumerKey, consumerSecret);
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | protected HttpRequest wrap(Object request) {
|
---|
38 | if (!(request instanceof HttpURLConnection)) {
|
---|
39 | throw new IllegalArgumentException(
|
---|
40 | "The default consumer expects requests of type java.net.HttpURLConnection");
|
---|
41 | }
|
---|
42 | return new HttpURLConnectionRequestAdapter((HttpURLConnection) request);
|
---|
43 | }
|
---|
44 |
|
---|
45 | }
|
---|