You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.8 KiB
100 lines
3.8 KiB
package com.fr.plugin.http.handler; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
import com.banboocloud.Codec.BamboocloudFacade; |
|
import com.fanruan.api.log.LogKit; |
|
import com.fr.decision.authority.AuthorityContext; |
|
import com.fr.decision.authority.controller.UserController; |
|
import com.fr.decision.authority.data.User; |
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.plugin.SYNCConfig; |
|
import com.fr.plugin.http.AttributeEntity; |
|
import com.fr.plugin.utils.BamboocloudUtils; |
|
import com.fr.stable.query.QueryFactory; |
|
import com.fr.stable.query.restriction.RestrictionFactory; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import com.fr.web.utils.WebUtils; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.io.PrintWriter; |
|
import java.util.ArrayList; |
|
import java.util.HashMap; |
|
import java.util.List; |
|
import java.util.Map; |
|
|
|
public class ALLSchemaServiceHandler extends BaseHttpHandler { |
|
@Override |
|
public RequestMethod getMethod() { |
|
return null; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/schemaService"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return true; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest req, HttpServletResponse res) throws Exception { |
|
String bodyparam = BamboocloudUtils.getRequestBody(req); |
|
SYNCConfig syncConfig = SYNCConfig.getInstance(); |
|
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); |
|
bodyparam = BamboocloudUtils.getPlaintext(bodyparam, syncConfig.getSyncSecret(), "AES"); |
|
LogKit.info("json--param-->" + bodyparam); |
|
Map<String,Object> reqmap = (Map<String,Object>) JSON.parse(bodyparam); |
|
|
|
// if (BamboocloudUtils.verify(reqmap, "MD5").booleanValue()) { |
|
String username = (String) reqmap.get("bimRemoteUser"); |
|
String password = (String) reqmap.get("bimRemotePwd"); |
|
|
|
BamboocloudUtils.checkUsernamePassword(username, password); |
|
|
|
Map<String, Object> schema = new HashMap<String, Object>(); |
|
List<AttributeEntity> accountAttrList = new ArrayList<AttributeEntity>(); |
|
|
|
AttributeEntity attr1 = new AttributeEntity(); |
|
attr1.setType("String"); |
|
attr1.setName("loginName"); |
|
attr1.setRequired(true); |
|
attr1.setMultivalued(false); |
|
accountAttrList.add(attr1); |
|
|
|
AttributeEntity attr3 = new AttributeEntity(); |
|
attr3.setType("String"); |
|
attr3.setName("fullName"); |
|
attr3.setRequired(true); |
|
attr3.setMultivalued(false); |
|
accountAttrList.add(attr3); |
|
|
|
AttributeEntity attr5 = new AttributeEntity(); |
|
attr5.setType("String"); |
|
attr5.setName("password"); |
|
attr5.setRequired(true); |
|
attr5.setMultivalued(false); |
|
accountAttrList.add(attr5); |
|
|
|
schema.put("account", accountAttrList); |
|
schema.put("bimRequestId", reqmap.get("bimRequestId")); |
|
String mapJson = JSON.toJSONString(schema); |
|
LogKit.info("response---json-->" + mapJson); |
|
mapJson = BamboocloudFacade.encrypt(mapJson, syncConfig.getSyncSecret(), "AES"); |
|
WebUtils.printAsString(res, mapJson); |
|
return; |
|
// } |
|
// WebUtils.printAsString(res, BamboocloudFacade.encrypt(JSON.toJSONString(createJson((String) reqmap.get("bimRequestId"), "500", "接口验证失败")), syncConfig.getSyncSecret(), "AES")); |
|
} |
|
|
|
private Map createJson(String bimRequestId, String code, String msg) { |
|
Map<String, Object> schema = new HashMap<String, Object>(); |
|
schema.put("bimRequestId", bimRequestId); |
|
schema.put("resultCode", code); |
|
schema.put("message", msg); |
|
return schema; |
|
} |
|
|
|
}
|
|
|