1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.common.keymaster.client.self;
20
21 import java.util.List;
22 import java.util.Map;
23 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
24 import org.apache.syncope.common.keymaster.client.api.DomainOps;
25 import org.apache.syncope.common.keymaster.client.api.KeymasterException;
26 import org.apache.syncope.common.keymaster.client.api.model.Domain;
27 import org.apache.syncope.common.keymaster.rest.api.service.DomainService;
28 import org.apache.syncope.common.lib.types.CipherAlgorithm;
29
30 public class SelfKeymasterDomainOps extends SelfKeymasterOps implements DomainOps {
31
32 public SelfKeymasterDomainOps(final JAXRSClientFactoryBean clientFactory) {
33 super(clientFactory);
34 }
35
36 @Override
37 public List<Domain> list() {
38 return client(DomainService.class, Map.of()).list();
39 }
40
41 @Override
42 public Domain read(final String key) {
43 try {
44 return client(DomainService.class, Map.of()).read(key);
45 } catch (KeymasterException e) {
46 throw e;
47 } catch (Exception e) {
48 throw new KeymasterException(e);
49 }
50 }
51
52 @Override
53 public void create(final Domain domain) {
54 try {
55 client(DomainService.class, Map.of()).create(domain);
56 } catch (KeymasterException e) {
57 throw e;
58 } catch (Exception e) {
59 throw new KeymasterException(e);
60 }
61 }
62
63 @Override
64 public void changeAdminPassword(final String key, final String password, final CipherAlgorithm cipherAlgorithm) {
65 try {
66 client(DomainService.class, Map.of()).changeAdminPassword(key, password, cipherAlgorithm);
67 } catch (KeymasterException e) {
68 throw e;
69 } catch (Exception e) {
70 throw new KeymasterException(e);
71 }
72 }
73
74 @Override
75 public void adjustPoolSize(final String key, final int maxPoolSize, final int minIdle) {
76 try {
77 client(DomainService.class, Map.of()).adjustPoolSize(key, maxPoolSize, minIdle);
78 } catch (KeymasterException e) {
79 throw e;
80 } catch (Exception e) {
81 throw new KeymasterException(e);
82 }
83 }
84
85 @Override
86 public void delete(final String key) {
87 try {
88 client(DomainService.class, Map.of()).delete(key);
89 } catch (KeymasterException e) {
90 throw e;
91 } catch (Exception e) {
92 throw new KeymasterException(e);
93 }
94 }
95 }