1414import org .apache .commons .codec .digest .DigestUtils ;
1515import org .apache .log4j .Logger ;
1616
17+ import util .UnsupportedAuthenticationSchema ;
18+
1719public class HttpRequestManager {
1820
1921 private static final Logger log = Logger
@@ -36,7 +38,7 @@ public static String executePost(String url, String urlParameters)
3638 }
3739
3840 public static String executePost (String url , String urlParameters ,
39- String username , String password ) throws Exception {
41+ String username , String password ) throws IOException {
4042 // TODO: May be try to do Authorized post by default first ??? to avoid
4143 // doing two queries? are all the queries made by the generator will use
4244 // the
@@ -71,8 +73,10 @@ public static String executePost(String url, String urlParameters,
7173 throw new HTTPException (responseCode );
7274 }
7375 } else
74- throw new Exception ("Unsupported authentication type: "
75- + wwwAuthenticateHeader .getAuthenticationScheme ());
76+ throw new UnsupportedAuthenticationSchema (
77+ "Unsupported authentication type: "
78+ + wwwAuthenticateHeader
79+ .getAuthenticationScheme ());
7680 case 400 : // bad request
7781 log .error (connection .getResponseCode () + "\n \t "
7882 + connection .getResponseMessage () + "\n \t url:" + url
@@ -115,7 +119,8 @@ private static HttpURLConnection sendPost(String url, String urlParameters)
115119
116120 private static HttpURLConnection sendAuthorizedPost (String url ,
117121 String urlParameters , WWWAuthenticateHeader wwwAuthenticateHeader ,
118- String username , String password ) throws Exception {
122+ String username , String password ) throws IOException ,
123+ UnsupportedAuthenticationSchema {
119124 log .debug ("Execute authorized POST to " + url );
120125 URL targetURL = new URL (url );
121126 HttpURLConnection connection = (HttpURLConnection ) targetURL
@@ -173,11 +178,13 @@ private static WWWAuthenticateHeader getWWWAuthenticationHeader(
173178
174179 private static String getDigestAuthorizationProperty (String endpoint ,
175180 WWWAuthenticateHeader wwwAuthenticateHeader , String username ,
176- String password , String requestMethod ) throws Exception {
181+ String password , String requestMethod )
182+ throws UnsupportedAuthenticationSchema {
177183 if (!wwwAuthenticateHeader .isDigest ())
178- throw new Exception ("Unexpected authentication scheme "
179- + wwwAuthenticateHeader .getAuthenticationScheme ()
180- + ", Digest expected" );
184+ throw new UnsupportedAuthenticationSchema (
185+ "Unexpected authentication scheme "
186+ + wwwAuthenticateHeader .getAuthenticationScheme ()
187+ + ", Digest expected" );
181188 String nc = "00000001" ;
182189 String cnonce = DigestUtils .md5Hex (Long .toString (System
183190 .currentTimeMillis ()));
0 commit comments