예제 #1
0
 public @Override boolean enabled() {
   if (Boolean.getBoolean("netbeans.keyring.no.native")) {
     LOG.fine("native keyring integration disabled");
     return false;
   }
   boolean envVarSet = false;
   for (String key : System.getenv().keySet()) {
     if (key.startsWith("GNOME_KEYRING_")) { // NOI18N
       envVarSet = true;
       break;
     }
   }
   if (!envVarSet) {
     LOG.fine("no GNOME_KEYRING_* environment variable set");
     return false;
   }
   String appName = "JOSM";
   try {
     // Need to do this somewhere, or we get warnings on console.
     // Also used by confirmation dialogs to give the app access to the login keyring.
     LIBRARY.g_set_application_name(appName);
     if (!LIBRARY.gnome_keyring_is_available()) {
       return false;
     }
     // #178571: try to read some key just to make sure gnome_keyring_find_password_sync is bound:
     read("NoNeXiStEnT"); // NOI18N
     return true;
   } catch (Throwable t) {
     LOG.log(Level.FINE, null, t);
     return false;
   }
 }