3.4.1支持IP访问

cas-client和cas server交互,cas server必须要有域名,否则会发生异常。



实际上这个问题发生在cas-client-core模块,包org.jasig.cas.client.util,类CommonUtils.java。


修改如下代码:


public static String getResponseFromServer(final URL constructedUrl, final HttpURLConnectionFactory factory,

final String encoding) {


HttpsURLConnection conn = null;

InputStreamReader in = null;

try {

HostnameVerifier hv = new HostnameVerifier() {

public boolean verify(String urlHostName, SSLSession session) {

return true;

}

};


HttpsURLConnection.setDefaultHostnameVerifier(hv);


conn = (HttpsURLConnection) constructedUrl.openConnection();


if (CommonUtils.isEmpty(encoding)) {

in = new InputStreamReader(conn.getInputStream());

} else {

in = new InputStreamReader(conn.getInputStream(), encoding);

}


final StringBuilder builder = new StringBuilder(255);

int byteRead;

while ((byteRead = in.read()) != -1) {

builder.append((char) byteRead);

}


return builder.toString();

} catch (final Exception e) {

LOGGER.error(e.getMessage(), e);

throw new RuntimeException(e);

} finally {

closeQuietly(in);

if (conn != null) {

conn.disconnect();

}

}

}


修改后的包从 下载。



内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/11243.html