Java Code Examples for org.apache.zookeeper.data.Id#toString()

The following examples show how to use org.apache.zookeeper.data.Id#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistrySecurity.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Convert an ID to a string, stripping out all but the first few characters
 * of any digest auth hash for security reasons
 * @param id ID
 * @return a string description of a Zookeeper ID
 */
public static String idToString(Id id) {
  String s;
  if (id.getScheme().equals(SCHEME_DIGEST)) {
    String ids = id.getId();
    int colon = ids.indexOf(':');
    if (colon > 0) {
      ids = ids.substring(colon + 3);
    }
    s = SCHEME_DIGEST + ": " + ids;
  } else {
    s = id.toString();
  }
  return s;
}
 
Example 2
Source File: RegistrySecurity.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Convert an ID to a string, stripping out all but the first few characters
 * of any digest auth hash for security reasons
 * @param id ID
 * @return a string description of a Zookeeper ID
 */
public static String idToString(Id id) {
  String s;
  if (id.getScheme().equals(SCHEME_DIGEST)) {
    String ids = id.getId();
    int colon = ids.indexOf(':');
    if (colon > 0) {
      ids = ids.substring(colon + 3);
    }
    s = SCHEME_DIGEST + ": " + ids;
  } else {
    s = id.toString();
  }
  return s;
}