Changeset 26336 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-07-15T22:00:51+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/native-password-manager/netbeans-keyring-patches.diff
r26335 r26336 1 diff -r src-netbeans-524f40b94a30-origin/org/netbeans/modules/keyring/fallback/FallbackProvider.java src/org/netbeans/modules/keyring/fallback/FallbackProvider.java 2 45,47d44 3 < import java.util.Arrays; 4 < import java.util.HashMap; 5 < import java.util.Map; 6 49d45 7 < import java.util.concurrent.Callable; 8 52,54d47 9 < import java.util.prefs.BackingStoreException; 10 < import java.util.prefs.Preferences; 11 < import org.netbeans.api.keyring.Keyring; 12 58,63d50 13 < import org.openide.DialogDisplayer; 14 < import org.openide.NotifyDescriptor; 15 < import org.openide.util.Lookup; 16 < import org.openide.util.NbBundle; 17 < import org.openide.util.NbPreferences; 18 < import org.openide.util.lookup.ServiceProvider; 19 68,69c55 20 < @ServiceProvider(service=KeyringProvider.class, position=1000) 21 < public class FallbackProvider implements KeyringProvider, Callable<Void> { 22 --- 23 > public class FallbackProvider implements KeyringProvider { 24 76c62,75 25 < 26 --- 27 > private IPreferences pre; 28 > 29 > // simple interface for a generic preferences store 30 > public interface IPreferences { 31 > String get(String key, String def); 32 > void put(String key, String val); 33 > void remove(String key); 34 > } 35 > 36 > public FallbackProvider(EncryptionProvider encryption, IPreferences pref) { 37 > this.encryption = encryption; 38 > this.pre = pref; 39 > } 40 > 41 78,87c77,79 42 < for (EncryptionProvider p : Lookup.getDefault().lookupAll(EncryptionProvider.class)) { 43 < if (p.enabled()) { 44 < encryption = p; 45 < Preferences prefs = prefs(); 46 < Utils.goMinusR(prefs); 47 < p.encryptionChangingCallback(this); 48 < if (!testSampleKey(prefs)) { 49 < continue; 50 < } 51 < LOG.log(Level.FINE, "Using provider: {0}", p); 52 --- 53 > if (encryption.enabled()) { 54 > if (testSampleKey()) { 55 > LOG.log(Level.FINE, "Using provider: {0}", encryption); 56 95,106c87,92 57 < private boolean testSampleKey(Preferences prefs) { 58 < byte[] ciphertext = prefs.getByteArray(SAMPLE_KEY, null); 59 < if (ciphertext == null) { 60 < encryption.freshKeyring(true); 61 < if (_save(SAMPLE_KEY, (SAMPLE_KEY + UUID.randomUUID()).toCharArray(), 62 < NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.sample_key.description"))) { 63 < LOG.fine("saved sample key"); 64 < return true; 65 < } else { 66 < LOG.fine("could not save sample key"); 67 < return false; 68 < } 69 --- 70 > private boolean testSampleKey() { 71 > encryption.freshKeyring(true); 72 > if (_save(SAMPLE_KEY, (SAMPLE_KEY + UUID.randomUUID()).toCharArray(), 73 > "Sample value ensuring that decryption is working.")) { 74 > LOG.fine("saved sample key"); 75 > return true; 76 108,143c94,95 77 < encryption.freshKeyring(false); 78 < while (true) { 79 < try { 80 < if (new String(encryption.decrypt(ciphertext)).startsWith(SAMPLE_KEY)) { 81 < LOG.fine("succeeded in decrypting sample key"); 82 < return true; 83 < } else { 84 < LOG.fine("wrong result decrypting sample key"); 85 < } 86 < } catch (Exception x) { 87 < LOG.log(Level.FINE, "failed to decrypt sample key", x); 88 < } 89 < if (!encryption.decryptionFailed()) { 90 < LOG.fine("sample key decryption failed"); 91 < return promptToDelete(prefs); 92 < } 93 < LOG.fine("will retry decryption of sample key"); 94 < } 95 < } 96 < } 97 < 98 < private boolean promptToDelete(Preferences prefs) { 99 < Object result = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation( 100 < NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.msg_clear_keys"), 101 < NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.title_clear_keys"), 102 < NotifyDescriptor.OK_CANCEL_OPTION)); 103 < if (result == NotifyDescriptor.OK_OPTION) { 104 < try { 105 < LOG.log(Level.FINE, "agreed to delete stored passwords: {0}", Arrays.asList(prefs.keys())); 106 < prefs.clear(); 107 < return testSampleKey(prefs); 108 < } catch (BackingStoreException x) { 109 < LOG.log(Level.INFO, null, x); 110 < } 111 < } else { 112 < LOG.fine("refused to delete stored passwords"); 113 --- 114 > LOG.fine("could not save sample key"); 115 > return false; 116 145,149d96 117 < return false; 118 < } 119 < 120 < private Preferences prefs() { 121 < return NbPreferences.forModule(Keyring.class).node(encryption.id()); 122 153c100,101 123 < byte[] ciphertext = prefs().getByteArray(key, null); 124 --- 125 > String ciphertext_string = pre.get(key, null); 126 > byte[] ciphertext = ciphertext_string == null ? null : Utils.chars2Bytes(ciphertext_string.toCharArray()); 127 169d116 128 < Preferences prefs = prefs(); 129 171c118,120 130 < prefs.putByteArray(key, encryption.encrypt(password)); 131 --- 132 > byte[] encryptedPasswordByteArray = encryption.encrypt(password); 133 > String encryptedPassword = encryptedPasswordByteArray == null ? null : String.valueOf(Utils.bytes2Chars(encryptedPasswordByteArray)); 134 > pre.put(key, encryptedPassword); 135 178c127 136 < prefs.put(key + DESCRIPTION, description); 137 --- 138 > pre.put(key + DESCRIPTION, description); 139 184,209c133,134 140 < Preferences prefs = prefs(); 141 < prefs.remove(key); 142 < prefs.remove(key + DESCRIPTION); 143 < } 144 < 145 < public Void call() throws Exception { // encryption changing 146 < LOG.fine("encryption changing"); 147 < Map<String,char[]> saved = new HashMap<String,char[]>(); 148 < Preferences prefs = prefs(); 149 < for (String k : prefs.keys()) { 150 < if (k.endsWith(DESCRIPTION)) { 151 < continue; 152 < } 153 < byte[] ciphertext = prefs.getByteArray(k, null); 154 < if (ciphertext == null) { 155 < continue; 156 < } 157 < saved.put(k, encryption.decrypt(ciphertext)); 158 < } 159 < LOG.log(Level.FINE, "reencrypting keys: {0}", saved.keySet()); 160 < encryption.encryptionChanged(); 161 < for (Map.Entry<String,char[]> entry : saved.entrySet()) { 162 < prefs.putByteArray(entry.getKey(), encryption.encrypt(entry.getValue())); 163 < } 164 < LOG.fine("encryption changing finished"); 165 < return null; 166 --- 167 > pre.remove(key); 168 > pre.remove(key + DESCRIPTION); 169 diff -r src-netbeans-524f40b94a30-origin/org/netbeans/modules/keyring/gnome/GnomeProvider.java src/org/netbeans/modules/keyring/gnome/GnomeProvider.java 170 46,47d45 171 < import java.text.MessageFormat; 172 < import java.util.MissingResourceException; 173 52,53d49 174 < import org.openide.util.NbBundle; 175 < import org.openide.util.lookup.ServiceProvider; 176 55d50 177 < @ServiceProvider(service=KeyringProvider.class, position=100) 178 77,84c72 179 < String appName; 180 < try { 181 < appName = MessageFormat.format( 182 < NbBundle.getBundle("org.netbeans.core.windows.view.ui.Bundle").getString("CTL_MainWindow_Title_No_Project"), 183 < /*System.getProperty("netbeans.buildnumber")*/"…"); 184 < } catch (MissingResourceException x) { 185 < appName = "NetBeans"; // NOI18N 186 < } 187 --- 188 > String appName = "JOSM"; 189 diff -r src-netbeans-524f40b94a30-origin/org/netbeans/modules/keyring/kde/KWalletProvider.java src/org/netbeans/modules/keyring/kde/KWalletProvider.java 190 48d47 191 < import java.text.MessageFormat; 192 50d48 193 < import java.util.MissingResourceException; 194 54,55d51 195 < import org.openide.util.NbBundle; 196 < import org.openide.util.lookup.ServiceProvider; 197 61d56 198 < @ServiceProvider(service=KeyringProvider.class, position=99) 199 224,230c219 200 < String appName; 201 < try { 202 < appName = MessageFormat.format(NbBundle.getBundle("org.netbeans.core.windows.view.ui.Bundle").getString("CTL_MainWindow_Title_No_Project"),version ? System.getProperty("netbeans.buildnumber"):""); 203 < } catch (MissingResourceException x) { 204 < appName = "NetBeans"+(version? " "+System.getProperty("netbeans.buildnumber"):""); 205 < } 206 < return appName.toCharArray(); 207 --- 208 > return "JOSM".toCharArray(); 209 diff -r src-netbeans-524f40b94a30-origin/org/netbeans/modules/keyring/mac/MacProvider.java src/org/netbeans/modules/keyring/mac/MacProvider.java 210 50,51d49 211 < import org.openide.util.Utilities; 212 < import org.openide.util.lookup.ServiceProvider; 213 53d50 214 < @ServiceProvider(service=KeyringProvider.class, position=200) 215 59,63c56 216 < if (Boolean.getBoolean("netbeans.keyring.no.native")) { 217 < LOG.fine("native keyring integration disabled"); 218 < return false; 219 < } 220 < return Utilities.isMac(); 221 --- 222 > return true; // test elsewhere if we are on a mac 223 69c62 224 < byte[] accountName = "NetBeans".getBytes("UTF-8"); 225 --- 226 > byte[] accountName = "JOSM".getBytes("UTF-8"); 227 89c82 228 < byte[] accountName = "NetBeans".getBytes("UTF-8"); 229 --- 230 > byte[] accountName = "JOSM".getBytes("UTF-8"); 231 103c96 232 < byte[] accountName = "NetBeans".getBytes("UTF-8"); 233 --- 234 > byte[] accountName = "JOSM".getBytes("UTF-8"); 235 diff -r src-netbeans-524f40b94a30-origin/org/netbeans/modules/keyring/win32/Win32Protect.java src/org/netbeans/modules/keyring/win32/Win32Protect.java 236 57,58d56 237 < import org.openide.util.Utilities; 238 < import org.openide.util.lookup.ServiceProvider; 239 65d62 240 < @ServiceProvider(service=EncryptionProvider.class, position=100) 241 71,78c68 242 < if (!Utilities.isWindows()) { 243 < LOG.fine("not running on Windows"); 244 < return false; 245 < } 246 < if (Boolean.getBoolean("netbeans.keyring.no.native")) { 247 < LOG.fine("native keyring integration disabled"); 248 < return false; 249 < } 250 --- 251 > // asssume, we have windows os 1 Index: native-password-manager/src/org/netbeans/modules/keyring/fallback/FallbackProvider.java 2 =================================================================== 3 --- native-password-manager.orig/src/org/netbeans/modules/keyring/fallback/FallbackProvider.java 2011-07-15 21:52:52.064972526 +0200 4 +++ native-password-manager/src/org/netbeans/modules/keyring/fallback/FallbackProvider.java 2011-07-15 21:17:50.000000000 +0200 5 @@ -42,49 +42,41 @@ 6 7 package org.netbeans.modules.keyring.fallback; 8 9 -import java.util.Arrays; 10 -import java.util.HashMap; 11 -import java.util.Map; 12 import java.util.UUID; 13 -import java.util.concurrent.Callable; 14 import java.util.logging.Level; 15 import java.util.logging.Logger; 16 -import java.util.prefs.BackingStoreException; 17 -import java.util.prefs.Preferences; 18 -import org.netbeans.api.keyring.Keyring; 19 import org.netbeans.modules.keyring.impl.Utils; 20 import org.netbeans.modules.keyring.spi.EncryptionProvider; 21 import org.netbeans.spi.keyring.KeyringProvider; 22 -import org.openide.DialogDisplayer; 23 -import org.openide.NotifyDescriptor; 24 -import org.openide.util.Lookup; 25 -import org.openide.util.NbBundle; 26 -import org.openide.util.NbPreferences; 27 -import org.openide.util.lookup.ServiceProvider; 28 29 /** 30 * Platform-independent keyring provider using a master password and the user directory. 31 */ 32 -@ServiceProvider(service=KeyringProvider.class, position=1000) 33 -public class FallbackProvider implements KeyringProvider, Callable<Void> { 34 +public class FallbackProvider implements KeyringProvider { 35 36 private static final Logger LOG = Logger.getLogger(FallbackProvider.class.getName()); 37 private static final String DESCRIPTION = ".description"; 38 private static final String SAMPLE_KEY = "__sample__"; 39 40 private EncryptionProvider encryption; 41 - 42 + private IPreferences pre; 43 + 44 + // simple interface for a generic preferences store 45 + public interface IPreferences { 46 + String get(String key, String def); 47 + void put(String key, String val); 48 + void remove(String key); 49 + } 50 + 51 + public FallbackProvider(EncryptionProvider encryption, IPreferences pref) { 52 + this.encryption = encryption; 53 + this.pre = pref; 54 + } 55 + 56 public boolean enabled() { 57 - for (EncryptionProvider p : Lookup.getDefault().lookupAll(EncryptionProvider.class)) { 58 - if (p.enabled()) { 59 - encryption = p; 60 - Preferences prefs = prefs(); 61 - Utils.goMinusR(prefs); 62 - p.encryptionChangingCallback(this); 63 - if (!testSampleKey(prefs)) { 64 - continue; 65 - } 66 - LOG.log(Level.FINE, "Using provider: {0}", p); 67 + if (encryption.enabled()) { 68 + if (testSampleKey()) { 69 + LOG.log(Level.FINE, "Using provider: {0}", encryption); 70 return true; 71 } 72 } 73 @@ -92,65 +84,21 @@ 74 return false; 75 } 76 77 - private boolean testSampleKey(Preferences prefs) { 78 - byte[] ciphertext = prefs.getByteArray(SAMPLE_KEY, null); 79 - if (ciphertext == null) { 80 - encryption.freshKeyring(true); 81 - if (_save(SAMPLE_KEY, (SAMPLE_KEY + UUID.randomUUID()).toCharArray(), 82 - NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.sample_key.description"))) { 83 - LOG.fine("saved sample key"); 84 - return true; 85 - } else { 86 - LOG.fine("could not save sample key"); 87 - return false; 88 - } 89 + private boolean testSampleKey() { 90 + encryption.freshKeyring(true); 91 + if (_save(SAMPLE_KEY, (SAMPLE_KEY + UUID.randomUUID()).toCharArray(), 92 + "Sample value ensuring that decryption is working.")) { 93 + LOG.fine("saved sample key"); 94 + return true; 95 } else { 96 - encryption.freshKeyring(false); 97 - while (true) { 98 - try { 99 - if (new String(encryption.decrypt(ciphertext)).startsWith(SAMPLE_KEY)) { 100 - LOG.fine("succeeded in decrypting sample key"); 101 - return true; 102 - } else { 103 - LOG.fine("wrong result decrypting sample key"); 104 - } 105 - } catch (Exception x) { 106 - LOG.log(Level.FINE, "failed to decrypt sample key", x); 107 - } 108 - if (!encryption.decryptionFailed()) { 109 - LOG.fine("sample key decryption failed"); 110 - return promptToDelete(prefs); 111 - } 112 - LOG.fine("will retry decryption of sample key"); 113 - } 114 - } 115 - } 116 - 117 - private boolean promptToDelete(Preferences prefs) { 118 - Object result = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation( 119 - NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.msg_clear_keys"), 120 - NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.title_clear_keys"), 121 - NotifyDescriptor.OK_CANCEL_OPTION)); 122 - if (result == NotifyDescriptor.OK_OPTION) { 123 - try { 124 - LOG.log(Level.FINE, "agreed to delete stored passwords: {0}", Arrays.asList(prefs.keys())); 125 - prefs.clear(); 126 - return testSampleKey(prefs); 127 - } catch (BackingStoreException x) { 128 - LOG.log(Level.INFO, null, x); 129 - } 130 - } else { 131 - LOG.fine("refused to delete stored passwords"); 132 + LOG.fine("could not save sample key"); 133 + return false; 134 } 135 - return false; 136 - } 137 - 138 - private Preferences prefs() { 139 - return NbPreferences.forModule(Keyring.class).node(encryption.id()); 140 } 141 142 public char[] read(String key) { 143 - byte[] ciphertext = prefs().getByteArray(key, null); 144 + String ciphertext_string = pre.get(key, null); 145 + byte[] ciphertext = ciphertext_string == null ? null : Utils.chars2Bytes(ciphertext_string.toCharArray()); 146 if (ciphertext == null) { 147 return null; 148 } 149 @@ -166,47 +114,24 @@ 150 _save(key, password, description); 151 } 152 private boolean _save(String key, char[] password, String description) { 153 - Preferences prefs = prefs(); 154 try { 155 - prefs.putByteArray(key, encryption.encrypt(password)); 156 + byte[] encryptedPasswordByteArray = encryption.encrypt(password); 157 + String encryptedPassword = encryptedPasswordByteArray == null ? null : String.valueOf(Utils.bytes2Chars(encryptedPasswordByteArray)); 158 + pre.put(key, encryptedPassword); 159 } catch (Exception x) { 160 LOG.log(Level.FINE, "failed to encrypt password for " + key, x); 161 return false; 162 } 163 if (description != null) { 164 // Preferences interface gives no access to *.properties comments, so: 165 - prefs.put(key + DESCRIPTION, description); 166 + pre.put(key + DESCRIPTION, description); 167 } 168 return true; 169 } 170 171 public void delete(String key) { 172 - Preferences prefs = prefs(); 173 - prefs.remove(key); 174 - prefs.remove(key + DESCRIPTION); 175 - } 176 - 177 - public Void call() throws Exception { // encryption changing 178 - LOG.fine("encryption changing"); 179 - Map<String,char[]> saved = new HashMap<String,char[]>(); 180 - Preferences prefs = prefs(); 181 - for (String k : prefs.keys()) { 182 - if (k.endsWith(DESCRIPTION)) { 183 - continue; 184 - } 185 - byte[] ciphertext = prefs.getByteArray(k, null); 186 - if (ciphertext == null) { 187 - continue; 188 - } 189 - saved.put(k, encryption.decrypt(ciphertext)); 190 - } 191 - LOG.log(Level.FINE, "reencrypting keys: {0}", saved.keySet()); 192 - encryption.encryptionChanged(); 193 - for (Map.Entry<String,char[]> entry : saved.entrySet()) { 194 - prefs.putByteArray(entry.getKey(), encryption.encrypt(entry.getValue())); 195 - } 196 - LOG.fine("encryption changing finished"); 197 - return null; 198 + pre.remove(key); 199 + pre.remove(key + DESCRIPTION); 200 } 201 202 } 203 Index: native-password-manager/src/org/netbeans/modules/keyring/gnome/GnomeProvider.java 204 =================================================================== 205 --- native-password-manager.orig/src/org/netbeans/modules/keyring/gnome/GnomeProvider.java 2011-07-15 21:53:22.269122311 +0200 206 +++ native-password-manager/src/org/netbeans/modules/keyring/gnome/GnomeProvider.java 2011-07-15 21:17:50.000000000 +0200 207 @@ -43,16 +43,11 @@ 208 package org.netbeans.modules.keyring.gnome; 209 210 import com.sun.jna.Pointer; 211 -import java.text.MessageFormat; 212 -import java.util.MissingResourceException; 213 import java.util.logging.Level; 214 import java.util.logging.Logger; 215 import static org.netbeans.modules.keyring.gnome.GnomeKeyringLibrary.*; 216 import org.netbeans.spi.keyring.KeyringProvider; 217 -import org.openide.util.NbBundle; 218 -import org.openide.util.lookup.ServiceProvider; 219 220 -@ServiceProvider(service=KeyringProvider.class, position=100) 221 public class GnomeProvider implements KeyringProvider { 222 223 private static final Logger LOG = Logger.getLogger(GnomeProvider.class.getName()); 224 @@ -74,14 +69,7 @@ 225 LOG.fine("no GNOME_KEYRING_* environment variable set"); 226 return false; 227 } 228 - String appName; 229 - try { 230 - appName = MessageFormat.format( 231 - NbBundle.getBundle("org.netbeans.core.windows.view.ui.Bundle").getString("CTL_MainWindow_Title_No_Project"), 232 - /*System.getProperty("netbeans.buildnumber")*/"…"); 233 - } catch (MissingResourceException x) { 234 - appName = "NetBeans"; // NOI18N 235 - } 236 + String appName = "JOSM"; 237 try { 238 // Need to do this somewhere, or we get warnings on console. 239 // Also used by confirmation dialogs to give the app access to the login keyring. 240 Index: native-password-manager/src/org/netbeans/modules/keyring/kde/KWalletProvider.java 241 =================================================================== 242 --- native-password-manager.orig/src/org/netbeans/modules/keyring/kde/KWalletProvider.java 2011-07-15 21:53:37.837199499 +0200 243 +++ native-password-manager/src/org/netbeans/modules/keyring/kde/KWalletProvider.java 2011-07-15 21:17:50.000000000 +0200 244 @@ -45,20 +45,15 @@ 245 import java.io.BufferedReader; 246 import java.io.IOException; 247 import java.io.InputStreamReader; 248 -import java.text.MessageFormat; 249 import java.util.Arrays; 250 -import java.util.MissingResourceException; 251 import java.util.logging.Level; 252 import java.util.logging.Logger; 253 import org.netbeans.spi.keyring.KeyringProvider; 254 -import org.openide.util.NbBundle; 255 -import org.openide.util.lookup.ServiceProvider; 256 257 /** 258 * 259 * @author psychollek, ynov 260 */ 261 -@ServiceProvider(service=KeyringProvider.class, position=99) 262 public class KWalletProvider implements KeyringProvider{ 263 264 private static final Logger logger = Logger.getLogger(KWalletProvider.class.getName()); 265 @@ -221,13 +216,7 @@ 266 } 267 268 private char[] getApplicationName(boolean version){ 269 - String appName; 270 - try { 271 - appName = MessageFormat.format(NbBundle.getBundle("org.netbeans.core.windows.view.ui.Bundle").getString("CTL_MainWindow_Title_No_Project"),version ? System.getProperty("netbeans.buildnumber"):""); 272 - } catch (MissingResourceException x) { 273 - appName = "NetBeans"+(version? " "+System.getProperty("netbeans.buildnumber"):""); 274 - } 275 - return appName.toCharArray(); 276 + return "JOSM".toCharArray(); 277 } 278 279 private void warning(String descr) { 280 Index: native-password-manager/src/org/netbeans/modules/keyring/mac/MacProvider.java 281 =================================================================== 282 --- native-password-manager.orig/src/org/netbeans/modules/keyring/mac/MacProvider.java 2011-07-15 21:53:47.897249389 +0200 283 +++ native-password-manager/src/org/netbeans/modules/keyring/mac/MacProvider.java 2011-07-15 21:17:50.000000000 +0200 284 @@ -47,26 +47,19 @@ 285 import java.util.logging.Level; 286 import java.util.logging.Logger; 287 import org.netbeans.spi.keyring.KeyringProvider; 288 -import org.openide.util.Utilities; 289 -import org.openide.util.lookup.ServiceProvider; 290 291 -@ServiceProvider(service=KeyringProvider.class, position=200) 292 public class MacProvider implements KeyringProvider { 293 294 private static final Logger LOG = Logger.getLogger(MacProvider.class.getName()); 295 296 public boolean enabled() { 297 - if (Boolean.getBoolean("netbeans.keyring.no.native")) { 298 - LOG.fine("native keyring integration disabled"); 299 - return false; 300 - } 301 - return Utilities.isMac(); 302 + return true; // test elsewhere if we are on a mac 303 } 304 305 public char[] read(String key) { 306 try { 307 byte[] serviceName = key.getBytes("UTF-8"); 308 - byte[] accountName = "NetBeans".getBytes("UTF-8"); 309 + byte[] accountName = "JOSM".getBytes("UTF-8"); 310 int[] dataLength = new int[1]; 311 Pointer[] data = new Pointer[1]; 312 error("find", SecurityLibrary.LIBRARY.SecKeychainFindGenericPassword(null, serviceName.length, serviceName, 313 @@ -86,7 +79,7 @@ 314 delete(key); // XXX supposed to use SecKeychainItemModifyContent instead, but this seems like too much work 315 try { 316 byte[] serviceName = key.getBytes("UTF-8"); 317 - byte[] accountName = "NetBeans".getBytes("UTF-8"); 318 + byte[] accountName = "JOSM".getBytes("UTF-8"); 319 // Keychain Access seems to expect UTF-8, so do not use Utils.chars2Bytes: 320 byte[] data = new String(password).getBytes("UTF-8"); 321 error("save", SecurityLibrary.LIBRARY.SecKeychainAddGenericPassword(null, serviceName.length, serviceName, 322 @@ -100,7 +93,7 @@ 323 public void delete(String key) { 324 try { 325 byte[] serviceName = key.getBytes("UTF-8"); 326 - byte[] accountName = "NetBeans".getBytes("UTF-8"); 327 + byte[] accountName = "JOSM".getBytes("UTF-8"); 328 Pointer[] itemRef = new Pointer[1]; 329 error("find (for delete)", SecurityLibrary.LIBRARY.SecKeychainFindGenericPassword(null, serviceName.length, serviceName, 330 accountName.length, accountName, null, null, itemRef)); 331 Index: native-password-manager/src/org/netbeans/modules/keyring/win32/Win32Protect.java 332 =================================================================== 333 --- native-password-manager.orig/src/org/netbeans/modules/keyring/win32/Win32Protect.java 2011-07-15 21:53:58.733303122 +0200 334 +++ native-password-manager/src/org/netbeans/modules/keyring/win32/Win32Protect.java 2011-07-15 21:17:50.000000000 +0200 335 @@ -54,28 +54,18 @@ 336 import java.util.logging.Logger; 337 import org.netbeans.modules.keyring.impl.Utils; 338 import org.netbeans.modules.keyring.spi.EncryptionProvider; 339 -import org.openide.util.Utilities; 340 -import org.openide.util.lookup.ServiceProvider; 341 342 /** 343 * Data protection utility for Microsoft Windows. 344 * XXX org.tmatesoft.svn.core.internal.util.jna.SVNWinCrypt is a possibly more robust implementation 345 * (though it seems to set CRYPTPROTECT_UI_FORBIDDEN which we do not necessarily want). 346 */ 347 -@ServiceProvider(service=EncryptionProvider.class, position=100) 348 public class Win32Protect implements EncryptionProvider { 349 350 private static final Logger LOG = Logger.getLogger(Win32Protect.class.getName()); 351 352 public @Override boolean enabled() { 353 - if (!Utilities.isWindows()) { 354 - LOG.fine("not running on Windows"); 355 - return false; 356 - } 357 - if (Boolean.getBoolean("netbeans.keyring.no.native")) { 358 - LOG.fine("native keyring integration disabled"); 359 - return false; 360 - } 361 + // asssume, we have windows os 362 try { 363 if (CryptLib.INSTANCE == null) { 364 LOG.fine("loadLibrary -> null");
Note:
See TracChangeset
for help on using the changeset viewer.