1 /*******************************************************************************
2 * Copyright (c) 2007, 2014 Massimiliano Ziccardi
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 package it.jnrpe.osgi;
17
18 class JNRPEBindingAddress {
19
20 private boolean ssl = false;
21 private String address;
22 private int port = 5667;
23
24 JNRPEBindingAddress(final String bindingAddress) {
25 init(bindingAddress);
26 }
27
28 private void init(final String bindingAddress) {
29
30 String addr = bindingAddress;
31
32 ssl = addr.startsWith("SSL/");
33 if (ssl) {
34 addr = addr.substring(4);
35 }
36
37 if (addr.indexOf(':') != -1) {
38 String[] components = addr.split(":");
39 address = components[0];
40 port = Integer.parseInt(components[1]);
41 } else {
42 address = addr;
43 }
44 }
45
46 protected boolean isSsl() {
47 return ssl;
48 }
49
50 protected String getAddress() {
51 return address;
52 }
53
54 protected int getPort() {
55 return port;
56 }
57 }