package com.iflytek;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class ssodemo {
public static void main(String[] args) throws Exception {
//cas server 校验地址
String serverValidateUrl="https://demo.tch.com:8443/cas/serviceValidate";
//客户端地址
String service = "http://app1.tch.com:18080/examples/servlets/servlet/HelloWorldExample";
//ticket
String ticket ="ST-7-gCMvfsyy9hmnadayB1e3-cas01.example.org";
//组装url
String constructServiceUrl = serverValidateUrl+"?ticket="+ticket+"&service="+service;
System.out.println("constructServiceUrl:"+constructServiceUrl);
URL url =new URL(constructServiceUrl);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setConnectTimeout(5*1000);
conn.setRequestMethod("GET");
InputStream inStream = conn.getInputStream();
final StringBuilder builder = new StringBuilder(255);
int byteRead;
while ((byteRead = inStream.read()) != -1) {
builder.append((char) byteRead);
}
String response = builder.toString();
System.out.print("response:"+response);
}
}
==========================================================================================
我希望每一篇文章的背后,都能看到自己对于技术、对于生活的态度。
我相信乔布斯说的,只有那些疯狂到认为自己可以改变世界的人才能真正地改变世界。面对压力,我可以挑灯夜战、不眠不休;面对困难,我愿意迎难而上、永不退缩。
其实我想说的是,我只是一个程序员,这就是我现在纯粹人生的全部。
==========================================================================================