Skip to content

Commit fe5bc5a

Browse files
author
evgeny.ivanov
committed
SDK regenerated by CI server [ci skip]
1 parent a45af01 commit fe5bc5a

File tree

5 files changed

+380
-0
lines changed

5 files changed

+380
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ This repository contains Aspose.Words Cloud SDK for Java source code. This SDK a
1717

1818
- ImlRenderingMode option introduced witch is used to determine how ink (InkML) objects are rendered
1919
- MaxCharactersPerLine option introduced which is used to specify the maximum number of characters per one line
20+
- Added new API method to get a RSA public key to encrypt document passwords
21+
- Added encryptedPassword common query option to pass an encrypted document password
2022

2123

2224
## Enhancements in Version 21.6

src/main/java/com/aspose/words/cloud/api/WordsApi.java

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11122,6 +11122,81 @@ public void onRequestProgress(long bytesWritten, long contentLength, boolean don
1112211122
return call;
1112311123
}
1112411124

11125+
@SuppressWarnings("rawtypes")
11126+
private com.squareup.okhttp.Call getPublicKeyValidateBeforeCall(GetPublicKeyRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException, IOException {
11127+
return apiClient.buildCall(request.buildHttpRequest(apiClient, progressListener, progressRequestListener, true));
11128+
}
11129+
11130+
/**
11131+
* Get assymetric public key.
11132+
* @param request Request object
11133+
* @return PublicKeyResponse
11134+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
11135+
* @throws IOException If fail to serialize the request body object
11136+
*/
11137+
public PublicKeyResponse getPublicKey(GetPublicKeyRequest request) throws ApiException, MessagingException, IOException {
11138+
try {
11139+
ApiResponse< PublicKeyResponse > resp = getPublicKeyWithHttpInfo(request);
11140+
return resp.getData();
11141+
}
11142+
catch (ApiException ex) {
11143+
if (ex.getCode() == apiClient.getNotAuthCode()) {
11144+
apiClient.requestToken();
11145+
ApiResponse< PublicKeyResponse > resp = getPublicKeyWithHttpInfo(request);
11146+
return resp.getData();
11147+
}
11148+
throw ex;
11149+
}
11150+
}
11151+
11152+
/**
11153+
* Get assymetric public key.
11154+
* @param request Request object
11155+
* @return ApiResponse< PublicKeyResponse >;
11156+
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
11157+
* @throws IOException If fail to serialize the request body object
11158+
*/
11159+
private ApiResponse< PublicKeyResponse > getPublicKeyWithHttpInfo(GetPublicKeyRequest request) throws ApiException, MessagingException, IOException {
11160+
com.squareup.okhttp.Call call = getPublicKeyValidateBeforeCall(request, null, null);
11161+
Response response = call.execute();
11162+
PublicKeyResponse data = request.deserializeResponse(apiClient, response);
11163+
return new ApiResponse< PublicKeyResponse >(response.code(), response.headers().toMultimap(), data);
11164+
}
11165+
11166+
/**
11167+
* Get assymetric public key. (asynchronously)
11168+
* @param request Request object
11169+
* @param callback The callback to be executed when the API call finishes
11170+
* @return The request call
11171+
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
11172+
* @throws IOException If fail to serialize the request body object
11173+
*/
11174+
public com.squareup.okhttp.Call getPublicKeyAsync(GetPublicKeyRequest request, final ApiCallback< PublicKeyResponse > callback) throws ApiException, MessagingException, IOException {
11175+
11176+
ProgressResponseBody.ProgressListener progressListener = null;
11177+
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
11178+
11179+
if (callback != null) {
11180+
progressListener = new ProgressResponseBody.ProgressListener() {
11181+
@Override
11182+
public void update(long bytesRead, long contentLength, boolean done) {
11183+
callback.onDownloadProgress(bytesRead, contentLength, done);
11184+
}
11185+
};
11186+
11187+
progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
11188+
@Override
11189+
public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
11190+
callback.onUploadProgress(bytesWritten, contentLength, done);
11191+
}
11192+
};
11193+
}
11194+
11195+
com.squareup.okhttp.Call call = getPublicKeyValidateBeforeCall(request, progressListener, progressRequestListener);
11196+
apiClient.executeAsync(call, request.getResponseType(), callback);
11197+
return call;
11198+
}
11199+
1112511200
@SuppressWarnings("rawtypes")
1112611201
private com.squareup.okhttp.Call getRangeTextValidateBeforeCall(GetRangeTextRequest request, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException, IOException {
1112711202
return apiClient.buildCall(request.buildHttpRequest(apiClient, progressListener, progressRequestListener, true));
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="PublicKeyResponse.java">
4+
* Copyright (c) 2021 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
package com.aspose.words.cloud.model;
29+
30+
import java.util.Objects;
31+
import java.util.Arrays;
32+
import java.util.ArrayList;
33+
import java.util.List;
34+
import java.io.IOException;
35+
import org.threeten.bp.OffsetDateTime;
36+
import com.aspose.words.cloud.model.*;
37+
import com.google.gson.TypeAdapter;
38+
import com.google.gson.annotations.JsonAdapter;
39+
import com.google.gson.annotations.SerializedName;
40+
import com.google.gson.stream.JsonReader;
41+
import com.google.gson.stream.JsonWriter;
42+
import io.swagger.annotations.ApiModel;
43+
import io.swagger.annotations.ApiModelProperty;
44+
45+
/**
46+
* REST response for RSA public key info.
47+
*/
48+
@ApiModel(description = "REST response for RSA public key info.")
49+
public class PublicKeyResponse extends WordsResponse {
50+
@SerializedName("Exponent")
51+
private String exponent = null;
52+
53+
@SerializedName("Modulus")
54+
private String modulus = null;
55+
public PublicKeyResponse exponent(String exponent) {
56+
this.exponent = exponent;
57+
return this;
58+
}
59+
60+
/**
61+
* Gets or sets RSA key exponent as Base64 string.
62+
* @return exponent
63+
**/
64+
@ApiModelProperty(value = "Gets or sets RSA key exponent as Base64 string.")
65+
public String getExponent() {
66+
return exponent;
67+
}
68+
69+
public void setExponent(String exponent) {
70+
this.exponent = exponent;
71+
}
72+
73+
public PublicKeyResponse modulus(String modulus) {
74+
this.modulus = modulus;
75+
return this;
76+
}
77+
78+
/**
79+
* Gets or sets RSA key modulus as Base64 string.
80+
* @return modulus
81+
**/
82+
@ApiModelProperty(value = "Gets or sets RSA key modulus as Base64 string.")
83+
public String getModulus() {
84+
return modulus;
85+
}
86+
87+
public void setModulus(String modulus) {
88+
this.modulus = modulus;
89+
}
90+
91+
@Override
92+
public boolean equals(java.lang.Object o) {
93+
if (this == o) {
94+
return true;
95+
}
96+
if (o == null || getClass() != o.getClass()) {
97+
return false;
98+
}
99+
100+
PublicKeyResponse publicKeyResponse = (PublicKeyResponse) o;
101+
return
102+
Objects.equals(this.exponent, publicKeyResponse.exponent) &&
103+
Objects.equals(this.modulus, publicKeyResponse.modulus) &&
104+
super.equals(o);
105+
}
106+
107+
@Override
108+
public int hashCode() {
109+
return Objects.hash(exponent, modulus, super.hashCode());
110+
}
111+
112+
@Override
113+
public String toString() {
114+
StringBuilder sb = new StringBuilder();
115+
sb.append("class PublicKeyResponse {\n");
116+
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
117+
sb.append(" exponent: ").append(toIndentedString(exponent)).append("\n");
118+
sb.append(" modulus: ").append(toIndentedString(modulus)).append("\n");
119+
sb.append("}");
120+
return sb.toString();
121+
}
122+
123+
/**
124+
* Convert the given object to string with each line indented by 4 spaces
125+
* (except the first line).
126+
*/
127+
private String toIndentedString(java.lang.Object o) {
128+
if (o == null) {
129+
return "null";
130+
}
131+
return o.toString().replace("\n", "\n ");
132+
}
133+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="GetPublicKeyRequest.java">
4+
* Copyright (c) 2021 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
package com.aspose.words.cloud.model.requests;
29+
30+
import com.aspose.words.cloud.*;
31+
import com.aspose.words.cloud.model.*;
32+
import com.aspose.words.cloud.model.responses.*;
33+
import com.squareup.okhttp.*;
34+
import javax.mail.MessagingException;
35+
import javax.mail.internet.MimeMultipart;
36+
import java.io.*;
37+
import java.lang.reflect.Type;
38+
import java.util.*;
39+
40+
/*
41+
* Request model for getPublicKey operation.
42+
*/
43+
public class GetPublicKeyRequest implements RequestIfc {
44+
45+
/*
46+
* Creates the http request based on this request model.
47+
*
48+
* @param apiClient ApiClient instance
49+
* @throws ApiException If fail to serialize the request body object
50+
* @throws IOException If fail to serialize the request body object
51+
*/
52+
public Request buildHttpRequest(ApiClient apiClient, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener, Boolean addAuthHeaders) throws ApiException, IOException {
53+
54+
Object localVarPostBody = null;
55+
56+
// create path and map variables
57+
String localVarPath = "/words/encryption/publickey";
58+
localVarPath = localVarPath.replaceAll("//", "/");
59+
60+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
61+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
62+
63+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
64+
65+
Map<String, Object> localVarFormParams = new LinkedHashMap<String, Object>();
66+
67+
if (progressListener != null) {
68+
apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
69+
@Override
70+
public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
71+
com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
72+
return originalResponse.newBuilder()
73+
.body(new ProgressResponseBody(originalResponse.body(), progressListener))
74+
.build();
75+
}
76+
});
77+
}
78+
79+
return apiClient.buildRequest(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, addAuthHeaders, progressRequestListener);
80+
}
81+
82+
/*
83+
* Gets response type for this request.
84+
*/
85+
public Type getResponseType() {
86+
return PublicKeyResponse.class;
87+
}
88+
89+
/*
90+
* Deserialize response message.
91+
*
92+
* @param apiClient ApiClient instance
93+
* @param response Response instance
94+
*/
95+
public PublicKeyResponse deserializeResponse(ApiClient apiClient, Response response) throws ApiException, MessagingException, IOException {
96+
return (PublicKeyResponse) apiClient.deserialize(response, PublicKeyResponse.class);
97+
}
98+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* --------------------------------------------------------------------------------
3+
* <copyright company="Aspose" file="TestPasswordEncryption.java">
4+
* Copyright (c) 2021 Aspose.Words for Cloud
5+
* </copyright>
6+
* <summary>
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in all
15+
* copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
* SOFTWARE.
24+
* </summary>
25+
* --------------------------------------------------------------------------------
26+
*/
27+
28+
package com.aspose.words.cloud.api.document;
29+
30+
import com.aspose.words.cloud.*;
31+
import com.aspose.words.cloud.model.*;
32+
import com.aspose.words.cloud.model.requests.*;
33+
import com.aspose.words.cloud.model.responses.*;
34+
import junit.framework.TestCase;
35+
import org.junit.Test;
36+
import org.threeten.bp.*;
37+
import java.io.File;
38+
import java.io.IOException;
39+
import javax.mail.MessagingException;
40+
import java.nio.file.*;
41+
import java.util.ArrayList;
42+
43+
/*
44+
* Example of how to handle an encrypted document.
45+
*/
46+
public class TestPasswordEncryption extends TestCase
47+
{
48+
private String remoteDataFolder = TestInitializer.RemoteTestFolder + "/DocumentActions/PasswordEncryption";
49+
private String localFile = "Common/test_multi_pages.docx";
50+
51+
52+
@Override
53+
protected void setUp() throws Exception {
54+
super.setUp();
55+
TestInitializer.Initialize();
56+
}
57+
58+
/*
59+
* Test for getting a public key for password encryption.
60+
*/
61+
@Test
62+
public void testGetPublicKey() throws ApiException, MessagingException, IOException
63+
{
64+
GetPublicKeyRequest request = new GetPublicKeyRequest(
65+
);
66+
67+
PublicKeyResponse result = TestInitializer.wordsApi.getPublicKey(request);
68+
assertNotNull(result);
69+
assertNotNull(result.getExponent());
70+
assertNotNull(result.getModulus());
71+
}
72+
}

0 commit comments

Comments
 (0)