Permalink
Browse files

Merge pull request #56 from gcheng/security

Encryption integration test
  • Loading branch information...
2 parents 36542aa + 9d189ef commit ac6f67e158c41545600dbec2860ed7f4d57bf1a7 Albert Cheng committed Dec 18, 2012
@@ -104,6 +104,12 @@
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk16</artifactId>
+ <version>1.46</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -0,0 +1,80 @@
+/**
+ * Copyright 2012 Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.microsoft.windowsazure.services.media.implementation.content;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * This type maps the XML returned in the odata ATOM serialization
+ * for ErrorDetail entities.
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ErrorDetailType implements MediaServiceDTO {
+
+ /** The code. */
+ @XmlElement(name = "Code", namespace = Constants.ODATA_DATA_NS)
+ protected String code;
+
+ /** The message. */
+ @XmlElement(name = "Message", namespace = Constants.ODATA_DATA_NS)
+ protected String message;
+
+ /**
+ * Gets the code.
+ *
+ * @return the code
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * Sets the code.
+ *
+ * @param code
+ * the id to set
+ * @return the error detail type
+ */
+ public ErrorDetailType setCode(String code) {
+ this.code = code;
+ return this;
+ }
+
+ /**
+ * Gets the message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the message.
+ *
+ * @param message
+ * the message to set
+ * @return the error detail type
+ */
+ public ErrorDetailType setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+}
@@ -21,6 +21,7 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
/**
* This type maps the XML returned in the odata ATOM serialization
@@ -39,8 +40,9 @@
@XmlElement(name = "EndTime", namespace = Constants.ODATA_DATA_NS)
protected Date endTime;
- @XmlElement(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS)
- protected String errorDetails;
+ @XmlElementWrapper(name = "ErrorDetails", namespace = Constants.ODATA_DATA_NS)
+ @XmlElement(name = "element", namespace = Constants.ODATA_DATA_NS)
+ protected List<ErrorDetailType> errorDetails;
@XmlElement(name = "MediaProcessorId", namespace = Constants.ODATA_DATA_NS)
protected String mediaProcessorId;
@@ -112,11 +114,11 @@ public void setEndTime(Date endTime) {
this.endTime = endTime;
}
- public String getErrorDetails() {
+ public List<ErrorDetailType> getErrorDetails() {
return errorDetails;
}
- public void setErrorDetails(String errorDetails) {
+ public void setErrorDetails(List<ErrorDetailType> errorDetails) {
this.errorDetails = errorDetails;
}
@@ -78,6 +78,12 @@ public static Creator create(String id, ContentKeyType contentKeyType, String en
/** The checksum. */
private String checksum;
+ /** The protection key id. */
+ private String protectionKeyId;
+
+ /** The protection key type. */
+ private ProtectionKeyType protectionKeyType;
+
/**
* Instantiates a new creator.
*
@@ -89,7 +95,6 @@ public static Creator create(String id, ContentKeyType contentKeyType, String en
* the encrypted content key
*/
public Creator(String id, ContentKeyType contentKeyType, String encryptedContentKey) {
-
super(ENTITY_SET, ContentKeyInfo.class);
this.id = id;
@@ -107,9 +112,13 @@ public Object getRequestContents() {
if (contentKeyType != null) {
contentKeyRestType.setContentKeyType(contentKeyType.getCode());
}
+ if (protectionKeyType != null) {
+ contentKeyRestType.setProtectionKeyType(protectionKeyType.getCode());
+ }
contentKeyRestType.setEncryptedContentKey(encryptedContentKey);
contentKeyRestType.setName(name);
contentKeyRestType.setChecksum(checksum);
+ contentKeyRestType.setProtectionKeyId(protectionKeyId);
return contentKeyRestType;
}
@@ -136,6 +145,30 @@ public Creator setChecksum(String checksum) {
this.checksum = checksum;
return this;
}
+
+ /**
+ * Sets the protection key id.
+ *
+ * @param protectionKeyId
+ * the protection key id
+ * @return the creator
+ */
+ public Creator setProtectionKeyId(String protectionKeyId) {
+ this.protectionKeyId = protectionKeyId;
+ return this;
+ }
+
+ /**
+ * Sets the protection key type.
+ *
+ * @param protectionKeyType
+ * the protection key type
+ * @return the creator
+ */
+ public Creator setProtectionKeyType(ProtectionKeyType protectionKeyType) {
+ this.protectionKeyType = protectionKeyType;
+ return this;
+ }
}
/**
@@ -21,7 +21,6 @@
import com.microsoft.windowsazure.services.media.implementation.atom.EntryType;
import com.microsoft.windowsazure.services.media.implementation.content.ContentKeyRestType;
-// TODO: Auto-generated Javadoc
/**
* The Class ContentKeyInfo.
*/
@@ -17,7 +17,6 @@
import java.security.InvalidParameterException;
-// TODO: Auto-generated Javadoc
/**
*
* Specifies the type of a content key.
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2012 Microsoft Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.microsoft.windowsazure.services.media.models;
+
+/**
+ * The Class ErrorDetail.
+ */
+public class ErrorDetail {
+
+ /** The code. */
+ private final String code;
+
+ /** The message. */
+ private final String message;
+
+ /**
+ * Instantiates a new error detail.
+ *
+ * @param code
+ * the code
+ * @param message
+ * the message
+ */
+ public ErrorDetail(String code, String message) {
+ this.code = code;
+ this.message = message;
+ }
+
+ /**
+ * Gets the code.
+ *
+ * @return the code
+ */
+ public String getCode() {
+ return this.code;
+ }
+
+ /**
+ * Gets the message.
+ *
+ * @return the message
+ */
+ public String getMessage() {
+ return this.message;
+ }
+}
@@ -62,8 +62,6 @@ private Job() {
/**
* Creates an operation to create a new job.
*
- * @param serviceUri
- * the service uri
* @return the creator
*/
public static Creator create() {
@@ -15,10 +15,13 @@
package com.microsoft.windowsazure.services.media.models;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import com.microsoft.windowsazure.services.media.implementation.ODataEntity;
import com.microsoft.windowsazure.services.media.implementation.atom.EntryType;
+import com.microsoft.windowsazure.services.media.implementation.content.ErrorDetailType;
import com.microsoft.windowsazure.services.media.implementation.content.TaskType;
/**
@@ -70,8 +73,17 @@ public Date getEndTime() {
*
* @return the error details
*/
- public String getErrorDetails() {
- return getContent().getErrorDetails();
+ public List<ErrorDetail> getErrorDetails() {
+ List<ErrorDetail> result = new ArrayList<ErrorDetail>();
+ List<ErrorDetailType> errorDetailTypes = getContent().getErrorDetails();
+ if (errorDetailTypes != null) {
+ for (ErrorDetailType errorDetailType : errorDetailTypes) {
+ ErrorDetail errorDetail = new ErrorDetail(errorDetailType.getCode(), errorDetailType.getMessage());
+ result.add(errorDetail);
+ }
+ return result;
+ }
+ return null;
}
/**
@@ -18,38 +18,46 @@
import java.security.InvalidParameterException;
/**
- * Enum defining the state of various tasks
- *
+ * Enum defining the state of various tasks.
*/
public enum TaskState {
- /**
- * No state
- */
+
+ /** No state. */
None(0),
- /**
- * Active
- */
+ /** Active. */
Active(1),
- /**
- * Running
- */
+ /** Running. */
Running(2),
- /**
- * Completed
- */
- Completed(3);
+ /** Completed. */
+ Completed(3),
+
+ /** Error. */
+ Error(4),
+
+ /** The Canceled. */
+ Canceled(5),
+ /** The Canceling. */
+ Canceling(6);
+
+ /** The code. */
private int code;
+ /**
+ * Instantiates a new task state.
+ *
+ * @param code
+ * the code
+ */
private TaskState(int code) {
this.code = code;
}
/**
- * Get integer code corresponding to enum value
+ * Get integer code corresponding to enum value.
*
* @return the code
*/
@@ -58,7 +66,7 @@ public int getCode() {
}
/**
- * Convert code into enum value
+ * Convert code into enum value.
*
* @param code
* the code
@@ -74,6 +82,12 @@ public static TaskState fromCode(int code) {
return Running;
case 3:
return Completed;
+ case 4:
+ return Error;
+ case 5:
+ return Canceled;
+ case 6:
+ return Canceling;
default:
throw new InvalidParameterException("code");
}
Oops, something went wrong.

0 comments on commit ac6f67e

Please sign in to comment.