Externalizing Grails Datasource configuration

You can use a properties file specified in the grails.config.locations as a way to externalize the datasource configuration. Below is how I typically set up a Grails project: In my DataSource.groovy I specify this for the production environment: …. …. production { dataSource { dbCreate = “update” driverClassName = “com.myorg.jdbcDriverNotExists” url = “” username = … Read more

save PSCredential in the file

Update on non-Windows Platforms A lot has changed since this answer was first written. Modern versions of PowerShell are based on .net core, and run cross-platform. The underlying type that enables this whole answer is called [securestring] and the security and encryption that backs it comes from the Data Protection API (DPAPI) on Windows, which … Read more

How do I store and retrieve credentials from the Windows Vault credential manager?

Many thanks to @Luke for the hint: Windows API functions to store credentials to and read them from Windows Vault are CredWrite() and CredRead(). Here is a code sample that may be compiled and run, that I used to confirm that these functions indeed do the expected thing: #include <windows.h> #include <wincred.h> #include <wchar.h> #pragma … Read more

How to use UrlFetchApp with credentials? Google Scripts

This question has been answered on another else where. Here is the summary: Bruce Mcpherson basic authentication looks like this… var options = {}; options.headers = {“Authorization”: “Basic ” + Utilities.base64Encode(username + “:” + password)}; Lenny Cunningham //Added Basic Authorization////////////////////////////////////////////////////////////////////////////////////////// var USERNAME = PropertiesService.getScriptProperties().getProperty(‘username’); var PASSWORD = PropertiesService.getScriptProperties().getProperty(‘password’); var url = PropertiesService.getScriptProperties().getProperty(‘url’);//////////////////////////Forwarded Ports to WebRelay … Read more

HttpWebRequest using Basic authentication

You can also just add the authorization header yourself. Just make the name “Authorization” and the value “Basic BASE64({USERNAME:PASSWORD})” var username = “abc”; var password = “123”; string encoded = System.Convert.ToBase64String(Encoding.GetEncoding(“ISO-8859-1”) .GetBytes(username + “:” + password)); httpWebRequest.Headers.Add(“Authorization”, “Basic ” + encoded); Edit Switched the encoding from UTF-8 to ISO 8859-1 per What encoding should I … Read more

What is the most appropriate way to store user settings in Android application

In general SharedPreferences are your best bet for storing preferences, so in general I’d recommend that approach for saving application and user settings. The only area of concern here is what you’re saving. Passwords are always a tricky thing to store, and I’d be particularly wary of storing them as clear text. The Android architecture … Read more