diff --git a/.gitignore b/.gitignore index d9c4d48c..0c17bc84 100755 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,4 @@ target *.iml *.yml log -components -data +data/elasticsearch diff --git a/data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/component.js b/data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/component.js new file mode 100644 index 00000000..986f1aeb --- /dev/null +++ b/data/components/eabb131d-8fd1-43a8-88d9-a198abfd3d42/component.js @@ -0,0 +1,191 @@ +!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((u=d(d(t,n),d(e,u)))<>>32-o,r)}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function c(n,t){var r,e,o,u;n[t>>5]|=128<>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h>5]>>>e%32&255);return t}function a(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e>5]|=(255&n.charCodeAt(e/8))<>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return i(c(a(n=r(n)),8*n.length))}function u(n,t){return function(n,t){var r,e=a(n),o=[],u=[];for(o[15]=u[15]=void 0,1610000){ + mid=1; + } + return mid+""; +} + +this.decode = function (msg) { + //对msg进行解析,并返回物模型数据 + var content=msg.content; + var topic = content.topic; + var payload = content.payload; + var identifier = topic.substring(topic.lastIndexOf("/") + 1); + + //透传上报 + if(topic.endsWith("/event/rawReport")){ + var rst= component.transparentDecode(payload.params); + if(!rst){ + return null; + } + rst.occur=new Date().getTime(); + rst.time=new Date().getTime(); + return rst; + } + + if (topic.endsWith("/property/post")) { + //属性上报 + return { + mid: msg.mid, + productKey: msg.productKey, + deviceName: msg.deviceName, + type:"property", + identifier: "report", //属性上报 + occur: new Date().getTime(), //时间戳,设备上的事件或数据产生的本地时间 + time: new Date().getTime(), //时间戳,消息上报时间 + data: payload.params, + }; + } else if (topic.indexOf("/event/") > 0) { + //事件上报 + return { + mid: msg.mid, + productKey: msg.productKey, + deviceName: msg.deviceName, + type:"event", + identifier: identifier, + occur: new Date().getTime(), + time: new Date().getTime(), + data: payload.params, + }; + }else if(topic.endsWith("/service/property/set_reply")){ + //属性设置回复 + return { + mid: msg.mid, + productKey: msg.productKey, + deviceName: msg.deviceName, + type:"property", + identifier: identifier, + occur: new Date().getTime(), + time: new Date().getTime(), + code: payload.code + }; + } else if (topic.endsWith("_reply")) { + //服务回复 + return { + mid: msg.mid, + productKey: msg.productKey, + deviceName: msg.deviceName, + type:"service", + identifier: identifier, + occur: new Date().getTime(), + time: new Date().getTime(), + code: payload.code, + data: payload.data, + }; + } + return null; +}; + +this.encode = function (service,device) { + var deviceMid=getMid(); + var method="thing.service."; + var topic="/sys/"+service.productKey+"/"+service.deviceName+"/c/service/"; + var params={}; + + //透传下发 + if(device.transparent){ + var rst=component.transparentEncode(service,device); + topic="/sys/"+rst.productKey+"/"+rst.deviceName+"/c/service/rawSend"; + params.model=rst.content.model; + params.mac=rst.content.mac; + params.data=rst.content.data; + + return { + productKey:rst.productKey, + deviceName:rst.deviceName, + mid:rst.mid, + content:{ + topic:topic, + payload:JSON.stringify({ + id:rst.mid, + method:method+"rawSend", + params:params + }) + } + } + + } + + var type=service.type; + var identifier=service.identifier; + + if(type=="property"){ + method+="property."+identifier; + topic+="property/"+identifier; + }else if(type=="service"){ + method+=identifier; + topic+=identifier; + } + for(var p in service.params){ + params[p]=service.params[p]; + } + + return { + productKey:service.productKey, + deviceName:service.deviceName, + mid:deviceMid, + content:{ + topic:topic, + payload:JSON.stringify({ + id:deviceMid, + method:method, + params:params + }) + } + } +}; \ No newline at end of file diff --git a/oauth2-server/src/test/java/GenPwdSecret.java b/oauth2-server/src/test/java/GenPwdSecret.java index 9fe866d5..c18b9404 100644 --- a/oauth2-server/src/test/java/GenPwdSecret.java +++ b/oauth2-server/src/test/java/GenPwdSecret.java @@ -6,7 +6,7 @@ public class GenPwdSecret { @Test public void gen() throws Exception { //生成密码加密内容 - String secret = AuthUtil.enCryptPwd("guest123"); + String secret = AuthUtil.enCryptPwd("iotkitadmin"); System.out.println(secret); System.out.println(AuthUtil.checkPwd("guest123", secret)); }