Example usage for java.net InetAddress getByName

List of usage examples for java.net InetAddress getByName

Introduction

In this page you can find the example usage for java.net InetAddress getByName.

Prototype

public static InetAddress getByName(String host) throws UnknownHostException 

Source Link

Document

Determines the IP address of a host, given the host's name.

Usage

From source file:org.apache.maven.wagon.providers.http.ConfigurationUtils.java

public static void copyConfig(HttpMethodConfiguration config, RequestConfig.Builder builder) {
    if (config.getConnectionTimeout() > 0) {
        builder.setConnectTimeout(config.getConnectionTimeout());
    }//  w w  w. ja  v  a2  s. c om
    if (config.getReadTimeout() > 0) {
        builder.setSocketTimeout(config.getReadTimeout());
    }
    Properties params = config.getParams();
    if (params != null) {

        Pattern coercePattern = Pattern.compile(COERCE_PATTERN);
        for (Map.Entry entry : params.entrySet()) {
            String key = (String) entry.getKey();
            String value = (String) entry.getValue();
            Matcher matcher = coercePattern.matcher(value);
            if (matcher.matches()) {
                value = matcher.group(2);
            }

            if (key.equals(SO_TIMEOUT)) {
                builder.setSocketTimeout(Integer.parseInt(value));
            } else if (key.equals(STALE_CONNECTION_CHECK)) {
                builder.setStaleConnectionCheckEnabled(Boolean.valueOf(value));
            } else if (key.equals(CONNECTION_TIMEOUT)) {
                builder.setConnectTimeout(Integer.parseInt(value));
            } else if (key.equals(USE_EXPECT_CONTINUE)) {
                builder.setExpectContinueEnabled(Boolean.valueOf(value));
            } else if (key.equals(DEFAULT_PROXY)) {
                builder.setProxy(new HttpHost(value));
            } else if (key.equals(LOCAL_ADDRESS)) {
                try {
                    builder.setLocalAddress(InetAddress.getByName(value));
                } catch (UnknownHostException ignore) {
                }
            } else if (key.equals(PROXY_AUTH_PREF)) {
                builder.setProxyPreferredAuthSchemes(Arrays.asList(value.split(",")));
            } else if (key.equals(TARGET_AUTH_PREF)) {
                builder.setTargetPreferredAuthSchemes(Arrays.asList(value.split(",")));
            } else if (key.equals(HANDLE_AUTHENTICATION)) {
                builder.setAuthenticationEnabled(Boolean.valueOf(value));
            } else if (key.equals(ALLOW_CIRCULAR_REDIRECTS)) {
                builder.setCircularRedirectsAllowed(Boolean.valueOf(value));
            } else if (key.equals(CONN_MANAGER_TIMEOUT)) {
                builder.setConnectionRequestTimeout(Integer.parseInt(value));
            } else if (key.equals(COOKIE_POLICY)) {
                builder.setCookieSpec(value);
            } else if (key.equals(MAX_REDIRECTS)) {
                builder.setMaxRedirects(Integer.parseInt(value));
            } else if (key.equals(HANDLE_REDIRECTS)) {
                builder.setRedirectsEnabled(Boolean.valueOf(value));
            } else if (key.equals(REJECT_RELATIVE_REDIRECT)) {
                builder.setRelativeRedirectsAllowed(!Boolean.valueOf(value));
            }
        }
    }
}

From source file:com.baifendian.swordfish.common.search.EsSearch.java

private EsSearch() {
    String[] array = esAddress.split(",");

    Settings settings = Settings.builder().put("client.transport.sniff", false)
            .put("cluster.name", esClusterName).build();

    client = new PreBuiltTransportClient(settings);

    for (int i = 0; i < array.length; ++i) {
        String[] hostPort = array[i].split(":");

        String host = hostPort[0];
        Integer port = Integer.parseInt(hostPort[1]);

        try {//w ww  .ja  v a2  s.co  m
            client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));

            LOGGER.info("Add (host,port) => ({},{})", host, port);
        } catch (UnknownHostException e) {
            LOGGER.error("Add host,port failed", e);
        }
    }

    for (DiscoveryNode node : client.connectedNodes()) {
        LOGGER.info("Connect nodes: {}", node.toString());
    }
}

From source file:com.yahoo.inmind.services.streaming.control.rtsp.UriParser.java

/**
 * Configures a Session according to the given URI.
 * Here are some examples of URIs that can be used to configure a Session:
 * <ul><li>rtsp://xxx.xxx.xxx.xxx:8086?h264&flash=on</li>
 * <li>rtsp://xxx.xxx.xxx.xxx:8086?h263&camera=front&flash=on</li>
 * <li>rtsp://xxx.xxx.xxx.xxx:8086?h264=200-20-320-240</li>
 * <li>rtsp://xxx.xxx.xxx.xxx:8086?aac</li></ul>
 * @param uri The URI/*from   w  w w  . ja  va  2s  . c  om*/
 * @throws IllegalStateException
 * @throws IOException
 * @return A Session configured according to the URI
 */
public static Session parse(String uri) throws IllegalStateException, IOException {
    SessionBuilder builder = SessionBuilder.getInstance().clone();
    byte audioApi = 0, videoApi = 0;

    List<NameValuePair> params = URLEncodedUtilsHC4.parse(URI.create(uri), "UTF-8");
    if (params.size() > 0) {

        builder.setAudioEncoder(SessionBuilder.AUDIO_NONE).setVideoEncoder(SessionBuilder.VIDEO_NONE);

        // Those parameters must be parsed first or else they won't necessarily be taken into account
        for (Iterator<NameValuePair> it = params.iterator(); it.hasNext();) {
            NameValuePair param = it.next();

            // FLASH ON/OFF
            if (param.getName().equalsIgnoreCase("flash")) {
                if (param.getValue().equalsIgnoreCase("on"))
                    builder.setFlashEnabled(true);
                else
                    builder.setFlashEnabled(false);
            }

            // CAMERA -> the client can choose between the front facing camera and the back facing camera
            else if (param.getName().equalsIgnoreCase("camera")) {
                if (param.getValue().equalsIgnoreCase("back"))
                    builder.setCamera(CameraInfo.CAMERA_FACING_BACK);
                else if (param.getValue().equalsIgnoreCase("front"))
                    builder.setCamera(CameraInfo.CAMERA_FACING_FRONT);
            }

            // MULTICAST -> the stream will be sent to a multicast group
            // The default mutlicast address is 228.5.6.7, but the client can specify another
            else if (param.getName().equalsIgnoreCase("multicast")) {
                if (param.getValue() != null) {
                    try {
                        InetAddress addr = InetAddress.getByName(param.getValue());
                        if (!addr.isMulticastAddress()) {
                            throw new IllegalStateException("Invalid multicast address !");
                        }
                        builder.setDestination(param.getValue());
                    } catch (UnknownHostException e) {
                        throw new IllegalStateException("Invalid multicast address !");
                    }
                } else {
                    // Default multicast address
                    builder.setDestination("228.5.6.7");
                }
            }

            // UNICAST -> the client can use this to specify where he wants the stream to be sent
            else if (param.getName().equalsIgnoreCase("unicast")) {
                if (param.getValue() != null) {
                    builder.setDestination(param.getValue());
                }
            }

            // VIDEOAPI -> can be used to specify what api will be used to encode video (the MediaRecorder API or the MediaCodec API)
            else if (param.getName().equalsIgnoreCase("videoapi")) {
                if (param.getValue() != null) {
                    if (param.getValue().equalsIgnoreCase("mr")) {
                        videoApi = MediaStream.MODE_MEDIARECORDER_API;
                    } else if (param.getValue().equalsIgnoreCase("mc")) {
                        videoApi = MediaStream.MODE_MEDIACODEC_API;
                    }
                }
            }

            // AUDIOAPI -> can be used to specify what api will be used to encode audio (the MediaRecorder API or the MediaCodec API)
            else if (param.getName().equalsIgnoreCase("audioapi")) {
                if (param.getValue() != null) {
                    if (param.getValue().equalsIgnoreCase("mr")) {
                        audioApi = MediaStream.MODE_MEDIARECORDER_API;
                    } else if (param.getValue().equalsIgnoreCase("mc")) {
                        audioApi = MediaStream.MODE_MEDIACODEC_API;
                    }
                }
            }

            // TTL -> the client can modify the time to live of packets
            // By default ttl=64
            else if (param.getName().equalsIgnoreCase("ttl")) {
                if (param.getValue() != null) {
                    try {
                        int ttl = Integer.parseInt(param.getValue());
                        if (ttl < 0)
                            throw new IllegalStateException();
                        builder.setTimeToLive(ttl);
                    } catch (Exception e) {
                        throw new IllegalStateException("The TTL must be a positive integer !");
                    }
                }
            }

            // H.264
            else if (param.getName().equalsIgnoreCase("h264")) {
                VideoQuality quality = VideoQuality.parseQuality(param.getValue());
                builder.setVideoQuality(quality).setVideoEncoder(SessionBuilder.VIDEO_H264);
            }

            // H.263
            else if (param.getName().equalsIgnoreCase("h263")) {
                VideoQuality quality = VideoQuality.parseQuality(param.getValue());
                builder.setVideoQuality(quality).setVideoEncoder(SessionBuilder.VIDEO_H263);
            }

            // AMR
            else if (param.getName().equalsIgnoreCase("amrnb") || param.getName().equalsIgnoreCase("amr")) {
                AudioQuality quality = AudioQuality.parseQuality(param.getValue());
                builder.setAudioQuality(quality).setAudioEncoder(SessionBuilder.AUDIO_AMRNB);
            }

            // AAC
            else if (param.getName().equalsIgnoreCase("aac")) {
                AudioQuality quality = AudioQuality.parseQuality(param.getValue());
                builder.setAudioQuality(quality).setAudioEncoder(SessionBuilder.AUDIO_AAC);
            }

        }

    }

    if (builder.getVideoEncoder() == SessionBuilder.VIDEO_NONE
            && builder.getAudioEncoder() == SessionBuilder.AUDIO_NONE) {
        SessionBuilder b = SessionBuilder.getInstance();
        builder.setVideoEncoder(b.getVideoEncoder());
        builder.setAudioEncoder(b.getAudioEncoder());
    }

    Session session = builder.build();

    if (videoApi > 0 && session.getVideoTrack() != null) {
        session.getVideoTrack().setStreamingMethod(videoApi);
    }

    if (audioApi > 0 && session.getAudioTrack() != null) {
        session.getAudioTrack().setStreamingMethod(audioApi);
    }

    return session;

}

From source file:com.sshtools.daemon.SshDaemon.java

/**
 *
 *
 * @param msg/* w  ww  .  j a va 2s .  co  m*/
 *
 * @throws IOException
 */
public static void stop(String msg) throws IOException {
    try {
        Socket socket = new Socket(InetAddress.getByName("127.0.0.1"),
                ((ServerConfiguration) ConfigurationLoader.getConfiguration(ServerConfiguration.class))
                        .getCommandPort());

        // Write the command id
        socket.getOutputStream().write(0x3a);

        // Write the length of the message (max 255)
        int len = (msg.length() <= 255) ? msg.length() : 255;
        socket.getOutputStream().write(len);

        // Write the message
        if (len > 0) {
            socket.getOutputStream().write(msg.substring(0, len).getBytes());
        }

        socket.close();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}

From source file:org.apache.maven.wagon.shared.http.ConfigurationUtils.java

public static void copyConfig(HttpMethodConfiguration config, RequestConfig.Builder builder) {
    if (config.getConnectionTimeout() > 0) {
        builder.setConnectTimeout(config.getConnectionTimeout());
    }/*w  w w . j a v  a  2s  .c  o m*/
    if (config.getReadTimeout() > 0) {
        builder.setSocketTimeout(config.getReadTimeout());
    }
    Properties params = config.getParams();
    if (params != null) {

        Pattern coercePattern = Pattern.compile(COERCE_PATTERN);
        for (Map.Entry entry : params.entrySet()) {
            String key = (String) entry.getKey();
            String value = (String) entry.getValue();
            Matcher matcher = coercePattern.matcher(value);
            if (matcher.matches()) {
                value = matcher.group(2);
            }

            if (key.equals(SO_TIMEOUT)) {
                builder.setSocketTimeout(Integer.parseInt(value));
            } else if (key.equals(STALE_CONNECTION_CHECK)) {
                builder.setStaleConnectionCheckEnabled(Boolean.valueOf(value));
            } else if (key.equals(CONNECTION_TIMEOUT)) {
                builder.setConnectTimeout(Integer.parseInt(value));
            } else if (key.equals(USE_EXPECT_CONTINUE)) {
                builder.setExpectContinueEnabled(Boolean.valueOf(value));
            } else if (key.equals(DEFAULT_PROXY)) {
                builder.setProxy(new HttpHost(value));
            } else if (key.equals(LOCAL_ADDRESS)) {
                try {
                    builder.setLocalAddress(InetAddress.getByName(value));
                } catch (UnknownHostException ignore) {
                    // ignore
                }
            } else if (key.equals(PROXY_AUTH_PREF)) {
                builder.setProxyPreferredAuthSchemes(Arrays.asList(value.split(",")));
            } else if (key.equals(TARGET_AUTH_PREF)) {
                builder.setTargetPreferredAuthSchemes(Arrays.asList(value.split(",")));
            } else if (key.equals(HANDLE_AUTHENTICATION)) {
                builder.setAuthenticationEnabled(Boolean.valueOf(value));
            } else if (key.equals(ALLOW_CIRCULAR_REDIRECTS)) {
                builder.setCircularRedirectsAllowed(Boolean.valueOf(value));
            } else if (key.equals(CONN_MANAGER_TIMEOUT)) {
                builder.setConnectionRequestTimeout(Integer.parseInt(value));
            } else if (key.equals(COOKIE_POLICY)) {
                builder.setCookieSpec(value);
            } else if (key.equals(MAX_REDIRECTS)) {
                builder.setMaxRedirects(Integer.parseInt(value));
            } else if (key.equals(HANDLE_REDIRECTS)) {
                builder.setRedirectsEnabled(Boolean.valueOf(value));
            } else if (key.equals(REJECT_RELATIVE_REDIRECT)) {
                builder.setRelativeRedirectsAllowed(!Boolean.valueOf(value));
            }
        }
    }
}

From source file:NTP_Example.java

/**
 * Process <code>TimeInfo</code> object and print its details.
 * @param info <code>TimeInfo</code> object.
 *//*from   w w  w. j  ava2  s . c  o m*/
public static void processResponse(TimeInfo info) {
    NtpV3Packet message = info.getMessage();
    int stratum = message.getStratum();
    String refType;
    if (stratum <= 0) {
        refType = "(Unspecified or Unavailable)";
    } else if (stratum == 1) {
        refType = "(Primary Reference; e.g., GPS)"; // GPS, radio clock, etc.
    } else {
        refType = "(Secondary Reference; e.g. via NTP or SNTP)";
    }
    // stratum should be 0..15...
    System.out.println(" Stratum: " + stratum + " " + refType);
    int version = message.getVersion();
    int li = message.getLeapIndicator();
    System.out.println(" leap=" + li + ", version=" + version + ", precision=" + message.getPrecision());

    System.out.println(" mode: " + message.getModeName() + " (" + message.getMode() + ")");
    int poll = message.getPoll();
    // poll value typically btwn MINPOLL (4) and MAXPOLL (14)
    System.out.println(
            " poll: " + (poll <= 0 ? 1 : (int) Math.pow(2, poll)) + " seconds" + " (2 ** " + poll + ")");
    double disp = message.getRootDispersionInMillisDouble();
    System.out.println(" rootdelay=" + numberFormat.format(message.getRootDelayInMillisDouble())
            + ", rootdispersion(ms): " + numberFormat.format(disp));

    int refId = message.getReferenceId();
    String refAddr = NtpUtils.getHostAddress(refId);
    String refName = null;
    if (refId != 0) {
        if (refAddr.equals("127.127.1.0")) {
            refName = "LOCAL"; // This is the ref address for the Local Clock
        } else if (stratum >= 2) {
            // If reference id has 127.127 prefix then it uses its own reference clock
            // defined in the form 127.127.clock-type.unit-num (e.g. 127.127.8.0 mode 5
            // for GENERIC DCF77 AM; see refclock.htm from the NTP software distribution.
            if (!refAddr.startsWith("127.127")) {
                try {
                    InetAddress addr = InetAddress.getByName(refAddr);
                    String name = addr.getHostName();
                    if (name != null && !name.equals(refAddr)) {
                        refName = name;
                    }
                } catch (UnknownHostException e) {
                    // some stratum-2 servers sync to ref clock device but fudge stratum level higher... (e.g. 2)
                    // ref not valid host maybe it's a reference clock name?
                    // otherwise just show the ref IP address.
                    refName = NtpUtils.getReferenceClock(message);
                }
            }
        } else if (version >= 3 && (stratum == 0 || stratum == 1)) {
            refName = NtpUtils.getReferenceClock(message);
            // refname usually have at least 3 characters (e.g. GPS, WWV, LCL, etc.)
        }
        // otherwise give up on naming the beast...
    }
    if (refName != null && refName.length() > 1) {
        refAddr += " (" + refName + ")";
    }
    System.out.println(" Reference Identifier:\t" + refAddr);

    TimeStamp refNtpTime = message.getReferenceTimeStamp();
    System.out.println(" Reference Timestamp:\t" + refNtpTime + "  " + refNtpTime.toDateString());

    // Originate Time is time request sent by client (t1)
    TimeStamp origNtpTime = message.getOriginateTimeStamp();
    System.out.println(" Originate Timestamp:\t" + origNtpTime + "  " + origNtpTime.toDateString());

    long destTime = info.getReturnTime();
    // Receive Time is time request received by server (t2)
    TimeStamp rcvNtpTime = message.getReceiveTimeStamp();
    System.out.println(" Receive Timestamp:\t" + rcvNtpTime + "  " + rcvNtpTime.toDateString());

    // Transmit time is time reply sent by server (t3)
    TimeStamp xmitNtpTime = message.getTransmitTimeStamp();
    System.out.println(" Transmit Timestamp:\t" + xmitNtpTime + "  " + xmitNtpTime.toDateString());

    // Destination time is time reply received by client (t4)
    TimeStamp destNtpTime = TimeStamp.getNtpTime(destTime);
    System.out.println(" Destination Timestamp:\t" + destNtpTime + "  " + destNtpTime.toDateString());

    info.computeDetails(); // compute offset/delay if not already done
    Long offsetValue = info.getOffset();
    Long delayValue = info.getDelay();
    String delay = (delayValue == null) ? "N/A" : delayValue.toString();
    String offset = (offsetValue == null) ? "N/A" : offsetValue.toString();

    System.out.println(" Roundtrip delay(ms)=" + delay + ", clock offset(ms)=" + offset); // offset in ms
}

From source file:com.rastating.droidbeard.net.TlsSocketFactory.java

@Override
public Socket createSocket(Socket plainSocket, String host, int port, boolean autoClose)
        throws IOException, UnknownHostException {
    // Create and connect SSL socket, but don't do hostname/certificate verification yet
    SSLCertificateSocketFactory sslSocketFactory = (SSLCertificateSocketFactory) SSLCertificateSocketFactory
            .getDefault(0);//from   ww w  .j a v a  2 s . c om

    // Setup custom trust manager if we are trusting all certificates
    if (mTrustAllCertificates) {
        TrustManager tm = new X509TrustManager() {
            public void checkClientTrusted(X509Certificate[] chain, String authType)
                    throws CertificateException {
            }

            public void checkServerTrusted(X509Certificate[] chain, String authType)
                    throws CertificateException {
            }

            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }
        };

        sslSocketFactory.setTrustManagers(new TrustManager[] { tm });
    }

    SSLSocket ssl = (SSLSocket) sslSocketFactory.createSocket(InetAddress.getByName(host), port);

    // Enable TLSv1.1/1.2 if available
    // (see https://github.com/rfc2822/davdroid/issues/229)
    ssl.setEnabledProtocols(ssl.getSupportedProtocols());
    SSLSession session = ssl.getSession();

    // Verify hostname and certificate if we aren't trusting all certificates
    if (!mTrustAllCertificates) {
        if (!hostnameVerifier.verify(host, session))
            throw new SSLPeerUnverifiedException("Cannot verify hostname: " + host);
    }

    Log.i("droidbeard", "Established " + session.getProtocol() + " connection with " + session.getPeerHost()
            + " using " + session.getCipherSuite());
    return ssl;
}

From source file:net.dfs.remote.filestorage.impl.FileReceiverSupportImpl.java

/**
 * retrieveFile will create an instance of {@link FileStorageModel} and takes
 * the matching File objects from the Space. It makes sure that the Space is not
 * null before taking the File objects./*from w w w .ja v  a 2 s  .  co m*/
 * <p>
 * The received File object will be then sent to the {@link StorageManager} for ensure
 * the persistent storage. It accepts no values and returns no value.
 */
public void retrieveFile() {

    FileToken tempToken = new FileToken();

    if (space == null) {
        try {
            log.debug("Space Requested from " + serverIP);
            space = spaceCreator.getSpace(InetAddress.getByName(serverIP), InetAddress.getLocalHost());
            log.debug("Space Returned to " + serverIP);
        } catch (UnknownHostException e) {
            log.error("e");
        }
    }

    for (;;) {
        try {
            FileToken received = (FileToken) space.take(tempToken, null, Long.MAX_VALUE);
            log.info("Chunk " + received.fileName + " with Chunk No " + received.CHUNK_NO
                    + " Taken from the Space");

            FileStorageModel fileStorageModel = tokenFileManager.receiveChunk(received.fileName, received.ext,
                    received.CHUNK_NO);
            log.info("ACTUAL File " + fileStorageModel.fileName + " with bytes " + fileStorageModel.bytesRead
                    + " Received from the Server");
            storageManager.fileStorage(fileStorageModel);
            hashMap.createHashIndex(fileStorageModel.fileName, InetAddress.getLocalHost().getHostAddress());

        } catch (RemoteException e) {
            log.error("e");
        } catch (UnusableEntryException e) {
            log.error("e");
        } catch (TransactionException e) {
            log.error("e");
        } catch (InterruptedException e) {
            log.error("e");
        } catch (IOException e) {
            log.error("e");
        }
    }
}

From source file:com.jkoolcloud.tnt4j.utils.TimeService.java

/**
 * Obtain NTP time and synchronize with NTP server
 *
 * @throws IOException if error accessing time server
 *//*w w w  .j  a va 2s  . c o m*/
public static void updateTime() throws IOException {
    if (TIME_SERVER != null) {
        timeServer.setDefaultTimeout((int) TIME_SERVER_TIMEOUT);
        String[] pair = TIME_SERVER.split(":");
        InetAddress hostAddr = InetAddress.getByName(pair[0]);
        timeInfo = pair.length < 2 ? timeServer.getTime(hostAddr)
                : timeServer.getTime(hostAddr, Integer.parseInt(pair[1]));
        timeInfo.computeDetails();
        adjustment = timeInfo.getOffset() - timeOverheadMillis;
        updatedTime = currentTimeMillis();
        if (TIME_SERVER_VERBOSE) {
            logger.log(OpLevel.DEBUG,
                    "Time server={0}, timeout.ms={1}, offset.ms={2}, delay.ms={3}, clock.adjust.ms={4}, overhead.nsec={5}",
                    TIME_SERVER, TIME_SERVER_TIMEOUT, timeInfo.getOffset(), timeInfo.getDelay(), adjustment,
                    timeOverheadNanos);
        }
    }
}

From source file:dk.statsbiblioteket.doms.iprolemapper.webservice.IPRoleMapperService.java

@GET
@Path("getRoles/{ipaddress}")
@Produces("text/plain")
public String getRoles(@PathParam("ipaddress") String ipAddress) throws Throwable {

    if (log.isTraceEnabled()) {
        log.trace("getRoles(): Called with IP adress: " + ipAddress);
    }//from www.ja  va2s .c  o m

    try {
        // The static content of IPRolemapper will be initialised by
        // verifyConfiguration if the configuration can be successfully
        // read.
        verifyConfiguration();
        final IPRoleMapper ipRoleMapper = new IPRoleMapper();
        final Set<String> mappedRoles = ipRoleMapper.mapIPHost(InetAddress.getByName(ipAddress));

        // Build the result string.
        String rolesString = "";
        final Iterator<String> roleIterator = mappedRoles.iterator();
        while (roleIterator.hasNext()) {
            rolesString += roleIterator.next();

            // Append a comma if there are more roles left.
            if (roleIterator.hasNext()) {
                rolesString += ",";
            }
        } // end-while

        log.debug("IPRoleMapperService.getRoles(): returning roles: " + rolesString);

        return rolesString;
    } catch (Throwable throwable) {
        log.warn("getRoles(): Caught un-expected exception.", throwable);
        throw throwable;
    }
}