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

Caslabs Client - Account Settings#6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
thomshutt merged 7 commits intozencoder:masterfromJesse0Michael:Account-Settings
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletionspom.xml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.brightcove</groupId>
<artifactId>castlabs-java-api</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<developers>
<developer>
<name>Phil Cluff</name>
Expand DownExpand Up@@ -38,6 +38,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All@@ -50,6 +51,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand DownExpand Up@@ -137,17 +139,6 @@
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven 2</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>Spring</id>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>
</repository>
</repositories>
<properties>
<signing.disabled>true</signing.disabled>
<keystore.path>cert/temp.keystore</keystore.path>
Expand Down
135 changes: 132 additions & 3 deletionssrc/main/java/com/brightcove/castlabs/client/CastlabsClient.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,8 @@
import java.io.UnsupportedEncodingException;
import java.util.List;

import com.brightcove.castlabs.client.request.LinkAccountToSubMerchantRequest;
import com.brightcove.castlabs.client.request.*;
import com.brightcove.castlabs.client.response.ListAccountsResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.collect.Lists;
import org.apache.commons.io.IOUtils;
Expand All@@ -19,15 +20,14 @@
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;

import com.brightcove.castlabs.client.request.IngestKeysRequest;
import com.brightcove.castlabs.client.response.IngestAssetsResponse;
import com.brightcove.castlabs.client.request.AddSubMerchantAccountRequest;
import com.brightcove.castlabs.client.response.AddSubMerchantAccountResponse;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand DownExpand Up@@ -267,6 +267,135 @@ public void linkAccountToSubMerchant(final LinkAccountToSubMerchantRequest reque
}
}

/**
* Update Account Authorization Setting
*
* @param request Request parameters to pass to Castlabs
* @param merchantUuid UUID for the merchant
* @throws CastlabsException error reported by Castlabs
* @throws IOException network error while communicating with Castlabs REST API
*/
public void updateAuthorizationSettings(final UpdateAuthorizationSettingsRequest request, final String merchantUuid)
throws IOException, CastlabsException {

final String uri = this.getUrlWithTicket(this.ingestionBaseUrl + "frontend/rest/config/v1/" + merchantUuid + "/auth/settings");
final HttpPost httpRequest = createHttpPostRequest(uri, request);

final CloseableHttpClient httpclient = HttpClients.createDefault();
try (final CloseableHttpResponse httpResponse = httpclient.execute(httpRequest)) {
final int statusCode = httpResponse.getStatusLine().getStatusCode();

if (statusCode != HttpStatus.SC_NO_CONTENT) {
final HttpEntity responseEntity = httpResponse.getEntity();

String responseBody = "";
if (responseEntity != null) {
responseBody = IOUtils.toString(responseEntity.getContent());
}

throw new CastlabsException("Unexpected status code from Castlabs: " + statusCode + ". Response body: " + responseBody);
}
}
}

/**
* Add a Shared Secret to the Castlabs Account
*
* @param request Request parameters to pass to Castlabs
* @param merchantUuid UUID for the merchant
* @throws CastlabsException error reported by Castlabs
* @throws IOException network error while communicating with Castlabs REST API
*/
public void addSharedSecret(final SharedSecretRequest request, final String merchantUuid)
throws IOException, CastlabsException {

final String uri = this.getUrlWithTicket(this.ingestionBaseUrl + "frontend/rest/config/v1/" + merchantUuid + "/upfront/secret/add");
final HttpPost httpRequest = createHttpPostRequest(uri, request);

final CloseableHttpClient httpclient = HttpClients.createDefault();
try (final CloseableHttpResponse httpResponse = httpclient.execute(httpRequest)) {
final int statusCode = httpResponse.getStatusLine().getStatusCode();

if (statusCode != HttpStatus.SC_OK) {
final HttpEntity responseEntity = httpResponse.getEntity();

String responseBody = "";
if (responseEntity != null) {
responseBody = IOUtils.toString(responseEntity.getContent());
}

throw new CastlabsException("Unexpected status code from Castlabs: " + statusCode + ". Response body: " + responseBody);
}
}
}

/**
* Add Fairplay configuration to the Castlabs Account
*
* @param request Request parameters to pass to Castlabs
* @param merchantUuid UUID for the merchant
* @throws CastlabsException error reported by Castlabs
* @throws IOException network error while communicating with Castlabs REST API
*/
public void setFairplayConfiguration(final FairplayRequest request, final String merchantUuid)
throws IOException, CastlabsException {

final String uri = this.getUrlWithTicket(this.ingestionBaseUrl + "frontend/rest/config/v1/" + merchantUuid + "/drm/fairplay");
final HttpPost httpRequest = createHttpPostRequest(uri, request);

final CloseableHttpClient httpclient = HttpClients.createDefault();
try (final CloseableHttpResponse httpResponse = httpclient.execute(httpRequest)) {
final int statusCode = httpResponse.getStatusLine().getStatusCode();

if (statusCode != HttpStatus.SC_OK) {
final HttpEntity responseEntity = httpResponse.getEntity();

String responseBody = "";
if (responseEntity != null) {
responseBody = IOUtils.toString(responseEntity.getContent());
}

throw new CastlabsException("Unexpected status code from Castlabs: " + statusCode + ". Response body: " + responseBody);
}
}
}

/**
* List accounts available to a merchant
*
* @param merchantUuid UUID for the merchant
* @return response from Castlabs
* @throws CastlabsException error reported by Castlabs
* @throws IOException network error while communicating with Castlabs REST API
*/
public ListAccountsResponse listAccounts(final String merchantUuid)
throws IOException, CastlabsException {

final String uri = this.getUrlWithTicket(this.ingestionBaseUrl + "frontend/rest/config/v1/" + merchantUuid + "/account/list");
final HttpGet httpRequest = new HttpGet(uri);

final CloseableHttpClient httpclient = HttpClients.createDefault();
try (final CloseableHttpResponse httpResponse = httpclient.execute(httpRequest)) {
final int statusCode = httpResponse.getStatusLine().getStatusCode();
final HttpEntity responseEntity = httpResponse.getEntity();
if (responseEntity == null) {
throw new CastlabsException("Empty response entity from Castlabs. HTTP Status: " + httpResponse.getStatusLine().getStatusCode());
}

final String responseBody = IOUtils.toString(responseEntity.getContent());
if (StringUtils.isBlank(responseBody)) {
throw new CastlabsException("Empty response entity from Castlabs. HTTP Status: " + httpResponse.getStatusLine().getStatusCode());
}

if (statusCode != HttpStatus.SC_OK) {
throw new CastlabsException("Unexpected status code from Castlabs: " + statusCode + ". Response body: " + responseBody);
}

final ListAccountsResponse response = objectMapper.readValue(responseBody, ListAccountsResponse.class);
return response;
}
}

private HttpPost createHttpPostRequest(final String uri, final Object body) throws JsonProcessingException, UnsupportedEncodingException {
final HttpPost request = new HttpPost(uri);
request.addHeader("Content-Type", "application/json");
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
package com.brightcove.castlabs.client.request;

public class FairplayRequest {

private String providerCertificate;
private String providerPrivateKey;
private String applicationSecretKey;

public String getProviderCertificate() {
return providerCertificate;
}

public void setProviderCertificate(String providerCertificate) {
this.providerCertificate = providerCertificate;
}

public String getProviderPrivateKey() { return providerPrivateKey; }

public void setProviderPrivateKey(String providerPrivateKey) {
this.providerPrivateKey = providerPrivateKey;
}

public String getApplicationSecretKey() { return applicationSecretKey; }

public void setApplicationSecretKey(String applicationSecretKey) { this.applicationSecretKey = applicationSecretKey; }

@Override
public String toString() {
return "FairplayRequest{" +
"providerCertificate='" + providerCertificate + '\'' +
", providerPrivateKey='" + providerPrivateKey + '\'' +
", applicationSecretKey='" + applicationSecretKey + '\'' +
'}';
}

}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
package com.brightcove.castlabs.client.request;

public class SharedSecretRequest {

private Boolean enabled;
private String description;
private String secret;

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getSecret() { return secret; }

public void setSecret(String secret) {
this.secret = secret;
}

@Override
public String toString() {
return "SharedSecretRequest{" +
"enabled='" + enabled + '\'' +
", description='" + description + '\'' +
", secret='" + secret + '\'' +
'}';
}

}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
package com.brightcove.castlabs.client.request;

public class UpdateAuthorizationSettingsRequest {

private String mode;
private String callbackUrl;

public String getMode() {
return mode;
}

public void setMode(String mode) { this.mode = mode; }

public String getCallbackUrl() { return callbackUrl; }

public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}

@Override
public String toString() {
return "UpdateAuthorizationSettingsRequest{" +
"mode='" + mode + '\'' +
", callbackUrl='" + callbackUrl + '\'' +
'}';
}

}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
package com.brightcove.castlabs.client.response;

import java.util.List;

public class Account {

private String id;
private Boolean enabled;
private Boolean api;
private String login;
private String firstName;
private String lastName;
private List<String> permissions;

public String getID() {
return id;
}

public void setID(String id) {
this.id = id;
}

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

public Boolean getAPI() {
return api;
}

public void setAPI(Boolean api) {
this.api = api;
}

public String getLogin() {
return login;
}

public void setLogin(String login) {
this.login = login;
}

public String getFirstName() { return firstName; }

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public List<String> getPermissions() {
return permissions;
}

public void setPermissions(List<String> permissions) {
this.permissions = permissions;
}

@Override
public String toString() {
return "Account{" +
"id='" + id + '\'' +
", enabled='" + enabled + '\'' +
", api='" + api + '\'' +
", login='" + login + '\'' +
", firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
", permissions='" + permissions + '\'' +
'}';
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp