- Introduction to KooGallery
-
Seller Guide
- Registration
- Joint Operations Certification and Product Access
-
Delivery Methods
- Product Release Description
- Delivery Methods
- Image Release Guide
- Releasing Professional Services
- SaaS Release Guide
- Releasing Consulting Services
- License Release Guide
- Releasing Multi-SKU Product Specifications
- Seller Management
- Product Management
- Service Supervision
- Transaction Management
- Settlement Management
- Bill Management
- Issuing Invoices to Huawei Cloud
-
FAQs
- What Enterprise Certificates Are Needed for the Registration?
- Can I Use the Same Account to Apply for Seller Registration Again After I Exit KooGallery?
- How Do I Become a KooGallery Partner?
- How Long Does It Take to Review the Registration Application?
- How Do I Release Products on KooGallery?
- How Long Does It Take to Review a Product Release Application?
- How Do I Remove a Product from the Catalog?
- When Can I Receive the Payment After a Bill Is Generated?
- When Can I Issue an Invoice for an Order?
- Is the Product Technical Support Provided by Sellers or Huawei Cloud?
- How Long Is the Validity Period of Products on KooGallery?
- How Do I Initiate an Appeal During Service Supervision?
- Can an Individual User Become a Seller on KooGallery?
- What Benefits Can I Obtain After Registering with KooGallery?
- Do I Need to Pay Deposit If I Register with KooGallery?
- How Do I Change the Company Name?
- Why Is No Bill Generated for an Order? What Are the Prerequisites for Bill Run?
- How Do I View the Sharing Ratio of a Product?
- How Do I Release a Trial SaaS Specification?
- Why Can't I Select an Image as an Image Asset?
- Reseller Guide
-
User Guide
- Support You May Need
- Huawei Cloud KooGallery Terms
- Product Purchase
- Product Use
- Service Supervision
- After-Sales Support
- Renewal Management
- Product Unsubscription
- Invoice Management
- Agencies
-
FAQs
- What Is Huawei Cloud KooGallery?
- What Software and Services Are Provided on KooGallery?
- How Do I Purchase Cloud Applications on KooGallery?
- Why Can't I Use the Pay-per-Use or Yearly/Monthly Billing Mode for Certain Products?
- How Do I View Purchased Applications?
- How Do I Request Invoices After Purchasing Products from KooGallery?
- What Do I Do If I Encounter a Problem When Using a Product?
- How Do I Renew Purchased Applications?
- What Do I Do If No Applications or Services Meet My Requirements?
- How Do I Contact a Seller?
- What Do I Do If I Cannot Contact a Seller?
- Does Huawei Cloud Support Login Through Third-Party Website?
- Common Problems About Yearly/Monthly Images
- Common Problems About Pay-per-Use Images
- How Do I Initiate an Appeal During Service Supervision?
-
Access Guide
- SaaS Access Guide V2.0 (New Products)
- SaaS Access Guide V1.0 (Existing Products)
- Automatic Deployment and Access Guide
- General Reference
Show all
Copied.
ISV Server Verifying Requests
The following figure shows the overall process of code invocation for request verification.
/** * Verify the validity of requests. * @param request --HTTP requests * @param accessKey --Access key * @param encryptLength --Length of the encrypted content * @return --Verification result */ public static boolean verificateRequestParams(javax.servlet.http.HttpServletRequest request, String accessKey,int encryptLength) { // Resolve the URL. Map<String, String[]> paramsMap = request.getParameterMap(); String timeStamp = null; String authToken = null; String[] timeStampArray = paramsMap.get("timeStamp"); if (null != timeStampArray && timeStampArray.length > 0) { timeStamp = timeStampArray[0]; } String[] authTokenArray = paramsMap.remove("authToken"); if (null != authTokenArray && authTokenArray.length > 0) { authToken = authTokenArray[0]; } // Sort the remaining parameters and combine them to form the encrypted content. Map<String, String[]> sortedMap = new TreeMap<String, String[]>(); sortedMap.putAll(paramsMap); StringBuffer strBuffer = new StringBuffer(); Set<String> keySet = sortedMap.keySet(); Iterator<String> iter = keySet.iterator(); while (iter.hasNext()) { String key = iter.next(); String value = sortedMap.get(key)[0]; strBuffer.append("&").append(key).append("=").append(value); } // Rectify the message body by removing the ampersand (&) before the first parameter. String reqParams = strBuffer.toString().substring(1); String key = accessKey + timeStamp; String signature = null; try { signature = generateResponseBodySignature(key, reqParams); } catch (InvalidKeyException | NoSuchAlgorithmException | IllegalStateException | UnsupportedEncodingException e) { // TODO Auto-generated catch block } return authToken.equals(signature); } |
/** * Generate an example signature demo of an HTTP response body. * @param key --Access key obtained on the Seller Console. Log in to the Seller Console to view the access key. * @param body --HTTP response message body * @return --Encryption result * @throws InvalidKeyException * @throws NoSuchAlgorithmException * @throws IllegalStateException * @throws UnsupportedEncodingException */ public static String generateResponseBodySignature(String key, String body) throws InvalidKeyException, NoSuchAlgorithmException, IllegalStateException, UnsupportedEncodingException { return base_64(hmacSHA256(key, body)); } |
/** * * HAMC-SHA256 encryption algorithm * @param macKey --Key * @param macData --Encryption content, that is, the response message body * @return --Ciphertext * @throws NoSuchAlgorithmException * @throws InvalidKeyException * @throws IllegalStateException * @throws UnsupportedEncodingException */ public static byte[] hmacSHA256(String macKey, String macData) throws NoSuchAlgorithmException, InvalidKeyException, IllegalStateException, UnsupportedEncodingException { SecretKeySpec secret = new SecretKeySpec(macKey.getBytes(), "HmacSHA256"); Mac mac = Mac.getInstance("HmacSHA256"); mac.init(secret); byte[] doFinal = mac.doFinal(macData.getBytes("UTF-8")); return doFinal; } |
/** * * Convert the byte array into a string. * @param bytes --Byte array * @return --String */ public static String base_64(byte[] bytes) { return new String(Base64.encodeBase64(bytes)); } |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot