* Sighs *
Keep creating posts with similar meaning and you'll get downvoted quickly. Although we are here to help you, you could at least try using the search feature and also recompensate us by checking the correct answer.
- Log in to post comments
* Sighs *
Keep creating posts with similar meaning and you'll get downvoted quickly. Although we are here to help you, you could at least try using the search feature and also recompensate us by checking the correct answer.
My first idea is to use a captcha service straight from China.
Something like this:
http://www.yinxiangma.com/
Maybe if you use some flag to fallback to this service instead of reCaptcha when the consumer originates from mainland China.
The only issue is that you might need a translator for support.
There's no embedded or native way of doing so, due to, well... security concerns.
There're scripts and third party programs that allow you to do something close to it.
https://stackoverflow.com/questions/19098101/how-to-open-an-elevated-cm…
However, should you really be executing it with admin privileges? Why not make your executable accessible for your Caché user, so that you won't need to elevate your prompt?
No, you can't. Unless you ovewrite some methods from %CSP.REST, like DispatchMethod.
Even so, simply ovewritting it wouldn't give you data about arguments that your dispatch method received, you need to go further than that and modify the way the info about the route is generated.
I also had headaches with that, because the pattern generation algorithm simply replaces any :placeholder by it's regular expression group counterpart, e.g. for Route elements /:msg becomes /([^/]+), but there're some variations according to which element you use to define it: Map or Route.
When compile your class, a method generator runs and creates a DispatchMap that takes an index, this index contains info about your dispatch method, http method and pattern to match. This index is based on the order you defined each element.
However DispatchMap does not generate info about the name of the parameter affected, only their index, so you would need to parse it by opening the dispatch method's class %Dictionary.CompiledMethod and accessing each Property's FormalSpec and matching their index to find the name of the argument.
This is some of the reasons why I implemented this, because I found %CSP.REST very limited. And what you want is something that I call: Reporter. It's a an abstract module that runs custom implementations whenever a method ends abnormally. I already implemented a sample of it for reporting an error via e-mail.
EDIT: I just noticed that you want something to run for every request, regardless of success or error. I'll work on it.
You must notice two methods as declared here. These are the methods that should be implemented. After that you only need to register the setup class with your router class. If you want to see it quickly, just change the commented reporter to this one and configure your e-mail parameters.
Finally, you can use %OAuth2's JWT implementation to store info about your current user. I'd recommend you to read this tutorial to learn how to setup it.
And if you want to read more about how my implementation works, you can find it out here.
Are you trying to execute some binary outside Caché or is it related to your current Caché process? By the type of the value you used as example, I'm attempted to say it's related to the JVM. If so, you can set most of the values using the its command-line arguments, including the heap size.
If that's related to your current process, you could trying doing the inverse procedure and capture the values from a .env file instead, it seems you can't get freshly set env variables because for the OS the Caché is already a running process. Maybe you can work around it using by source 'ing a script file that sets it, but I haven't tried.
However, I'd still go with the .env file instead. I did a little utility sometime ago because I thought it would be useful someday
Hello, is that what you're looking for?
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCRNA
You might want to try using Port. It was made exactly for that purpose.
Just install the port-prod.xml and restart your Studio, note that this tool will takeover your current source control class.
After that, open your project, Source Control->Export. If your language is not supported, then you might need to change your current session to english using ##class(%MessageDictionary).SetSessionLanguage("en").
You should never attempt to filter the list manually (using $replace). Instead of that, if you already know what item you want to fetch then you can :
Use the $listfind to retrieve the index of the matching item inside your list and $listget to to finally fetch it.
set list = $listbuild("a","b","c")
set whatIWantToFind = "c"
set index = $listfind(list, "c") // returns the index 3.
write $listget(list, index) // returns "c".
If you don't know the content on that list, you can use $listlength to get the size of the list:
set list = $listbuild("a","b","c")
for i=1:1:$listlength(list) {
write $listget(list, i) // returns the current item at index i.
}
If you want extreme performance, then I'd suggest you to go with $listnext:
set pointer = 0
set list = $listbuild("a","b","c")
while $listnext(list, pointer, item) {
// Self-explanatory.
}
If you really want to filter the list separators, you can use $listtostring to do the opposite of $listfromstring that you used.
set list = $listbuild("a","b","c")
write $listtostring(list, "|") // "a|b|c"
Finally, you can also compare the list as whole using $listsame:
set list = $listbuild("a","b","c")
set listB = $listbuild("a", "b", "d")
set listC = $listbuild("a","b","c")
write $listsame(list, listB) // 0. False, because they're not the same.
write $listsame(list, listC) // 1. True, the values match.
Try sending the CreatedDate format like this, which is the format used by JSON serializers.
"2019-08-26T16:38:26.893Z"
If you don't want to hook Caché with another language using Caché Bindings, you should use PBKDF2 with SHA256. Otherwise you'll need some external implementation to use bcrypt.
write $System.Encryption.PBKDF2("secret", 15000, $System.Encryption.GenCryptRand(64), 64, 256)
Although IS should really implement bcrypt and Argon with native support.
You need to generate a SSL configuration and provide to your request object by using the SSLConfiguration property, after this you must also inform to your request that you want to use a secure connection by enabling the property Https.
Here's how we send a push using OneSignal:
set client = ##class(%Net.HttpRequest).%New()
set client.Server = "onesignal.com"
// You'll need to generate the configuration to be used below, you can decide its name.
set client.SSLConfiguration = "OneSignal SSL Config"
set client.Https = 1
set client.Authorization = $$$FormatText("Basic %1", $get(^App.Envs("ONESIGNAL_KEY")))
set client.ContentCharset = "utf-8"
set client.ContentType = "application/json"
set client.ContentEncoding = "utf-8"
set client.NoDefaultContentCharset = 0
set body = {
"app_id": ($get(^App.Envs("ONESIGNAL_APPID"))),
"data": (data),
"contents": {
"en": (message),
"pt": (message)
},
"filters": (filters)
}
set json = body.%ToJSON()
do client.EntityBody.Write(json)
set sc = client.Post("/api/v1/notifications")
return sc
You can generate that SSL configuration using the portal, you can also something like this:
ClassMethod CreateSSLConfigurationIfNoneExists(name As %String)
{
new $namespace
set $namespace = "%SYS"
do ##class(Security.SSLConfigs).Get(name, .p)
if $data(p) quit
set p("CipherList")="ALL:!aNULL:!eNULL:!EXP:!SSLv2"
set p("CAFile")=""
set p("CAPath")=""
set p("CRLFile")=""
set p("CertificateFile")=""
set p("CipherList")="ALL:!aNULL:!eNULL:!EXP:!SSLv2"
set p("Description")=""
set p("Enabled")=1
set p("PrivateKeyFile")=""
set p("PrivateKeyPassword")=""
set p("PrivateKeyType")=2
set p("Protocols")=24
set p("SNIName")=""
set p("Type")=0
set p("VerifyDepth")=9
set p("VerifyPeer")=0
do ##class(Security.SSLConfigs).Create(name, .p)
}
Check for the following methods:
FindInFiles and FindInFilesRegex.
Optionally you could limit the search for a single project using the method FindInProject.
All methods belong to the %Studio.Project class.
Here's how Atelier does:
Set tSC=##class(%Studio.Project).FindInFiles(
tSearch,
doclist,
system,
wholeword,
casesensitive,
max,
"GENERATED="_generated, // filter
wildcards
)
But you'll need to use device redirection to capture and parse its content. Because Studio uses these methods to display the results in the Output window.
Looks like there's a pvaoref property that points to the original instance as you can see below:
Method %OnNew(oref As %Library.DynamicAbstractObject) As %Status [ Private, ProcedureBlock = 1, ServerOnly = 1 ]
{
set i%pointer = -1
set ..pvaoref = oref
return $$$OK
}
And it seems to work:
USER>set a = []
USER>set it = a.%GetIterator()
USER>w it.pvaoref
1@%Library.DynamicArray
USER>
I think it is:
write %request.GetCgiEnv("HTTP_APPLICATION_ID")
Although by convention, custom headers should begin with a X character to avoid possible conflicts with future but spec-based implementations.
Sorry for taking so long to reply, here's the result from one line:
DEV2>Zw line
line=$c(9,9,9)_"title: 'Erro de aplicação',"
DEV2>zzdump line
0000: 09 09 09 74 69 74 6C 65 3A 20 27 45 72 72 6F 20 ...title: 'Erro
0010: 64 65 20 61 70 6C 69 63 61 C3 A7 C3 A3 6F 27 2C de aplicação'
Just so you know, my Caché terminal is configured to output using UTF-8 already.
Neither alternatives. I'd usually archive the repository instead.
Try defining these settings and see if that solves your issue.
set httpRequest.ContentCharset = "utf-8"
set httpRequest.ContentType = "application/json"
set httpRequest.ContentEncoding = "utf-8"
set httpRequest.NoDefaultContentCharset = 0 // Specifically this one.
Is your Caché unicode?
Can you try reading the content of headings.en right before you send it? So that we can see see if that's already corrupted before the HttprRequest takes control or if it's corrupting the input.
I might have to check the IRIS version, because my Caché 2018 doesn't have any traces of the DispatchClass configuration.
Method CSPApplication(
pUrl As %String,
pNamespace As %String,
pDescription As %String,
pDirectory As %String,
pResource As %String,
pRecurse As %String,
pLoginClass As %String,
pGrant As %String,
pCookiePath As %String,
pAuthMethods As %Integer,
pLockCSPName As %Boolean,
pEventClass As %String,
pDefaultTimeout As %Integer,
pDefaultSuperclass As %String,
pUseSessionCookie As %Integer,
pServeFiles As %Boolean,
pServeFilesTimeout As %Integer,
pCustomErrorPage As %String,
pPackageName As %String,
pChangePasswordPage As %String,
pGroupById As %String = "",
pCspZenEnabled As %Boolean = 1,
pInboundWebServicesEnabled As %Boolean = 1,
pTwoFactorEnabled As %Boolean = 0,
pIsNameSpaceDefault As %Boolean = 0,
pPermittedClasses As %String = "",
pAutoCompile As %Boolean = 1) [ Internal ]
Can I use the ZPM client like a standalone the same way it works when using the %Installer manifest? Bu that I mean, just calling the ZPM to parse the manifest and install it without relying on the registry and the CLI for now, because all the code I want to import is already local, I just need to create a web application that uses the DispatchClass property.
Yeah, I just noticed it now: https://docs.intersystems.com/csp/documatic/%25CSP.Documatic.cls?PAGE=CLASS&LIBRARY=%25SYS&CLASSNAME=%25Installer.CSPApplication
EDIT: I'll make some tests and see if it works fine. I'll report back for you if it does.
Looks like the new version of the %Installer for IRIS already supports this setting.
But it might still be helpful to clear that question about the ZPM for other circunstances.
From your code above I see that you attempted to use both Directory and DispatchClass attributes. Have you tried removing the Directory attribute?
Indeed, I got this error too. However if I use a dummy directory it accepts.
I haven't used this feature yet because I must change plenty of things to actually consume that REST application. But the way I'm seeing things so far I guess it would work.
So what if you provide a dummy directory like: "/tmp/dummycsp" as well?
This one unexpectedly displays the #ERROR part though.
Yep, this one works fine as long as you don't embed another error using $$$ADDSC or $$$EMBEDSC.
Ahh, yes, it could be used that way too.
Either way, basically only the schema is supporting the DispatchClass, the engine itself doesn't, making it looks like a feature that's in development. So I'm sure that will get this feature on the near future.
Well... here's how I did it:
https://github.com/rfns/iris-ci/blob/master/ci/App/Installer.cls