Skip to content

Commit

Permalink
# fixed checkstyle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Converti committed Jan 5, 2016
1 parent 63fc31d commit 9b9cb2a
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,49 @@
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;


@XmlRootElement(name = "TokenRestrictionTemplate")
@XmlAccessorType(XmlAccessType.FIELD)
public class TokenRestrictionTemplate {

@XmlElementWrapper(name = "AlternateVerificationKeys")
@XmlElement(name = "TokenVerificationKey")
private List<TokenVerificationKey> alternateVerificationKeys;

@XmlElement(name = "Audience", required = true)
private URI audience;

@XmlElement(name = "Issuer", required = true)
private URI issuer;

@XmlElement(name = "PrimaryVerificationKey", nillable = true)
private TokenVerificationKey primaryVerificationKey;

@XmlElementWrapper(name = "RequiredClaims")
@XmlElement(name = "TokenClaim")
private List<TokenClaim> requiredClaims;

@XmlElement(name = "TokenType")
private TokenType tokenType;

@XmlElement(name = "OpenIdConnectDiscoveryDocument")
private OpenIdConnectDiscoveryDocument openIdConnectDiscoveryDocument;

@SuppressWarnings("unused")
private TokenRestrictionTemplate() {
this.setTokenType(TokenType.SWT);
initCollections();
}

public TokenRestrictionTemplate(TokenType tokenType) {
this.setTokenType(tokenType);
initCollections();
}

private void initCollections() {
setRequiredClaims(new ArrayList<TokenClaim>());
setAlternateVerificationKeys(new ArrayList<TokenVerificationKey>());
}

/**
* @return the audience
*/
Expand All @@ -62,7 +61,8 @@ public URI getAudience() {
}

/**
* @param audience the audience to set
* @param audience
* the audience to set
* @return this
*/
public TokenRestrictionTemplate setAudience(URI audience) {
Expand All @@ -78,7 +78,8 @@ public URI getIssuer() {
}

/**
* @param issuer the issuer to set
* @param issuer
* the issuer to set
* @return this
*/
public TokenRestrictionTemplate setIssuer(URI issuer) {
Expand All @@ -94,7 +95,8 @@ public TokenType getTokenType() {
}

/**
* @param tokenType the tokenType to set
* @param tokenType
* the tokenType to set
* @return this
*/
public TokenRestrictionTemplate setTokenType(TokenType tokenType) {
Expand All @@ -110,7 +112,8 @@ public TokenVerificationKey getPrimaryVerificationKey() {
}

/**
* @param primaryVerificationKey the primaryVerificationKey to set
* @param primaryVerificationKey
* the primaryVerificationKey to set
* @return this
*/
public TokenRestrictionTemplate setPrimaryVerificationKey(TokenVerificationKey primaryVerificationKey) {
Expand All @@ -126,7 +129,8 @@ public List<TokenClaim> getRequiredClaims() {
}

/**
* @param requiredClaims the requiredClaims to set
* @param requiredClaims
* the requiredClaims to set
* @return this
*/
public TokenRestrictionTemplate setRequiredClaims(List<TokenClaim> requiredClaims) {
Expand All @@ -142,14 +146,15 @@ public List<TokenVerificationKey> getAlternateVerificationKeys() {
}

/**
* @param alternateVerificationKeys the alternateVerificationKeys to set
* @param alternateVerificationKeys
* the alternateVerificationKeys to set
* @return this
*/
public TokenRestrictionTemplate setAlternateVerificationKeys(List<TokenVerificationKey> alternateVerificationKeys) {
this.alternateVerificationKeys = alternateVerificationKeys;
return this;
}

/**
* @return the alternateVerificationKeys
*/
Expand All @@ -158,12 +163,14 @@ public OpenIdConnectDiscoveryDocument getOpenIdConnectDiscoveryDocument() {
}

/**
* @param alternateVerificationKeys the alternateVerificationKeys to set
* @param alternateVerificationKeys
* the alternateVerificationKeys to set
* @return this
*/
public TokenRestrictionTemplate setOpenIdConnectDiscoveryDocument(OpenIdConnectDiscoveryDocument openIdConnectDiscoveryDocument) {
public TokenRestrictionTemplate setOpenIdConnectDiscoveryDocument(
OpenIdConnectDiscoveryDocument openIdConnectDiscoveryDocument) {
this.openIdConnectDiscoveryDocument = openIdConnectDiscoveryDocument;
return this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ private TokenRestrictionTemplateSerializer() {
}

public static String serialize(TokenRestrictionTemplate template) throws JAXBException {
validateTokenRestrictionTemplate(template);

validateTokenRestrictionTemplate(template);

StringWriter writer = new StringWriter();
JAXBContext context = JAXBContext.newInstance(TokenRestrictionTemplate.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty("com.sun.xml.bind.namespacePrefixMapper", new NamespacePrefixMapper() {
@Override
public String[] getPreDeclaredNamespaceUris() {
return new String[] { XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI };
return new String[] {
XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
};
}

@Override
Expand All @@ -65,7 +67,7 @@ public String getPreferredPrefix(String namespaceUri, String suggestion, boolean
}

private static void validateTokenRestrictionTemplate(TokenRestrictionTemplate template) {
if (template.getPrimaryVerificationKey() == null && template.getOpenIdConnectDiscoveryDocument() == null) {
if (template.getPrimaryVerificationKey() == null && template.getOpenIdConnectDiscoveryDocument() == null) {
throw new IllegalArgumentException(
ErrorMessages.PRIMARY_VERIFICATIONKEY_AND_OPENIDCONNECTDISCOVERYDOCUMENT_ARE_NULL);
}
Expand All @@ -86,10 +88,10 @@ private static void validateTokenRestrictionTemplate(TokenRestrictionTemplate te
if (!openIdDiscoveryUrlValid) {
throw new IllegalArgumentException(ErrorMessages.OPENIDDISCOVERYURI_STRING_IS_NOT_ABSOLUTE_URI);
}
}
}
}
}

public static TokenRestrictionTemplate deserialize(String xml) throws JAXBException {
public static TokenRestrictionTemplate deserialize(String xml) throws JAXBException {
try {
return deserialize(xml, null);
} catch (SAXException e) {
Expand All @@ -108,7 +110,7 @@ public static TokenRestrictionTemplate deserialize(String xml, String validation
u.setSchema(schema);
}
TokenRestrictionTemplate template = (TokenRestrictionTemplate) u.unmarshal(new StringReader(xml));
validateTokenRestrictionTemplate(template);
validateTokenRestrictionTemplate(template);
return template;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.microsoft.windowsazure.services.media.implementation.templates.widevine;

public enum AllowedTrackTypes {
SD_ONLY,
SD_HD
SD_ONLY, SD_HD
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,76 @@
package com.microsoft.windowsazure.services.media.implementation.templates.widevine;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

public class ContentKeySpecs {
/**
* A track type name.
*/
@JsonProperty
public String track_type;

/**
* Unique identifier for the key.
*/
@JsonProperty
public String key_id;

/**
* Defines client robustness requirements for playback.
* 1 - Software-based whitebox crypto is required.
* 2 - Software crypto and an obfuscated decoder is required.
* 3 - The key material and crypto operations must be performed
* within a hardware backed trusted execution environment.
* 4 - The crypto and decoding of content must be performed within
* a hardware backed trusted execution environment.
* 5 - The crypto, decoding and all handling of the media (compressed
* and uncompressed) must be handled within a hardware backed trusted
* execution environment.
*/
@JsonProperty
public Integer security_level;

/**
* Indicates whether HDCP V1 or V2 is required or not.
*/
@JsonProperty
public RequiredOutputProtection required_output_protection;
public class ContentKeySpecs {
/**
* A track type name.
*/
@JsonProperty("track_type")
private String trackType;

/**
* Unique identifier for the key.
*/
@JsonProperty("key_id")
private String keyId;

/**
* Defines client robustness requirements for playback. 1 - Software-based
* whitebox crypto is required. 2 - Software crypto and an obfuscated
* decoder is required. 3 - The key material and crypto operations must be
* performed within a hardware backed trusted execution environment. 4 - The
* crypto and decoding of content must be performed within a hardware backed
* trusted execution environment. 5 - The crypto, decoding and all handling
* of the media (compressed and uncompressed) must be handled within a
* hardware backed trusted execution environment.
*/
@JsonProperty("security_level")
private Integer securityLevel;

/**
* Indicates whether HDCP V1 or V2 is required or not.
*/
@JsonProperty("required_output_protection")
private RequiredOutputProtection requiredOutputProtection;

@JsonProperty("track_type")
public String getTrackType() {
return trackType;
}

@JsonProperty("track_type")
public void setTrackType(String trackType) {
this.trackType = trackType;
}

@JsonProperty("key_id")
public String getKeyId() {
return keyId;
}

@JsonProperty("key_id")
public void setKeyId(String keyId) {
this.keyId = keyId;
}

@JsonProperty("security_level")
public Integer getSecurityLevel() {
return securityLevel;
}

@JsonProperty("security_level")
public void setSecurityLevel(Integer securityLevel) {
this.securityLevel = securityLevel;
}

@JsonProperty("required_output_protection")
public RequiredOutputProtection getRequiredOutputProtection() {
return requiredOutputProtection;
}

@JsonProperty("required_output_protection")
public void setRequiredOutputProtection(RequiredOutputProtection requiredOutputProtection) {
this.requiredOutputProtection = requiredOutputProtection;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.microsoft.windowsazure.services.media.implementation.templates.widevine;

public enum Hdcp {
HDCP_NONE,
HDCP_V1,
HDCP_V2
HDCP_NONE, HDCP_V1, HDCP_V2
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
import com.fasterxml.jackson.annotation.JsonProperty;

public class RequiredOutputProtection {
/**
* Indicates whether HDCP is required.
*/
@JsonProperty
public Hdcp hdcp;
/**
* Indicates whether HDCP is required.
*/
@JsonProperty("hdcp")
private Hdcp hdcp;

@JsonProperty("hdcp")
public Hdcp getHdcp() {
return hdcp;
}

@JsonProperty("hdcp")
public void setHdcp(Hdcp hdcp) {
this.hdcp = hdcp;
}
}
Loading

0 comments on commit 9b9cb2a

Please sign in to comment.