When trying a HTTP local execution to an device from a Google Nest hub, the hub restarts. Fullfillment, Discovery and identify are OK. The code used :
const deviceCommand = new smarthome.DataFlow.HttpRequestData();
deviceCommand.data = "";
deviceCommand.deviceId = device.id;
deviceCommand.isSecure = false;
deviceCommand.method = smarthome.Constants.HttpOperation.GET;
deviceCommand.port = 80;
deviceCommand.protocol = smarthome.Constants.Protocol.HTTP;
deviceCommand.requestId = executeRequest.requestId;
deviceCommand.path = "http://192.168.1.10/json.htm?command=On";
Thanks for any advice.
Fixed by using deviceCommand.path = "/json.htm?Command=On"
You should not include the entire target URL in the path argument, just the path portion. The DeviceManager API knows the target address of the device based on the deviceId and will construct the proper URL.
I would expect your command should look more like this (note I also removed a few extra properties you shouldn't need to include):
const deviceCommand = new smarthome.DataFlow.HttpRequestData();
deviceCommand.deviceId = device.id;
deviceCommand.isSecure = false;
deviceCommand.method = smarthome.Constants.HttpOperation.GET;
deviceCommand.port = 80;
deviceCommand.requestId = executeRequest.requestId;
deviceCommand.path = "/json.htm?Command=On";
Related
On making a SAML request the port number (443) is being stripped out of the Destination. I understand this is default behaviour of the URI object. However the SAML identity provider requires the destination includes the port number for validation.
How can I get the SAML builder to include the port? 443 is being stripped from https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso (see below)
Saml2Configuration samlconfig = GetSAMLConfig();
var samlRequest = new Saml2AuthnRequest(samlconfig);
samlRequest.AssertionConsumerServiceUrl = new Uri(_appConfiguration["Saml2:AssertionConsumerServiceUrl"]);
samlRequest.Destination = new Uri(_appConfiguration["Saml2:SingleSignOnDestination"]); // https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso
samlRequest.NameIdPolicy = new NameIdPolicy()
{
AllowCreate = false,
Format = "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
SPNameQualifier = _appConfiguration["Saml2:SPNameQualifier"]
};
samlRequest.Conditions = new Condition();
samlRequest.Conditions.Items = new List<ITfoxtec.Identity.Saml2.Schemas.Conditions.ICondition>();
samlRequest.Conditions.Items.Add(new ITfoxtec.Identity.Saml2.Schemas.Conditions.AudienceRestriction() { Audiences = new List<Audience>() { new Audience() { Uri = _appConfiguration["Saml2:AllowedAudienceUris"] } } });
var bnd = binding.Bind(samlRequest);
It is possible to change the destination URL after the ToActionResult method has been called if you are using a Saml2RedirectBinding. And thereby overriding the default behavior.
Like this:
var action = binding.ToActionResult() as RedirectResult;
action.Url = action.Url.Replace("https://sit-api.eat.xxxxxx.xxxx.xx/samlsso", "https://sit-api.eat.xxxxxx.xxxx.xx:443/samlsso");
return action;
everyone.
I am trying to override dns resolver settings in my iOS app.
I used NEVPNManager to install a personal vpn and then used onDemandRules to set specific dns servers.
So far my code works for some domains.
Below is my code.
When I put "*.com" in matchDomains, it works perfectly.
But what I want to do is to redirect all dns queries to specific dns server.
I tried empty matchDomains([]) and empty string([""]).
I also tried wildcard expression like ["*"] and ["*.*].
So far I had no success.
It's been a few days and I still can't figure it out.
Can anybody tell me what I am missing here?
Thanks in advance.
let manager = NEVPNManager.sharedManager()
manager.loadFromPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in loading preferences : \(vpnError)")
return
}
if manager.protocolConfiguration == nil {
let myIPSec = NEVPNProtocolIPSec()
myIPSec.username = "username"
myIPSec.serverAddress = "server address"
myIPSec.passwordReference = self.getPersistentRef()
myIPSec.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
myIPSec.sharedSecretReference = self.getPersistentRef()
myIPSec.useExtendedAuthentication = true
manager.protocolConfiguration = myIPSec
manager.localizedDescription = "myDNS"
let evaluationRule = NEEvaluateConnectionRule(matchDomains: ["*.com"], andAction: NEEvaluateConnectionRuleAction.ConnectIfNeeded)
evaluationRule.useDNSServers = ["XXX.XXX.XXX.XXX"]
let onDemandRule = NEOnDemandRuleEvaluateConnection()
onDemandRule.connectionRules = [evaluationRule]
onDemandRule.interfaceTypeMatch = NEOnDemandRuleInterfaceType.Any
manager.onDemandRules = [onDemandRule]
manager.onDemandEnabled = true
manager.enabled = true
manager.saveToPreferencesWithCompletionHandler { error in
if let vpnError = error {
print("vpn error in saving preferences : \(vpnError)")
return
}
}
}
}
I found this is buggy in even the latest iOS (10.3.1) and using NEVPNProtocolIKEv2. One moment it works, the next moment it doesn't want to start a VPN connection because it seems to misinterpret the ondemand rules and gives the error back saying the VPN profile is not enabled. I ended up with configuring the IKEv2 server (Strongswan) to push DNS settings with the "rightdns" option in /etc/ipsec.conf. This gives me the desired result of having the DNS requests redirected to a custom resolver.
I am trying to get presigned url for these music files from amazon server , I have working code of android but couldn't find a way in Objective-C to do this.
public static String getPreSignedURL(String url) {
java.util.Date expiration = new java.util.Date();
long msec = expiration.getTime();
msec += 1000 * 60 * 5; // 5 minutes
expiration.setTime(msec);
AWSCredentials myCredentials = new BasicAWSCredentials(
AppConstants.AWS_ACCESS_KEY_ID, AppConstants.AWS_SECRET_KEY_ID);
AmazonS3 s3client = new AmazonS3Client(myCredentials);
s3client.setEndpoint(AppConstants.ENDPOINT_S3);
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(
AppConstants.BUCKET_NAME, url.replace(AppConstants.OBJECT_NAME_FILTER, ""));
request.setExpiration(expiration);
URL objectURL = s3client.generatePresignedUrl(request);
return objectURL.toString();
}
This above code is in android.
var presignedUrl: AWSTask = AWSTask()
let expiration = NSDate().dateByAddingTimeInterval(5*60)
let credential = AWSStaticCredentialsProvider.init(accessKey: AWS_ACCESS_KEY_ID, secretKey: AWS_SECRET_KEY_ID)
let configuration = AWSServiceConfiguration.init(region:.USEast1, credentialsProvider: credential)
//print("%#",configuration.endpoint)
//let regionTp = AWSRegionType(s)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
let urlBuilder = AWSS3PreSignedURLBuilder.defaultS3PreSignedURLBuilder()
let preSignedURLRequest = AWSS3GetPreSignedURLRequest.init()
preSignedURLRequest.key = "10488/01-New_Jack_City_hq.mp3"
preSignedURLRequest.bucket = "damixhub"
preSignedURLRequest.expires = expiration
preSignedURLRequest.HTTPMethod = .GET
presignedUrl = urlBuilder.getPreSignedURL(preSignedURLRequest)
This is what I am doing in ios till now but urls have significant difference and I get accessdenied error possibly because I havent mentioned custom end points.
Please let me know if you know solution to this.
I managed to get this using version 1 of amazon sdk.
Just write pod "AWSiOSSDK" if you are using cocoa pods , if you want to do it manually then you need to get it from github get it here
Note - As amazon doesnt provide this functionality in version 2 of sdk I have to use this deprecate version.
We are using Rotativa in a .Net MVC 5 project. it works like a charm locally and fails (generates a blank PDF) equally when deployed to server. However, if I login to server and access the website as localhost it generates PDF just fine.
So it looked like a permission issue with which Application pool is running on. So, for testing purpose, I changed to run the App Pool to run on "Local System". Still same issue.
We have also tried:
"ViewasPDF"
App settings which looks like: <add key="WkhtmltopdfPath" value="<path to the folder>"/>
Below is the code:
return new ActionAsPdf("ActionMethod",new { id = id, partSelected = part, selectedTab = selectedTab, isDownload = true })
{
FileName = fileName,
PageMargins = { Left = 0, Right = 0 },
CustomSwitches = "--disable-external-links --disable-internal-links --disable-smart-shrinking --viewport-size 1600x900 --load-error-handling ignore",
PageOrientation = Rotativa.Options.Orientation.Portrait,
PageSize = Rotativa.Options.Size.A4,
PageWidth = 210,
PageHeight = 297
};
First, you have disabled displaying error with the custom switch --load-error-handling ignore. It might help to not have it disabled temporarily for the purpose of debugging.
Secondly, a blind guess from me is that you may have some images that require local path as src on the pdf? If that's the case you will need #Server.MapPath for each one of those.
For example:
<img src="#Server.MapPath("your image path")"/>
var iResult = new Rotativa.ActionAsPdf("PrintForm", new { Id = Id }) { FileName = iFilename, SaveOnServerPath = ViewBag.FileName };
iResult.UserName = System.Configuration.ConfigurationManager.AppSettings["ADUserID"].ToString();
iResult.Password = System.Configuration.ConfigurationManager.AppSettings["ADPassword"].ToString();
return iResult;
Here is a code example where aduser is user name and password, please create a generic user account for this..
I'm trying to save a record like so:
var testRecord = new SecRecord(SecKind.GenericPassword)
{
CreationDate = DateTime.UtcNow,
MatchCaseInsensitive = false,
Service = "MyService",
Label = "MyService",
Account = "User",
Generic = NSData.FromString("test", NSStringEncoding.UTF8),
};
SecKeyChain.Add(testRecord);
...but I'm getting SecStatusCode.Param back when I run it in the simulator. According to the documentation, that code means "Invalid or incomplete parameters passed" but I don't see anything missing or unusual that others aren't doing with apparent success.
Even adding CreationDate, Invisible, Description, Comment, Accessible, and ValueData properties to the SecRecord (some as in this example) didn't help -- still getting SecStatusCode.Param.
Are there any non-obvious things that might cause a Param status code to be returned?
I had a lot of trouble trying to use the keychain. I finally got mine working to store user credentials in the app. Here is what I have:
SecRecord existingRec = new SecRecord (SecKind.GenericPassword) {
Service = Keychain.USER_SERVICE,
Label = Keychain.USER_LABEL
};
var record = new SecRecord (SecKind.GenericPassword) {
Service = Keychain.USER_SERVICE,
Label = Keychain.USER_LABEL,
Account = username,
ValueData = NSData.FromString (password),
Accessible = SecAccessible.Always
};
SecStatusCode code = SecKeyChain.Add (record);
if (code == SecStatusCode.DuplicateItem) {
code = SecKeyChain.Remove (existingRec);
if (code == SecStatusCode.Success)
code = SecKeyChain.Add (record);
}
Keychain is a static class with constants so I don't have to retype the strings.
The only thing different between yours and mine is the CreationDate/MatchCaseInsensitive properties and the encoding for NSData. Maybe try it without those and see if it works? If so, add them back separately and see what gives the problem.
This might be because you are running on the simulator - in that case you need to add an Entitlements plist in the project options for your current build config in order to make keychain access work.