Here is a redis example
Create a new Redisappsecretmanager class to implement the Appsecretmanager interface
/** * How to use: * * <pre> @Autowired private Appsecretmanager Appsecretmanager;
@Override protected void Initapiconfig (Apiconfig apiconfig) {... apiconfig.setappsecretmanager (appsecretmanager);
...
}
* </pre> * * @author TANGHC * */@Component public class Redisappsecretmanager implements Appsecretmanager {
public static String App_key_prefix = "Easyopen_app_key:";
@Autowired private Stringredistemplate stringredistemplate; @Override public void Addappsecret (map<string, string> appsecretstore) {Stringredistemplate.opsforhash (
). Putall (App_key_prefix, Appsecretstore); @Override public string Getsecret (string AppKey) {return (string) Stringredistemplate.opsforhash (). Get (
App_key_prefix, AppKey);
@Override public boolean Isvalidappkey (String appKey) {if (AppKey = = null) {return false;
} return Getsecret (appKey)! = NULL; }
}
Storing App_key and secret in the form of hash set, so the view in Redis is more convenient, at a glance.
Then in the Indexcontroller:
@Autowired
private Appsecretmanager Appsecretmanager;
@Override
protected void Initapiconfig (Apiconfig apiconfig) {
...
Apiconfig.setappsecretmanager (Appsecretmanager);
...
}