/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: RESTUtils.java,v 1.5 2008/08/19 19:13:03 veiming Exp $
*
*/
/**
* Utility class to call REST APIs on OpenSSO.
*/
public class RESTUtils {
/**
* call the REST service URL and return its reponse.
* @param url the URL to be called
* @postData the data to be posted over the url
* @return the response from called URL
*/
try {
urlConnect.setUseCaches(false);
urlConnect.setDoOutput(true);
//urlConnect.setConnectTimeout(10000);
// post data
// read response
urlConnect.getInputStream()));
}
} catch (FileNotFoundException ex) {
throw ex;
} catch (UnknownHostException ex) {
throw ex;
} catch (ConnectException ex) {
throw ex;
} catch (IOException ex) {
try {
}
} finally {
}
}
} finally {
}
}
}
return response;
}
/**
* Inner public class to encapsulate the reponse from REST API.
*/
public static class RESTResponse {
return content;
}
}
public int getResponseCode() {
return responseCode;
}
this.responseCode = responseCode;
}
buffer = new StringBuffer();
}
} // end of if (...
} // end of toString()
}
}