Skip to content
Merged

Dev #324

Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,29 @@
import com.sun.jersey.api.client.WebResource.Builder;

public class PipelineHelpers {

private static String createErrorMessage(ClientResponse clientResponse) {
clientResponse.bufferEntity();
String errorMessage = clientResponse.toString();
if (clientResponse.hasEntity()) {
errorMessage = errorMessage + " " + clientResponse.getEntity(String.class);
}
return errorMessage;
}

public static void ThrowIfNotSuccess(ClientResponse clientResponse) {
int statusCode = clientResponse.getStatus();

if ((statusCode < 200) || (statusCode >= 300)) {
throw new UniformInterfaceException(clientResponse);
String errorMessage = createErrorMessage(clientResponse);
throw new UniformInterfaceException(errorMessage, clientResponse);
}
}

public static void ThrowIfError(ClientResponse clientResponse) {
if (clientResponse.getStatus() >= 400) {
throw new UniformInterfaceException(clientResponse);
String errorMessage = createErrorMessage(clientResponse);
throw new UniformInterfaceException(errorMessage, clientResponse);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static org.junit.Assert.*;

import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.PrivateKey;
import java.security.Security;
Expand Down Expand Up @@ -284,9 +285,10 @@ public void rebindContentKeyWithX509CertficateSuccess() throws Exception {
byte[] aesKey = createTestAesKey();
ContentKeyInfo contentKeyInfo = createValidTestContentKeyWithAesKey("rebindContentKeyWithX509Success", aesKey);
URL serverCertificateUri = getClass().getResource("/certificate/server.crt");
X509Certificate x509Certificate = EncryptionHelper.loadX509Certificate(serverCertificateUri.getFile());
X509Certificate x509Certificate = EncryptionHelper.loadX509Certificate(URLDecoder.decode(
serverCertificateUri.getFile(), "UTF-8"));
URL serverPrivateKey = getClass().getResource("/certificate/server.der");
PrivateKey privateKey = EncryptionHelper.getPrivateKey(serverPrivateKey.getFile());
PrivateKey privateKey = EncryptionHelper.getPrivateKey(URLDecoder.decode(serverPrivateKey.getFile(), "UTF-8"));

String rebindedContentKey = service.action(ContentKey.rebind(contentKeyInfo.getId(),
URLEncoder.encode(Base64.encode(x509Certificate.getEncoded()), "UTF-8")));
Expand Down