IDEA社区版+springboot创建项目(图解流程0
Spring Boot 返回 JSON 数据及数据封装
Springboot启动后外部无法通过IP+端口方式访问,只能本地访问localhost
Springboot中使用Xstream进行XML与Bean 相互转换
ava开发之调用shell命令并获取执行结果(Mac)
Java ArrayList、string、string[]之间的转换
Springboot后台设置允许跨域的方法
org.springframework.web.HttpMediaTypeNotSupported...
user-agent对应的型号
获取JavaUDID上传
@RequestMapping(value = "/uploadUDID",method = {RequestMethod.GET,RequestMethod.POST})
public void uploadUDID(HttpServletRequest request,HttpServletResponse response){
try {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
//获取HTTP请求的输入流
InputStream is = request.getInputStream();
//已HTTP请求输入流建立一个BufferedReader对象
BufferedReader br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
StringBuilder sb = new StringBuilder();
//读取HTTP请求内容
String buffer = null;
while ((buffer = br.readLine()) != null) {
sb.append(buffer);
}
String content = sb.toString().substring(sb.toString().indexOf("<?xml"), sb.toString().indexOf("</plist>")+8);
//content就是接收到的xml字符串
content = content.replaceAll("\t","");
int from = content.indexOf("<dict>")+"<dict>".length();
content = content.substring(from);
int to = content.indexOf("</dict>");
content = content.substring(0,to);
content = content.replaceAll("<key>","");
content = content.replaceAll("</key>","=");
content = content.replaceAll("<string>","");
content = content.replaceAll("</string>","#*#");
HashMap<String,String> plistMap = new HashMap<String,String>();
String[] list = content.split("#*#");
for (String var : list){
String[] keyVals = var.split("=");
if(keyVals.length == 2){
plistMap.put(keyVals[0],keyVals[1]);
}
}
System.out.println(plistMap);
String udid = plistMap.get("UDID");
response.setStatus(301); //301之后iOS设备会自动打开safari浏览器
response.setHeader("Location", "http://192.168.3.57:8080/mysign/index2.html?UDID="+udid);
//http://192.168.1.106:8080/udid.jsp 是用于显示udid的页面,也可以利用之前的下载mobileprofile文件页面
}catch (Exception e){
}
@RequestMapping(value = "/createUDIDConfig",method = {RequestMethod.GET,RequestMethod.POST})
public String createUDIDCnofig(){
String cmd = "/bin/bash";
String path = "/Users/tony/fastlane_workspace/SuperSign/test.sh";
HashMap<String,String> shParams = new HashMap();
String uuid = UUID.randomUUID().toString().replace("-", "");
shParams.put("--playload_udid",uuid);
shParams.put("--playload_url","http://192.168.3.57:8091/json/uploadUDID");
shParams.put("--playload_name","红苹果绿菠萝");
HashMap resultMap = exec(cmd,path,shParams);
return (String) resultMap.get("msg");
}
public HashMap<String,Object> exec(String cmd,String path,HashMap<String,String> params) {
HashMap<String,Object> resultMap = new HashMap<String,Object>();
ArrayList<String> commandList = new ArrayList<String>();
commandList.add(cmd);
commandList.add(path);
for (String key : params.keySet()) {
commandList.add(key+"="+params.get(key));
}
String[] commandArray = (String[])commandList.toArray(new String[commandList.size()]);
int exitValue = 0;
String resultString = "";
try {
Process process = Runtime.getRuntime().exec(commandArray);
exitValue = process.waitFor();
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = input.readLine()) != null) {
resultString = resultString + line + "<br/>";
}
input.close();
process.destroy();
}catch (Exception e){
e.printStackTrace();
}
resultMap.put("code",exitValue);
resultMap.put("msg",resultString);
return resultMap;
}
@RequestMapping(value = "/createProvisioning",method = {RequestMethod.GET,RequestMethod.POST})
public String createProvisioning(){
String cmd = "/bin/bash";
String path = "/Users/tony/fastlane_workspace/SuperSign/create_provision.sh";
HashMap<String,String> shParams = new HashMap();
String bundleId = "com.ak.rf.hoc.hello";
String device_udid = "942d4763983c8219082fd8218e5a4f53265495f8";
String provision_path = "abchhhh123.mobileprovision";
shParams.put("--bundleId",bundleId);
shParams.put("--device_udid",device_udid);
shParams.put("--provision_path",provision_path);
HashMap resultMap = exec(cmd,path,shParams);
return (String) resultMap.get("msg");
}
private String getIpAdrress(HttpServletRequest request) {
String agent = request.getHeader("user-agent");
System.out.println("user-agent: "+agent);
String Xip = request.getHeader("X-Real-IP");
String XFor = request.getHeader("X-Forwarded-For");
if(XFor != null && !XFor.isEmpty() && !"unKnown".equalsIgnoreCase(XFor)){
//多次反向代理后会有多个ip值,第一个ip才是真实ip
int index = XFor.indexOf(",");
if(index != -1){
return XFor.substring(0,index);
}else{
return XFor;
}
}
XFor = Xip;
if(XFor != null && !XFor.isEmpty() && !"unKnown".equalsIgnoreCase(XFor)){
return XFor;
}
if (XFor == null || XFor.isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("Proxy-Client-IP");
}
if (XFor == null || XFor.isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("WL-Proxy-Client-IP");
}
if (XFor == null || XFor.isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("HTTP_CLIENT_IP");
}
if (XFor == null || XFor.isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (XFor == null || XFor.isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getRemoteAddr();
}
return XFor;
}
}
{
SERIAL=FK3VQJ6JJCL6,
CHALLENGE=4C1B718D-A51D-7430-2AE1-F02C9868CCB3_1566645538_49e7e7ebe0a1e399095960365c8a5d6d, PRODUCT=iPhone10,3,
VERSION=16G77,
UDID=942d4763983c8219082fd8218e5a4f53265495f8
}
#! /bin./bash
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
#脚本所在的文件夹
__filePath=$(dirname "$0")
__filePath2=`pwd`
__srcPath=$__filePath
__absolutePath="/Users/tony/fastlane_workspace/SuperSign"
source "$__srcPath/parseParams.sh"
bundleId=`parseParams $@ "--bundleId"`
device_udid=`parseParams $@ "--device_udid"`
provision_path=`parseParams $@ "--provision_path"`
provision_path=`echo "/Users/tony/fastlane_workspace/SuperSign/$provision_path"`
echo "========================<br/>"
echo "bundleId: $bundleId<br/>"
echo "device_udid: $device_udid<br/>"
echo "provision_path: $provision_path<br/>"
echo "=========通过UDID生成证书===============<br/>"
cd /Users/tony/fastlane_workspace/SuperSign
fastlane custom_spaceship \
bundleId:$bundleId \
device_udid:$device_udid \
provision_path:$provision_path
echo "============重签名==============="
ipa_path="/Users/tony/fastlane_workspace/SuperSign/5d638d7045434.ipa"
sign_identity="iPhone Distribution: Nevin Mia (H4ZBQUPR3Q)"
output_path="$__absolutePath/hello.ipa"
# fastlane sigh resign $ipa_path \
# --signing_identity "iPhone Distribution: Nevin Mia (H4ZBQUPR3Q)" \
# -p $provision_path
#-c "iPhone Distribution: Nevin Mia (H4ZBQUPR3Q)" \
./CoolResign \
-i $ipa_path \
-p $provision_path \
-c "$sign_identity" \
-o $output_path \
-b "com.ak.jd"
echo "============生成下载描述文件==============="
download_path="$__absolutePath/download.plist"
cat > "$download_path" << END_TEXT
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>
https://d-hk.ggonet.cn/ipasigned/5d638d7045434.ipa?s=c0aaddc450f110f7d1c41713348ae398
</string>
</dict>
<dict>
<key>kind</key>
<string>display-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>https://static.app2.cn/icon/5d63a67a1f8d6.png</string>
</dict>
<dict>
<key>kind</key>
<string>full-size-image</string>
<key>needs-shine</key>
<true/>
<key>url</key>
<string>https://static.app2.cn/icon/5d63a67a1f8d6.png</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>$bundle_id</string>
<key>bundle-version</key>
<string>1.0.52</string>
<key>kind</key>
<string>software</string>
<key>subtitle</key>
<string/>
<key>title</key>
<string>ak彩票本地</string>
</dict>
</dict>
</array>
</dict>
</plist>
END_TEXT
echo "====生成下载文件成功======"
cat $download_path
JS跨域保存获取数据
-
js iframe跨域访问
A网站的html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="renderer" content="ie-comp">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="email=no">
</head>
<body>
<a href="javascript:askB();">ask</a>
<iframe id="ifr" src="http://192.168.3.57:8080/web2/b.html" style="display:none;" ></iframe>
<script type="text/javascript">
window.addEventListener('message', function(e){
// console.log('A get message from B ');
// console.log(e.data);
let serialId = e.data.serialId;
if(window.temp_response_localstorage_iframe_all_functions && window.temp_response_localstorage_iframe_all_functions[serialId]){
let func = window.temp_response_localstorage_iframe_all_functions[serialId];
window.temp_response_localstorage_iframe_all_functions[serialId] = undefined;
func(e.data);
}
// console.log(e.data);
}, false);
function sendFramMessage(data,callback){
let serialId="sendFramMessage"+Date.now()+"-"+Math.random().toString(36).slice(-8);
let form = {"serialId": serialId};
// console.log('before', form);
Object.assign(form, data);
// console.log("after",form);
if (callback){
if (!window.temp_response_localstorage_iframe_all_functions){
window.temp_response_localstorage_iframe_all_functions = {};
}
window.temp_response_localstorage_iframe_all_functions[serialId] = callback;
}
var ifr = document.querySelector('#ifr');
ifr.contentWindow.postMessage(form, '*');
}
</script>
<script type="text/javascript">
window.onload = function(){
askB();
}
function askB(){
//sendFramMessage();
sendFramMessage({"method":"get","name":"deviceId"},function(data){
console.log(">>>>>>>>");
console.log(data);
if(data.deviceId && "undefined" != data.deviceId){
console.log("+++++拿到了deviceId+++++");
console.log(data.deviceId);
}else{
console.log("--------没有deviceId-------")
sendFramMessage({"method":"save","name":"deviceId","val":"324750389qwer"},function(){
askB();
});
}
});
}
</script>
</body>
</html>
用于临时通信保存跨域访问的B网站的b.html
<!DOCTYPE html>
<html>
<script type="text/javascript">
window.addEventListener('message', function(e){
// console.log('B get message from A ' );
// console.log(e.data)
let form = {"serialId": e.data.serialId,"method":e.data.method};
if(e.data.method == "get"){
var saveVal = window.localStorage[e.data.name];
// console.log("B send message begin");
let responseData = {};
if(saveVal && undefined != saveVal && "undefined" != saveVal){
responseData[e.data.name] = saveVal;
}
Object.assign(form, responseData);
e.source.postMessage(form, '*');
}else if (e.data.method == "save") {
window.localStorage[e.data.name]=e.data.val;
let responseData = {};
// console.log("B send message begin");
Object.assign(form, responseData);
e.source.postMessage(form, '*');
}else{
// console.log("B send message begin");
let responseData = {"deviceId":deviceId};
Object.assign(form, responseData);
e.source.postMessage(form, '*');
}
}, false);
</script>
</html>
网友评论