microsoft / credential-secure-storage-for-java Goto Github PK
View Code? Open in Web Editor NEWSecure storage for credentials in platform-provided credential managers.
License: MIT License
Secure storage for credentials in platform-provided credential managers.
License: MIT License
Thanks for implementing this library, it's really useful! π
I have bumped into a small issue while using it on Mac: if the username or the password contains any special characters, they are not stored and retrieved correctly. E.g. if I store the username "tΓ€st", it retrieves this string: 0x74C3A47374 "t\303\244st
My macOS version is Sonoma 14.0.
Here is the code that I use to store the credentials:
fun storeAccount(accountKey: String, urlKey: String, settings: ServerConfiguration) {
val credentialStorage = StorageProvider.getCredentialStorage(true, StorageProvider.SecureOption.REQUIRED)
val storedSettings = Settings()
if (settings.url.isEmpty()) {
storedSettings.remove(urlKey)
credentialStorage.delete(accountKey)
return
}
storedSettings.putString(urlKey, settings.url)
if (settings.username.isEmpty()) {
credentialStorage.delete(accountKey)
return
}
val credentialsToStore = StoredCredential(settings.username, settings.password.toCharArray())
credentialStorage.add(accountKey, credentialsToStore)
}
This is used to load them:
fun getAccount(accountKey: String, urlKey: String): ServerConfiguration {
val storedSettings = Settings()
val url = storedSettings.getString(urlKey, "")
val credentialStorage = StorageProvider.getCredentialStorage(true, StorageProvider.SecureOption.REQUIRED)
val credential: StoredCredential? = credentialStorage.get(accountKey)
val username = credential?.username ?: ""
val password = (credential?.password ?: CharArray(0)).joinToString("")
return ServerConfiguration(url, username, password)
}
I also tested on Windows and there it worked without issues. (Not sure about Linux as I didn't manage to get it running at all due to some strange NPEs, I'm still looking into that.)
If execute the sample from power shell like:
java -jar <JAR_FILE> works ok
But if execute the same jar file as a windows service I can't recover the same credentials.
What is the problem?
Can the team please review the Azure SDK Guidelines for Java Libraries, and identify what needs to be addressed to bring consistency with the other Azure SDKs already published on Maven Central?
Is this project still maintained?
I'm glad to see this was extracted from https://github.com/microsoft/vsts-authentication-library-for-java but there haven't been updates since Mar. last year.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.