Created
November 8, 2011 18:26
-
-
Save PyYoshi/1348632 to your computer and use it in GitHub Desktop.
BasicAuthのサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class BasicAuth{ | |
| private String auth_type = "BASIC"; | |
| private String login_uri = "http://www.tumblr.com/api/authenticate"; | |
| private String username; | |
| private String passwd; | |
| BasicAuth(String email, String password){ | |
| this.username = email; | |
| this.passwd = password; | |
| } | |
| /** | |
| * リクエストヘッダにauth用ヘッダを付加して返す | |
| * @param HttpURLConnection request; | |
| * | |
| */ | |
| public final HttpURLConnection sign(HttpURLConnection request){ | |
| // authヘッダの付加 | |
| String basic = this.username + ":" + this.passwd; | |
| basic = new String(basic.getBytes()); | |
| request.setRequestProperty( | |
| "Authorization", | |
| "Basic "+basic | |
| ); | |
| return request; | |
| } | |
| public final void getUserInfo(){ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment