1 package cn.home1.oss.environment.admin;
2
3 import java.util.Collection;
4 import java.util.concurrent.ConcurrentHashMap;
5 import java.util.concurrent.ConcurrentMap;
6
7
8
9
10 public class ClientKeyStore {
11
12 private final ConcurrentMap<String, ClientKey> keysMap = new ConcurrentHashMap<>();
13
14 public ClientKey save(final ClientKey clientKey) {
15 return this.keysMap.put(clientKey.getServiceId(), clientKey);
16 }
17
18 public Collection<ClientKey> findAll() {
19 return this.keysMap.values();
20 }
21
22 public ClientKey find(final String serviceId) {
23 return this.keysMap.get(serviceId);
24 }
25
26 public ClientKey delete(final String serviceId) {
27 return this.keysMap.remove(serviceId);
28 }
29
30 public boolean isAvailable(final String serviceId) {
31 return find(serviceId) != null;
32 }
33 }