KotlinMultiplatform Cannot access 'kotlin.Cloneable' - kotlin-multiplatform

How can I use the "Mac" encryption class in the shared Kotlin Multiplatform module? When I try this I see the error "Cannot access 'kotlin.Cloneable' which is a supertype of 'javax.crypto.Mac'. Check your module classpath for missing or conflicting dependencies"
enter image description here
If you know another way to encrypt the string with the "HmacSHA512" algorithm using the key I would be very happy to see your way!

Related

Get access to yaml external file in Thorntail

I want to get access to external YAML file which I specify through command-line argument:
java -jar target/app-thorntail.jar -s./test.yaml
This file I need to use to get my custom properties tree by SnakeYaml.
You can use #Inject #ConfigurationValue for your custom properties, and you can #Inject a ConfigView to read the entire configuration tree. I believe that should be enough for your usecase. This approach will also provide correct values in case multiple configuration files are used.
I'm not sure if you can get access to the file itself, except maybe provide a custom main method and parse the command-line arguments yourself.

"class" is ambiguous for type lookup in this context in Swift

I'm using pods in my project. When using Realm and permission libraries, I got error " "Permission" is ambiguous for type lookup in this context".
When I click on Permission in my method it's actually going to "Permission" Which is defined in realm.Check here.
But actually it should read the permission class from "Permission" Module. Check here
Now I came to know that it's name conflict. Two modules are using same name. I tried by referring (Modulename.classname) like Permission.permission.Still it's giving same error. So how to refer to class Which is in permission module.
Thanks..

unable to find `as` method in `Config`

I saw the following code snippet
val settings = configuration.underlying.as[CookieSecretSettings]("silhouette.oauth1TokenSecretProvider")
I believe configuration is of type play.api.Configuration and underlying is of typeConfig` (https://www.playframework.com/documentation/2.6.x/api/scala/index.html#play.api.Configuration)
I copied the code in my Apploader (as I am using Compile Time Injection). The BuiltInComponentsFromContext has a configuration variable. I thought to use that as follows val config = configuration.underlying.as[CookieAuthenticatorSettings]("silhouette.authenticator") but the compiler cannot resolve as. What am I doing wrong?
The Config library seem to have asInstanceOf instead of as but I get other errors if I use that. I notice that the code for which as works uses play version 2.4.2 while I am using 2.6.12.
I realize this is an old question, but I stumbled upon this exact problem today and couldn't find anything helpful.
The as method is provided by a third-party library (Ficus) to read case classes and Scala types from Typesafe config. You need to include it in your build dependencies, then add to imports:
import net.ceedubs.ficus.Ficus._
import net.ceedubs.ficus.readers.ArbitraryTypeReader._

Get config value from file, or environment variable if file doesn't exist

I'm trying to get a setting from a configuration file (preferably something simple like .ini or JSON, not XML). If the file or setting does not exist, I want to be able to fall back to retrieving an environment variable.
I'd prefer to use an existing library for working with JSON/INI and not parsing the file myself. However, most libraries I've found won't work if a file doesn't exist.
How would I access a configuration value from a file that may or may not exist in F#?
You can use File.Exists to test whether or not the file exists:
open System.IO
let getConfig file =
if File.Exists file
then "config from file"
else "config from somewhere else"
OpenExeConfiguration (despite it's name) can open an arbitrary config file.
There's also the ASP.NET vNext Configuration stuff, outlined in this article which is quite flexible - no idea how separable (or relevant to your actual use case) it is [aside from the fact that you could conditionally include the config file into the config manager depending on whether it exists a la Mark's answer].
In addition to type providers, FSharp.Data provides some basic parsers, including JSON. This allows you to do a runtime check using File.Exists and then parse using your preferred utility.
I took the following approach in FAKE:
if File.Exists "local.json" then
let localVarProps = JsonValue.Parse(File.ReadAllText"local.json").Properties
for key, jsonValue in localVarProps do
setEnvironVar key (jsonValue.AsString())

Embed the sample files of F# JsonProvider to use in a library

According to this, you can specify samples as embedded resources by using EmbeddedResource:
type Declaracion = JsonProvider<"declaracion.json", EmbeddedResource="Irpf.Hechos, declaracion.json">
But when I reference this library, "Irpf.Hechos.dll", I get a File Not Found error, the path ConsumingLibraryPath\declaracion.json is not found; typecheck error FS3033
I have tried to set the declaracion.json file as resource, and content, but no luck.
Am I missing some step?
You need to set the build action as "EmbeddedResource" rather than "Resource".

Resources