| | |
| | | import org.apache.commons.lang.StringUtils; |
| | | |
| | | import java.awt.*; |
| | | import java.math.BigInteger; |
| | | import java.security.MessageDigest; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | |
| | | headerMap.put("Tenant-Id",ConfigUtils.getConfigValue("410.code.token.tenantId","000000")); |
| | | headerMap.put("Authorization",ConfigUtils.getConfigValue("410.code.token.authorization","Basic c3dvcmQ6c3dvcmRfc2VjcmV0")); |
| | | headerMap.put("Content-Type",ConfigUtils.getConfigValue("410.code.token.contentType","application/x-www-form-urlencoded")); |
| | | |
| | | UserObject userObject=new UserObject(); |
| | | String userName=ConfigUtils.getConfigValue("410.code.token.username","pdmUser"); |
| | | String password=ConfigUtils.getConfigValue("410.code.token.password","21232f297a57a5a743894a0e4a801fc3"); |
| | | Map<String,String> parmarMap=new HashMap<>(); |
| | | //userObject.set("Tenant-Id",ConfigUtils.getConfigValue("410.code.token.tenantId","000000")); |
| | | /*userObject.setUsername("admin"); |
| | |
| | | userObject.setGrant_type("password"); |
| | | userObject.setScope("all"); |
| | | Object object = JSONObject.toJSON(userObject);*/ |
| | | parmarMap.put("username","admin"); |
| | | parmarMap.put("password","21232f297a57a5a743894a0e4a801fc3"); |
| | | parmarMap.put("username",userName); |
| | | //password=MD5PassWord(password); |
| | | parmarMap.put("password",password); |
| | | parmarMap.put("scope","all"); |
| | | parmarMap.put("grant_type","password"); |
| | | String result=HttpUtil.sendFormPost(tokenUrl,parmarMap,headerMap); |
| | |
| | | throw new Exception("验证用户鉴权信息失败!"); |
| | | } |
| | | } |
| | | private String MD5PassWord (String passWord){ |
| | | try { |
| | | MessageDigest md = MessageDigest.getInstance("MD5"); |
| | | byte[] a=md.digest(passWord.getBytes()); |
| | | String codestr = new BigInteger(1,a ).toString(16); |
| | | System.out.println(codestr); |
| | | return codestr; |
| | | } catch (NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return passWord; |
| | | } |
| | | |
| | | public void buildDialog() { |
| | | Dimension dime = Toolkit.getDefaultToolkit().getScreenSize(); |