【问题标题】:How to add a graphical image signature using CoSign Signature Soap API如何使用 CoSign Signature Soap API 添加图形图像签名
【发布时间】:2014-10-10 06:06:35
【问题描述】:

如果可能,添加一些代码 sn-p。我使用 Java 进行编码。

DSS:我想使用 CoSign Signature Soap API 添加多个图形图像签名,我该如何实现?如果可能,添加一些代码 sn-p。

【问题讨论】:

    标签: java soap digital-signature cosign-api


    【解决方案1】:

    这是一个 Java 代码示例,演示了如何使用 CoSign Signature SOAP API 添加图形签名:

    public static void AddGraphicalImage(String username, String domain, String password, byte[] imageBuffer, String imageName) throws Exception {
        try {
            SignRequest request = new SignRequest();
    
            RequestBaseType.OptionalInputs optInputs = new RequestBaseType.OptionalInputs();
    
            // Set signature type
            optInputs.setSignatureType("http://arx.com/SAPIWS/DSS/1.0/set-graphic-image");
    
            // Set user credentials
            ClaimedIdentity claimedIdentity = new ClaimedIdentity();
            NameIdentifierType nameIdentifier = new NameIdentifierType();
            nameIdentifier.setValue(username);
            nameIdentifier.setNameQualifier(domain);
            CoSignAuthDataType coSignAuthData = new CoSignAuthDataType();
            coSignAuthData.setLogonPassword(password);
            claimedIdentity.setName(nameIdentifier);
            claimedIdentity.setSupportingInfo(coSignAuthData);
            optInputs.setClaimedIdentity(claimedIdentity);
    
            // Set graphical image data
            GraphicImageType graphicImage = new GraphicImageType();
            graphicImage.setGraphicImage(imageBuffer);
            graphicImage.setDataFormat(Long.valueOf(6)); //JPG
            graphicImage.setGraphicImageName(imageName);
            optInputs.setGraphicImageToSet(graphicImage);
    
            request.setOptionalInputs(optInputs);
    
            // Initiate service client
            DSS client = new DSS(new URL("https://prime.cosigntrial.com:8080/sapiws/dss.asmx"));
    
            // Send the request
            DssSignResult response = client.getDSSSoap().dssSign(request);
    
            // Check result
            String errmsg = "" + response.getResult().getResultMajor();
            if (errmsg.compareTo("urn:oasis:names:tc:dss:1.0:resultmajor:Success") == 0) {
                System.out.println("Graphical image was added successfully!");
                return;
            }
            else {
                throw new Exception(response.getResult().getResultMessage().toString());
            }
        }
        catch (Exception e) {
            System.out.println("Error: " + e.getMessage());
            e.printStackTrace();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-19
      • 1970-01-01
      相关资源
      最近更新 更多