playready license server request only get - samsung-smart-tv

I use the following implementation for PlayReady on Samsung Smart TV SDK 3.5 & 4.x.
Now, in my network traces I see a plain GET Request to the license server URL being executed, but no data passed.
What could be the cause for this?
This is my code:
var VideoURL = '.........bution_deu_20_9000K.ism/Manifest';
var serverLicense = '...LicenseAcquisition.asmx';
var customData = '.....';
player.InitPlayer(VideoURL+"|COMPONENT=WMDRM");// + "|COMPONENT=WMDRM"
player.SetPlayerProperty(4, serverLicense, serverLicense.length);
player.SetPlayerProperty(3, customData, customData.length);
player.StartPlayback();
Thanks

Related

Jwt Security Token HoloLens 2

We are trying to implement an authentication system using JWT Security Tokens on HoloLens 2.
We are using:
Unity 2020.3.28
OpenXR
NuGet Packages:
Microsoft.IdentityModel.JsonWebTokens, v. 6.15.1
Microsoft.IdentityModel.Logging, v. 6.15.1
Microsoft.IdentityModel.Tokens, v. 6.15.1
System.IdentityModel.Tokens.Jwt, v. 6.15.1
Newtonsoft.Json, v. 11.0.2
When receiving the answer from the server we parse it into a JwtSecurityToken using this code snippet:
Debug.Log($"signInResul: {signInResult.IdentityToken}");
var stream = signInResult.IdentityToken;
var handler = new JwtSecurityTokenHandler();
var jsonToken = handler.ReadToken(stream);
Debug.Log($"jsonToken: {jsonToken}");
var tokenS = jsonToken as JwtSecurityToken;
Where the signInResult is the Server answer, and we can also output that the response comes in the correct way.
Now within Unity the parsing happens without any problems, once switching to the HoloLens it doesn't work anymore.
We receive the same answer as within the Unity environment, but the code stops on the line with var handler = new JwtSecurityTokenHandler(); or var jsonToken = handler.ReadToken(stream);, since we never get to Debug.Log($"jsonToken: {jsonToken}");.
Does anybody have experience with Jwt on HoloLens and might know where the issue could lies?
Thanks for the help

Receiving a TypeError for UDP scan data

Using the Local Home SDK developer preview for Google Assistant, I'm receiving a TypeError from my application during IDENTIFY that was previously working correctly. The error is claiming that UdpScanData is not a valid string when I try to decode the payload.
Example code:
const device = identifyRequest.inputs[0].payload.device;
const response = Buffer.from(device.udpScanData, "hex");
How do I access the UDP discovery payload?
In the 0.2.0 update to the developer preview SDK, we have migrated the UdpScanData parameter to be an interface instead of just a type alias for string (see the updated reference docs) to improve consistency with the other scan data types.
To access the response payload for a UDP scan in the latest SDK, update your package.json dependencies to use v0.2.0:
{
...
"dependencies": {
"#google/local-home-sdk": "^0.2.0"
}
}
Then, access the payload using the new data property:
const device = identifyRequest.inputs[0].payload.device;
const scanData = device.udpScanData;
const response = Buffer.from(scanData.data, "hex");

HttpWebRequest.GetRequestStream() is not working in MS Dynamics CRM Plugin

I have written a plugin wherein I am trying to get an XML response.
This is my code :
// Set the Method property of the request to POST.
string strXMLServer = "xxx";
var request = (HttpWebRequest)WebRequest.Create(strXMLServer);
request.Method = "POST";
// Set the ContentType property of the WebRequest.
request.ContentType = "xyz";
// Assuming XML is stored in strXML
byte[] byteArray = Encoding.UTF8.GetBytes(strXML);
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
//(LINE 5) Get the request stream
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
This code works fine when its written in a console application. But when I copy the same code to a class library(plugin) and tries to debug it using plugin profiler, the application gets stopped abruptly when it reaches (LINE 5)
i.e. At Stream dataStream = request.GetRequestStream();
request.GetRequestStream() function is not working with plugin, but works fine within a console.
Any help would be appreciated :)
Thanks in advance
Note: I am using Dynamics 365 online trial version
There are a couple of things to take into consideration when building a plugin with web requests. Firstly, you need to use WebClient as it's widely supported by Microsoft products.
Secondly, your URL needs to be a DNS name and not an IP address, as this is a hosted plugin in sandbox mode.
Example from Microsoft's website: https://msdn.microsoft.com/en-us/library/gg509030.aspx
Reading material: https://crmbusiness.wordpress.com/2015/02/05/understanding-plugin-sandbox-mode/

Azure IOT Hub Rest API Unauthorized

I am trying to use Azure Iot hub REST API to create device by following links
Create a new device identity
Control access to IoT Hub
And my http data is like
{
"status":"connected",
"authentication":{ "symmetricKey":{
"primaryKey":"key in shared access policies",
"secondaryKey":"key in shared access policies"}
},
"statusReason":"reason",
"deviceId":"test123"
}
My header is like
["Content-Type": "application/json", "Authorization": "SharedAccessSignature sig=(key in shared access policies public key)=&se=1481687791&skn=iothubowner&sr=(my iot hub name).azure-devices.net%2fdevices%2ftest123"]
But i get error 401
{"Message":"ErrorCode:IotHubUnauthorizedAccess;Unauthorized","ExceptionMessage":"Tracking ID:(tracking id )-TimeStamp:12/14/2016 03:15:17"}
Anyone know how to fixed it , or to track the exceptionMessage ?
The problem of 401 is, probably, in the way you are calculating the SAS.
The full process to calculate a SAS for the IoT Hub (in C#) is:
private static readonly DateTime epochTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
public static string SharedAccessSignature(string hostUrl, string policyName, string policyAccessKey, TimeSpan timeToLive)
{
if (string.IsNullOrWhiteSpace(hostUrl))
{
throw new ArgumentNullException(nameof(hostUrl));
}
var expires = Convert.ToInt64(DateTime.UtcNow.Add(timeToLive).Subtract(epochTime).TotalSeconds).ToString(CultureInfo.InvariantCulture);
var resourceUri = WebUtility.UrlEncode(hostUrl.ToLowerInvariant());
var toSign = string.Concat(resourceUri, "\n", expires);
var signed = Sign(toSign, policyAccessKey);
var sb = new StringBuilder();
sb.Append("sr=").Append(resourceUri)
.Append("&sig=").Append(WebUtility.UrlEncode(signed))
.Append("&se=").Append(expires);
if (!string.IsNullOrEmpty(policyName))
{
sb.Append("&skn=").Append(WebUtility.UrlEncode(policyName));
}
return sb.ToString();
}
private static string Sign(string requestString, string key)
{
using (var hmacshA256 = new HMACSHA256(Convert.FromBase64String(key)))
{
var hash = hmacshA256.ComputeHash(Encoding.UTF8.GetBytes(requestString));
return Convert.ToBase64String(hash);
}
}
If you want to create the device in the IoTHub you have to have a policy with full permissions that mean:
Registry read and write, Service connect and Device connect.
If you need a full functional example, in C#, about how use the IoT Hub REST API to create a device, check if a device exists and send messages to the IoT Hub I have wrote this post about it (the post is in spanish but I can imagine that what you need is just the code).
it looks like your SAS is wrong. It shouldn't include the devices part in the end. If you open the Iot Hub Device Explorer you can Generate SAS token to access the Iot Hub API. You should create the SAS for the IoT hub level and for a device level (which include the devive id in the SAS like you have).
So your SAS should look like this -
SharedAccessSignature sr={iot hub name}.azure-devices.net&sig={sig}&se={se}&skn=iothubowner
There are two edits you need to do:
In your http data, only deviceId is required, other are optional, you can do it like this:
{
deviceId: "test123"
}
Note that there are no double quotes around deviceId.
Like #shachar said, you need remove "%2fdevices%2ftest123" in SAS token of the header. About generating SAS token you can utilize Device Explorer.
This is my test result:
The format of SAS token you use is wrong. To create a device, you need to use SAS Token for IoT Hub. You could easily use Azure IoT Toolkit extension for Visual Studio Code to generate SAS Token for IoT Hub as below screenshot.
BTW, the format of SAS token for device is /^SharedAccessSignature sr=iot-hub-test.azure-devices.net%2Fdevices%2Fdevice1&sig=.+&se=.+$/, while the format of SAS token for IoT Hub is /^SharedAccessSignature sr=iot-hub-test.azure-devices.net&sig=.+&skn=iothubowner&se=.+$/
//Following code is to generate the SAS token programatically.
string sasToken = new SharedAccessSignatureBuilder()
{ KeyName = name,
Key = key,
Target = target,
TimeToLive = TimeSpan.FromDays(days)
}.ToSignature();
//use this sas token as authorization header before calling the iot restapi

Facebook Registration | Custom Fields Not Returning

I'm attempting to create a Facebook Registration process for our website that will create an account for the user in our CRM - to this end I require the use of a few custom fields in the registration form.
I have the registration form appearing properly on the site, however, when I process the signed_request the JSON only returns the decoded standard items and not my custom fields:
{
"algorithm": "HMAC-SHA256",
"code": "2.AQDp0sgWRw3TWrII.3600.1330650000.1100001862544007|LwjvMjADtPxaIzxizYuIivNdi7w",
"issued_at": 1330644064,
"user_id": "<my user id>"
}
This is a .NET implementation but I am not using the Facebook C# SDK as none of the documentation seems to be available anymore on their site and I'm just not clever enough to figure it out. I tried using the new 6.x beta of the Facebook C# SDK and the Facebook.Client() parse method but didn't have any luck determining what to do with it once the thing was parsed.
So - this stolen code is what I used to get the results posted above:
//client_payload = the signed_request from Facebook
string[] sB64String = client_payload.Split('.');
string payload = client_payload.Replace((sB64String[0] + "."), string.Empty);
var encoding = new UTF8Encoding();
var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/');
var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '='));
var json = encoding.GetString(base64JsonArray);
var jObject = JObject.Parse(json);
response.write(Convert.ToString(jObject)); // rw for debugging
Maybe I'm missing something?
I've resolved this on my own by modifying the way I was going about it.
I ended up using the tag and client side cookie as found here:
https://developers.facebook.com/docs/plugins/registration/advanced/
All of my custom fields end up in the cookie that I can then parse and send to my .NET webservice. Kind of a round-about way of doing it but it's getting the job done now.