Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26e119d

Browse files
authored
Merge pull request#6 from Jesse0Michael/Account-Settings
Caslabs Client - Account Settings
2 parents8e73fb2 +c93cff1 commit26e119d

File tree

9 files changed

+532
-15
lines changed

9 files changed

+532
-15
lines changed

‎pom.xml‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.brightcove</groupId>
55
<artifactId>castlabs-java-api</artifactId>
6-
<version>1.0.3</version>
6+
<version>1.0.4</version>
77
<developers>
88
<developer>
99
<name>Phil Cluff</name>
@@ -38,6 +38,7 @@
3838
<plugin>
3939
<groupId>org.apache.maven.plugins</groupId>
4040
<artifactId>maven-source-plugin</artifactId>
41+
<version>3.0.1</version>
4142
<executions>
4243
<execution>
4344
<id>attach-sources</id>
@@ -50,6 +51,7 @@
5051
<plugin>
5152
<groupId>org.apache.maven.plugins</groupId>
5253
<artifactId>maven-javadoc-plugin</artifactId>
54+
<version>2.10.4</version>
5355
<executions>
5456
<execution>
5557
<id>attach-javadocs</id>
@@ -137,17 +139,6 @@
137139
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
138140
</repository>
139141
</distributionManagement>
140-
<repositories>
141-
<repository>
142-
<id>maven2-repository.dev.java.net</id>
143-
<name>Java.net Repository for Maven 2</name>
144-
<url>http://download.java.net/maven/2</url>
145-
</repository>
146-
<repository>
147-
<id>Spring</id>
148-
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
149-
</repository>
150-
</repositories>
151142
<properties>
152143
<signing.disabled>true</signing.disabled>
153144
<keystore.path>cert/temp.keystore</keystore.path>

‎src/main/java/com/brightcove/castlabs/client/CastlabsClient.java‎

Lines changed: 132 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
importjava.io.UnsupportedEncodingException;
88
importjava.util.List;
99

10-
importcom.brightcove.castlabs.client.request.LinkAccountToSubMerchantRequest;
10+
importcom.brightcove.castlabs.client.request.*;
11+
importcom.brightcove.castlabs.client.response.ListAccountsResponse;
1112
importcom.fasterxml.jackson.core.JsonProcessingException;
1213
importcom.google.common.collect.Lists;
1314
importorg.apache.commons.io.IOUtils;
@@ -19,15 +20,14 @@
1920
importorg.apache.http.client.config.RequestConfig;
2021
importorg.apache.http.client.entity.UrlEncodedFormEntity;
2122
importorg.apache.http.client.methods.CloseableHttpResponse;
23+
importorg.apache.http.client.methods.HttpGet;
2224
importorg.apache.http.client.methods.HttpPost;
2325
importorg.apache.http.entity.StringEntity;
2426
importorg.apache.http.impl.client.CloseableHttpClient;
2527
importorg.apache.http.impl.client.HttpClients;
2628
importorg.apache.http.message.BasicNameValuePair;
2729

28-
importcom.brightcove.castlabs.client.request.IngestKeysRequest;
2930
importcom.brightcove.castlabs.client.response.IngestAssetsResponse;
30-
importcom.brightcove.castlabs.client.request.AddSubMerchantAccountRequest;
3131
importcom.brightcove.castlabs.client.response.AddSubMerchantAccountResponse;
3232
importcom.fasterxml.jackson.databind.DeserializationFeature;
3333
importcom.fasterxml.jackson.databind.ObjectMapper;
@@ -267,6 +267,135 @@ public void linkAccountToSubMerchant(final LinkAccountToSubMerchantRequest reque
267267
}
268268
}
269269

270+
/**
271+
* Update Account Authorization Setting
272+
*
273+
* @param request Request parameters to pass to Castlabs
274+
* @param merchantUuid UUID for the merchant
275+
* @throws CastlabsException error reported by Castlabs
276+
* @throws IOException network error while communicating with Castlabs REST API
277+
*/
278+
publicvoidupdateAuthorizationSettings(finalUpdateAuthorizationSettingsRequestrequest,finalStringmerchantUuid)
279+
throwsIOException,CastlabsException {
280+
281+
finalStringuri =this.getUrlWithTicket(this.ingestionBaseUrl +"frontend/rest/config/v1/" +merchantUuid +"/auth/settings");
282+
finalHttpPosthttpRequest =createHttpPostRequest(uri,request);
283+
284+
finalCloseableHttpClienthttpclient =HttpClients.createDefault();
285+
try (finalCloseableHttpResponsehttpResponse =httpclient.execute(httpRequest)) {
286+
finalintstatusCode =httpResponse.getStatusLine().getStatusCode();
287+
288+
if (statusCode !=HttpStatus.SC_NO_CONTENT) {
289+
finalHttpEntityresponseEntity =httpResponse.getEntity();
290+
291+
StringresponseBody ="";
292+
if (responseEntity !=null) {
293+
responseBody =IOUtils.toString(responseEntity.getContent());
294+
}
295+
296+
thrownewCastlabsException("Unexpected status code from Castlabs: " +statusCode +". Response body: " +responseBody);
297+
}
298+
}
299+
}
300+
301+
/**
302+
* Add a Shared Secret to the Castlabs Account
303+
*
304+
* @param request Request parameters to pass to Castlabs
305+
* @param merchantUuid UUID for the merchant
306+
* @throws CastlabsException error reported by Castlabs
307+
* @throws IOException network error while communicating with Castlabs REST API
308+
*/
309+
publicvoidaddSharedSecret(finalSharedSecretRequestrequest,finalStringmerchantUuid)
310+
throwsIOException,CastlabsException {
311+
312+
finalStringuri =this.getUrlWithTicket(this.ingestionBaseUrl +"frontend/rest/config/v1/" +merchantUuid +"/upfront/secret/add");
313+
finalHttpPosthttpRequest =createHttpPostRequest(uri,request);
314+
315+
finalCloseableHttpClienthttpclient =HttpClients.createDefault();
316+
try (finalCloseableHttpResponsehttpResponse =httpclient.execute(httpRequest)) {
317+
finalintstatusCode =httpResponse.getStatusLine().getStatusCode();
318+
319+
if (statusCode !=HttpStatus.SC_OK) {
320+
finalHttpEntityresponseEntity =httpResponse.getEntity();
321+
322+
StringresponseBody ="";
323+
if (responseEntity !=null) {
324+
responseBody =IOUtils.toString(responseEntity.getContent());
325+
}
326+
327+
thrownewCastlabsException("Unexpected status code from Castlabs: " +statusCode +". Response body: " +responseBody);
328+
}
329+
}
330+
}
331+
332+
/**
333+
* Add Fairplay configuration to the Castlabs Account
334+
*
335+
* @param request Request parameters to pass to Castlabs
336+
* @param merchantUuid UUID for the merchant
337+
* @throws CastlabsException error reported by Castlabs
338+
* @throws IOException network error while communicating with Castlabs REST API
339+
*/
340+
publicvoidsetFairplayConfiguration(finalFairplayRequestrequest,finalStringmerchantUuid)
341+
throwsIOException,CastlabsException {
342+
343+
finalStringuri =this.getUrlWithTicket(this.ingestionBaseUrl +"frontend/rest/config/v1/" +merchantUuid +"/drm/fairplay");
344+
finalHttpPosthttpRequest =createHttpPostRequest(uri,request);
345+
346+
finalCloseableHttpClienthttpclient =HttpClients.createDefault();
347+
try (finalCloseableHttpResponsehttpResponse =httpclient.execute(httpRequest)) {
348+
finalintstatusCode =httpResponse.getStatusLine().getStatusCode();
349+
350+
if (statusCode !=HttpStatus.SC_OK) {
351+
finalHttpEntityresponseEntity =httpResponse.getEntity();
352+
353+
StringresponseBody ="";
354+
if (responseEntity !=null) {
355+
responseBody =IOUtils.toString(responseEntity.getContent());
356+
}
357+
358+
thrownewCastlabsException("Unexpected status code from Castlabs: " +statusCode +". Response body: " +responseBody);
359+
}
360+
}
361+
}
362+
363+
/**
364+
* List accounts available to a merchant
365+
*
366+
* @param merchantUuid UUID for the merchant
367+
* @return response from Castlabs
368+
* @throws CastlabsException error reported by Castlabs
369+
* @throws IOException network error while communicating with Castlabs REST API
370+
*/
371+
publicListAccountsResponselistAccounts(finalStringmerchantUuid)
372+
throwsIOException,CastlabsException {
373+
374+
finalStringuri =this.getUrlWithTicket(this.ingestionBaseUrl +"frontend/rest/config/v1/" +merchantUuid +"/account/list");
375+
finalHttpGethttpRequest =newHttpGet(uri);
376+
377+
finalCloseableHttpClienthttpclient =HttpClients.createDefault();
378+
try (finalCloseableHttpResponsehttpResponse =httpclient.execute(httpRequest)) {
379+
finalintstatusCode =httpResponse.getStatusLine().getStatusCode();
380+
finalHttpEntityresponseEntity =httpResponse.getEntity();
381+
if (responseEntity ==null) {
382+
thrownewCastlabsException("Empty response entity from Castlabs. HTTP Status: " +httpResponse.getStatusLine().getStatusCode());
383+
}
384+
385+
finalStringresponseBody =IOUtils.toString(responseEntity.getContent());
386+
if (StringUtils.isBlank(responseBody)) {
387+
thrownewCastlabsException("Empty response entity from Castlabs. HTTP Status: " +httpResponse.getStatusLine().getStatusCode());
388+
}
389+
390+
if (statusCode !=HttpStatus.SC_OK) {
391+
thrownewCastlabsException("Unexpected status code from Castlabs: " +statusCode +". Response body: " +responseBody);
392+
}
393+
394+
finalListAccountsResponseresponse =objectMapper.readValue(responseBody,ListAccountsResponse.class);
395+
returnresponse;
396+
}
397+
}
398+
270399
privateHttpPostcreateHttpPostRequest(finalStringuri,finalObjectbody)throwsJsonProcessingException,UnsupportedEncodingException {
271400
finalHttpPostrequest =newHttpPost(uri);
272401
request.addHeader("Content-Type","application/json");
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
packagecom.brightcove.castlabs.client.request;
2+
3+
publicclassFairplayRequest {
4+
5+
privateStringproviderCertificate;
6+
privateStringproviderPrivateKey;
7+
privateStringapplicationSecretKey;
8+
9+
publicStringgetProviderCertificate() {
10+
returnproviderCertificate;
11+
}
12+
13+
publicvoidsetProviderCertificate(StringproviderCertificate) {
14+
this.providerCertificate =providerCertificate;
15+
}
16+
17+
publicStringgetProviderPrivateKey() {returnproviderPrivateKey; }
18+
19+
publicvoidsetProviderPrivateKey(StringproviderPrivateKey) {
20+
this.providerPrivateKey =providerPrivateKey;
21+
}
22+
23+
publicStringgetApplicationSecretKey() {returnapplicationSecretKey; }
24+
25+
publicvoidsetApplicationSecretKey(StringapplicationSecretKey) {this.applicationSecretKey =applicationSecretKey; }
26+
27+
@Override
28+
publicStringtoString() {
29+
return"FairplayRequest{" +
30+
"providerCertificate='" +providerCertificate +'\'' +
31+
", providerPrivateKey='" +providerPrivateKey +'\'' +
32+
", applicationSecretKey='" +applicationSecretKey +'\'' +
33+
'}';
34+
}
35+
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
packagecom.brightcove.castlabs.client.request;
2+
3+
publicclassSharedSecretRequest {
4+
5+
privateBooleanenabled;
6+
privateStringdescription;
7+
privateStringsecret;
8+
9+
publicBooleangetEnabled() {
10+
returnenabled;
11+
}
12+
13+
publicvoidsetEnabled(Booleanenabled) {
14+
this.enabled =enabled;
15+
}
16+
17+
publicStringgetDescription() {
18+
returndescription;
19+
}
20+
21+
publicvoidsetDescription(Stringdescription) {
22+
this.description =description;
23+
}
24+
25+
publicStringgetSecret() {returnsecret; }
26+
27+
publicvoidsetSecret(Stringsecret) {
28+
this.secret =secret;
29+
}
30+
31+
@Override
32+
publicStringtoString() {
33+
return"SharedSecretRequest{" +
34+
"enabled='" +enabled +'\'' +
35+
", description='" +description +'\'' +
36+
", secret='" +secret +'\'' +
37+
'}';
38+
}
39+
40+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
packagecom.brightcove.castlabs.client.request;
2+
3+
publicclassUpdateAuthorizationSettingsRequest {
4+
5+
privateStringmode;
6+
privateStringcallbackUrl;
7+
8+
publicStringgetMode() {
9+
returnmode;
10+
}
11+
12+
publicvoidsetMode(Stringmode) {this.mode =mode; }
13+
14+
publicStringgetCallbackUrl() {returncallbackUrl; }
15+
16+
publicvoidsetCallbackUrl(StringcallbackUrl) {
17+
this.callbackUrl =callbackUrl;
18+
}
19+
20+
@Override
21+
publicStringtoString() {
22+
return"UpdateAuthorizationSettingsRequest{" +
23+
"mode='" +mode +'\'' +
24+
", callbackUrl='" +callbackUrl +'\'' +
25+
'}';
26+
}
27+
28+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
packagecom.brightcove.castlabs.client.response;
2+
3+
importjava.util.List;
4+
5+
publicclassAccount {
6+
7+
privateStringid;
8+
privateBooleanenabled;
9+
privateBooleanapi;
10+
privateStringlogin;
11+
privateStringfirstName;
12+
privateStringlastName;
13+
privateList<String>permissions;
14+
15+
publicStringgetID() {
16+
returnid;
17+
}
18+
19+
publicvoidsetID(Stringid) {
20+
this.id =id;
21+
}
22+
23+
publicBooleangetEnabled() {
24+
returnenabled;
25+
}
26+
27+
publicvoidsetEnabled(Booleanenabled) {
28+
this.enabled =enabled;
29+
}
30+
31+
publicBooleangetAPI() {
32+
returnapi;
33+
}
34+
35+
publicvoidsetAPI(Booleanapi) {
36+
this.api =api;
37+
}
38+
39+
publicStringgetLogin() {
40+
returnlogin;
41+
}
42+
43+
publicvoidsetLogin(Stringlogin) {
44+
this.login =login;
45+
}
46+
47+
publicStringgetFirstName() {returnfirstName; }
48+
49+
publicvoidsetFirstName(StringfirstName) {
50+
this.firstName =firstName;
51+
}
52+
53+
publicStringgetLastName() {
54+
returnlastName;
55+
}
56+
57+
publicvoidsetLastName(StringlastName) {
58+
this.lastName =lastName;
59+
}
60+
61+
publicList<String>getPermissions() {
62+
returnpermissions;
63+
}
64+
65+
publicvoidsetPermissions(List<String>permissions) {
66+
this.permissions =permissions;
67+
}
68+
69+
@Override
70+
publicStringtoString() {
71+
return"Account{" +
72+
"id='" +id +'\'' +
73+
", enabled='" +enabled +'\'' +
74+
", api='" +api +'\'' +
75+
", login='" +login +'\'' +
76+
", firstName='" +firstName +'\'' +
77+
", lastName='" +lastName +'\'' +
78+
", permissions='" +permissions +'\'' +
79+
'}';
80+
}
81+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp