b97768a63f4af125dda2fbf3e3d05d715370676c
[aaf/authz.git] / cadi / client / src / main / java / org / onap / aaf / cadi / locator / HClientHotPeerLocator.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.cadi.locator;
23
24 import java.net.URI;
25 import java.net.URISyntaxException;
26
27 import org.onap.aaf.cadi.Access;
28 import org.onap.aaf.cadi.LocatorException;
29 import org.onap.aaf.cadi.http.HClient;
30 import org.onap.aaf.cadi.http.HX509SS;
31
32 public class HClientHotPeerLocator extends HotPeerLocator<HClient> {
33         private final HX509SS ss;
34
35         public HClientHotPeerLocator(Access access, String urlstr, long invalidateTime, String localLatitude,
36                         String localLongitude, HX509SS ss) throws LocatorException {
37                 super(access, urlstr, invalidateTime, localLatitude, localLongitude);
38                 
39                 this.ss = ss;
40         }
41
42         @Override
43         protected HClient _newClient(String clientInfo) throws LocatorException {
44                 try {
45                         int idx = clientInfo.indexOf('/');
46                         return new HClient(ss,new URI("https://"+(idx<0?clientInfo:clientInfo.substring(0, idx))),3000);
47                 } catch (URISyntaxException e) {
48                         throw new LocatorException(e);
49                 }
50         }
51
52         @Override
53         protected HClient _invalidate(HClient client) {
54                 return null;
55         }
56
57         @Override
58         protected void _destroy(HClient client) {
59         }
60 }