use of java.net.UnknownHostException in project java-chassis by ServiceComb.
the class SSLManager method createSSLSocket.
public static SSLSocket createSSLSocket(SSLOption option, SSLCustom custom) {
try {
SSLContext context = createSSLContext(option, custom);
SSLSocketFactory facroty = context.getSocketFactory();
SSLSocket socket = (SSLSocket) facroty.createSocket();
socket.setEnabledProtocols(option.getProtocols().split(","));
String[] supported = socket.getSupportedCipherSuites();
String[] eanbled = option.getCiphers().split(",");
socket.setEnabledCipherSuites(getEnabledCiphers(supported, eanbled));
return socket;
} catch (UnknownHostException e) {
throw new IllegalArgumentException("unkown host");
} catch (IOException e) {
throw new IllegalArgumentException("unable create socket");
}
}
use of java.net.UnknownHostException in project robo4j by Robo4J.
the class RaspistillUnit method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
Map<String, String> parameters = new HashMap<>();
parameters.put(KEY_WIDTH, configuration.getString(KEY_WIDTH, "320"));
parameters.put(KEY_HEIGHT, configuration.getString(KEY_HEIGHT, "240"));
parameters.put(KEY_EXPOSURE, configuration.getString(KEY_EXPOSURE, "sport"));
parameters.put(KEY_BRIGHTNESS, configuration.getString(KEY_BRIGHTNESS, null));
parameters.put(KEY_SHARPNESS, configuration.getString(KEY_SHARPNESS, null));
parameters.put(KEY_CONTRAST, configuration.getString(KEY_CONTRAST, null));
parameters.put(KEY_TIMEOUT, configuration.getString(KEY_TIMEOUT, "1"));
parameters.put(KEY_TIMELAPSE, configuration.getString(KEY_TIMELAPSE, "100"));
parameters.put(KEY_ROTATION, configuration.getString(KEY_ROTATION, null));
//@formatter:off
cameraCommand = new StringBuilder().append(RaspistillUtils.RASPISTILL_COMMAND).append(Constants.UTF8_SPACE).append(parameters.entrySet().stream().filter(p -> Objects.nonNull(p.getValue())).map(e -> {
StringBuilder c = new StringBuilder();
if (RaspistillUtils.isOption(e.getKey())) {
return c.append(RaspistillUtils.getOption(e.getKey())).append(Constants.UTF8_SPACE).append(e.getValue()).toString();
}
return null;
}).filter(Objects::nonNull).collect(Collectors.joining(Constants.UTF8_SPACE))).append(Constants.UTF8_SPACE).append(DEFAULT_IMAGE_SETUP).toString();
SimpleLoggingUtil.print(getClass(), "cameraCommand:" + cameraCommand);
//@formatter:on
targetOut = configuration.getString("targetOut", null);
String tmpClient = configuration.getString("client", null);
if (tmpClient == null || targetOut == null) {
throw ConfigurationException.createMissingConfigNameException("targetOut, client");
}
storeTarget = configuration.getString("storeTarget", null);
try {
InetAddress inetAddress = InetAddress.getByName(tmpClient);
String clientPort = configuration.getString("clientPort", null);
client = clientPort == null ? inetAddress.getHostAddress() : inetAddress.getHostAddress().concat(":").concat(clientPort);
clientUri = configuration.getString("clientUri", Constants.EMPTY_STRING);
} catch (UnknownHostException e) {
SimpleLoggingUtil.error(getClass(), "unknown ip address", e);
throw ConfigurationException.createMissingConfigNameException("unknown ip address");
}
}
use of java.net.UnknownHostException in project robo4j by Robo4J.
the class TestClientImageController method onInitialization.
@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
SimpleLoggingUtil.print(getClass(), "camera client init");
Map<String, String> parameters = new HashMap<>();
//64
parameters.put(KEY_WIDTH, configuration.getString(KEY_WIDTH, "320"));
//45
parameters.put(KEY_HEIGHT, configuration.getString(KEY_HEIGHT, "240"));
StringBuilder sb = new StringBuilder(RASPI_CAMERA).append(SPACE).append(parameters.entrySet().stream().map(e -> {
StringBuilder c = new StringBuilder();
if (raspistillProperties.containsKey(e.getKey())) {
return c.append(raspistillProperties.get(e.getKey())).append(SPACE).append(e.getValue()).toString();
}
return null;
}).filter(Objects::nonNull).collect(Collectors.joining(SPACE))).append(SPACE).append(DEFAULT_SETUP);
cameraCommand = sb.toString();
SimpleLoggingUtil.print(getClass(), "camera cameraCommand: " + cameraCommand);
targetOut = configuration.getString("targetOut", null);
String tmpClient = configuration.getString("client", null);
if (tmpClient == null || targetOut == null) {
throw ConfigurationException.createMissingConfigNameException("targetOut, client");
}
try {
InetAddress inetAddress = InetAddress.getByName(tmpClient);
String clientPort = configuration.getString("clientPort", null);
client = clientPort == null ? inetAddress.getHostAddress() : inetAddress.getHostAddress().concat(":").concat(clientPort);
clientUri = configuration.getString("clientUri", Constants.EMPTY_STRING);
} catch (UnknownHostException e) {
SimpleLoggingUtil.error(getClass(), "unknown ip address", e);
throw ConfigurationException.createMissingConfigNameException("unknown ip address");
}
}
use of java.net.UnknownHostException in project android_frameworks_base by ResurrectionRemix.
the class ConnectivityService method requestRouteToHostAddress.
/**
* Ensure that a network route exists to deliver traffic to the specified
* host via the specified network interface.
* @param networkType the type of the network over which traffic to the
* specified host is to be routed
* @param hostAddress the IP address of the host to which the route is
* desired
* @return {@code true} on success, {@code false} on failure
*/
@Override
public boolean requestRouteToHostAddress(int networkType, byte[] hostAddress) {
enforceChangePermission();
if (mProtectedNetworks.contains(networkType)) {
enforceConnectivityInternalPermission();
}
InetAddress addr;
try {
addr = InetAddress.getByAddress(hostAddress);
} catch (UnknownHostException e) {
if (DBG)
log("requestRouteToHostAddress got " + e.toString());
return false;
}
if (!ConnectivityManager.isNetworkTypeValid(networkType)) {
if (DBG)
log("requestRouteToHostAddress on invalid network: " + networkType);
return false;
}
NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
if (nai == null) {
if (mLegacyTypeTracker.isTypeSupported(networkType) == false) {
if (DBG)
log("requestRouteToHostAddress on unsupported network: " + networkType);
} else {
if (DBG)
log("requestRouteToHostAddress on down network: " + networkType);
}
return false;
}
DetailedState netState;
synchronized (nai) {
netState = nai.networkInfo.getDetailedState();
}
if (netState != DetailedState.CONNECTED && netState != DetailedState.CAPTIVE_PORTAL_CHECK) {
if (VDBG) {
log("requestRouteToHostAddress on down network " + "(" + networkType + ") - dropped" + " netState=" + netState);
}
return false;
}
final int uid = Binder.getCallingUid();
final long token = Binder.clearCallingIdentity();
try {
LinkProperties lp;
int netId;
synchronized (nai) {
lp = nai.linkProperties;
netId = nai.network.netId;
}
boolean ok = addLegacyRouteToHost(lp, addr, netId, uid);
if (DBG)
log("requestRouteToHostAddress ok=" + ok);
return ok;
} finally {
Binder.restoreCallingIdentity(token);
}
}
use of java.net.UnknownHostException in project android_frameworks_base by ResurrectionRemix.
the class ConnectivityPacketSummary method getIpAddressString.
private static String getIpAddressString(ByteBuffer ip, int byteLength) {
if (ip == null || ip.remaining() < byteLength)
return "invalid";
byte[] bytes = new byte[byteLength];
ip.get(bytes, 0, byteLength);
try {
InetAddress addr = InetAddress.getByAddress(bytes);
return addr.getHostAddress();
} catch (UnknownHostException uhe) {
return "unknown";
}
}
Aggregations