View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
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  }