package com.perforce.workshop.tjuricek.p4oauth.storage; import com.perforce.workshop.tjuricek.p4oauth.config.P4OAuthConfig; import com.perforce.workshop.tjuricek.p4oauth.models.Whitelist; import java.io.File; import java.io.IOException; /** * Right now, the whitelist is read into our whitelist model in memory. * <p> * It's assumed that the whitelist is generally only updated by a local * administrator. It's just a simple YAML file that we may provide an admin * interface to over the long term. */ public class WhitelistStore implements FilesystemStore { private P4OAuthConfig config; public WhitelistStore(P4OAuthConfig config) { this.config = config; } /** * @return */ public Whitelist read() throws IOException { File whitelistFile = getWhitelistFile(); if (whitelistFile.exists()) { return readYamlFile(Whitelist.class, whitelistFile); } throw new IllegalStateException("A whitelist has not been configured in the system"); } public void update(Whitelist w) throws IOException { File whitelistFile = getWhitelistFile(); ensureParentExists(whitelistFile); writeYamlFile(w, whitelistFile); } public File getWhitelistFile() { return getFile("whitelist"); } @Override public P4OAuthConfig getConfig() { return config; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 9095 | tjuricek | Added some basic test data and renamed "workspace" to "workshop" in package name | ||
//guest/tjuricek/p4oauth/src/main/java/com/perforce/workspace/tjuricek/p4oauth/storage/WhitelistStore.java | |||||
#1 | 9089 | tjuricek |
Moving some code that worked via some manual validation to the workshop. This just implements a basic code authorization grant scheme. Automated tests are forthcoming, awating some gradle plugin work that should sit outside of this project. |