public static String cleanRealm(String realm){
  if (realm == null) {
    return "/";
  }
  if (!realm.startsWith("/")) {
    realm="/" + realm;
  }
  if (realm.length() > 1 && realm.endsWith("/")) {
    realm=realm.substring(0,realm.length() - 1);
  }
  return realm;
}

public static String cleanRealm ( String realm ) { if ( realm == null ) { return "/" ; } if ( ! realm . startsWith ( "/" ) ) { realm = "/" + realm ; } if ( realm . length ( ) > 1 && realm . endsWith ( "/" ) ) { realm = realm . substring ( 0 , realm . length ( ) - 1 ) ; } return realm ; }
converts a realm to a valid form
