“ java.lang.UnsupportedOperationException:尚不支持?!?/h1>
瀏覽:140日期:2024-05-04 08:03:54
如何解決“ java.lang.UnsupportedOperationException:尚不支持?!??您看過這段代碼片段了嗎?
@Override public Result authenticate(HttpExchange he) {throw new UnsupportedOperationException('Not supported yet.'); }
正是這種情況會在您每次嘗試進行身份驗證時引發上述異常。
因此,在我看來,解決身份驗證問題的方法非常簡單:實施此方法。
解決方法 我正在嘗試做的是:
我正在嘗試使用Java連接到[使用https]的Web Portal。我已經編寫了使用Authenticator類提供用戶憑據的代碼。運行程序時出現異常:
“ java.lang.UnsupportedOperationException:尚不支持”
我有張貼的代碼:
public class Main { public class MyAuthenticator extends Authenticator {protected PasswordAuthentication getpasswordAuthentication() { String username = 'username'; String password = 'password'; // Return the information return new PasswordAuthentication(username,password.toCharArray());}@Overridepublic Result authenticate(HttpExchange he) { throw new UnsupportedOperationException('Not supported yet.');} } public static void main(String[] args) {// TODO code application logic hereTrustManager[] trustClients = new TrustManager[]{ new X509TrustManager() {public void checkClientTrusted(X509Certificate[] xcs,String string) throws CertificateException { throw new UnsupportedOperationException('Not supported yet.');}public void checkServerTrusted(X509Certificate[] xcs,String string) throws CertificateException { throw new UnsupportedOperationException('Not supported yet.');}public X509Certificate[] getAcceptedIssuers() { return null; //throw new UnsupportedOperationException('Not supported yet.');} }};try { SSLContext sslcontext = SSLContext.getInstance('SSL'); sslcontext.init(null,trustClients,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext.getSocketFactory());} catch (Exception e) { System.out.println('in 1st catch ' + e);}try { URL url = new URL('https://someURL.server.com/fmk/jsp/ltpaLogin.jsp'); URLConnection urlconnection = url.openConnection(); System.out.println(urlconnection); System.out.print(urlconnection.getInputStream().toString());} catch (Exception e) { System.out.println('in 2ndcatch ' + e.getMessage());} }}
第二次Try中引發了異?!癹ava.lang.UnsupportedOperationException:不支持”。我的方法正確嗎?如果沒有,還有其他選擇嗎?
當我在Web瀏覽器中打開頁面時,我得到登錄頁面;一旦提供了憑據,就會顯示Web門戶
有人可以建議如何訪問Webportal并提供我的憑據并檢查身份驗證是否成功嗎?任何示例代碼片段都將對您有所幫助。
標簽:
java
上一條:Spring WS Web服務。使用SAAJ向響應中添加附件-端點無適配器下一條:RestEasy:org.codehaus.jackson.map.JsonMappingException:無法從START_OBJECT令牌(..)中反序列化java.util.ArrayList
相關文章:
1. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. 配置Apache時,添加對PHP的支持時語法錯誤4. Apache 已經把網站根目錄的改為allow from all了,但是服務器還是不能訪問?5. css - 寫頁面遇到個布局問題,求大佬們幫解答,在線等,急!~6. phpstudy8.1支持win11系統嗎?7. javascript - nodejs關于進程間發送句柄的一點疑問8. 實現bing搜索工具urlAPI提交9. vue.js - Vue 如何像Angular.js watch 一樣監聽數據變化10. javascript - 移動端上不能實現拖拽布局嗎?
您看過這段代碼片段了嗎?
@Override public Result authenticate(HttpExchange he) {throw new UnsupportedOperationException('Not supported yet.'); }
正是這種情況會在您每次嘗試進行身份驗證時引發上述異常。
因此,在我看來,解決身份驗證問題的方法非常簡單:實施此方法。
解決方法我正在嘗試做的是:
我正在嘗試使用Java連接到[使用https]的Web Portal。我已經編寫了使用Authenticator類提供用戶憑據的代碼。運行程序時出現異常:
“ java.lang.UnsupportedOperationException:尚不支持”
我有張貼的代碼:
public class Main { public class MyAuthenticator extends Authenticator {protected PasswordAuthentication getpasswordAuthentication() { String username = 'username'; String password = 'password'; // Return the information return new PasswordAuthentication(username,password.toCharArray());}@Overridepublic Result authenticate(HttpExchange he) { throw new UnsupportedOperationException('Not supported yet.');} } public static void main(String[] args) {// TODO code application logic hereTrustManager[] trustClients = new TrustManager[]{ new X509TrustManager() {public void checkClientTrusted(X509Certificate[] xcs,String string) throws CertificateException { throw new UnsupportedOperationException('Not supported yet.');}public void checkServerTrusted(X509Certificate[] xcs,String string) throws CertificateException { throw new UnsupportedOperationException('Not supported yet.');}public X509Certificate[] getAcceptedIssuers() { return null; //throw new UnsupportedOperationException('Not supported yet.');} }};try { SSLContext sslcontext = SSLContext.getInstance('SSL'); sslcontext.init(null,trustClients,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sslcontext.getSocketFactory());} catch (Exception e) { System.out.println('in 1st catch ' + e);}try { URL url = new URL('https://someURL.server.com/fmk/jsp/ltpaLogin.jsp'); URLConnection urlconnection = url.openConnection(); System.out.println(urlconnection); System.out.print(urlconnection.getInputStream().toString());} catch (Exception e) { System.out.println('in 2ndcatch ' + e.getMessage());} }}
第二次Try中引發了異?!癹ava.lang.UnsupportedOperationException:不支持”。我的方法正確嗎?如果沒有,還有其他選擇嗎?
當我在Web瀏覽器中打開頁面時,我得到登錄頁面;一旦提供了憑據,就會顯示Web門戶
有人可以建議如何訪問Webportal并提供我的憑據并檢查身份驗證是否成功嗎?任何示例代碼片段都將對您有所幫助。

網公網安備