Changeset 35665 in osm for applications
- Timestamp:
- 2020-12-07T18:10:16+01:00 (4 years ago)
- Location:
- applications/editors/josm/plugins/native-password-manager/src/org
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/fallback/FallbackProvider.java
r34634 r35665 91 91 byte[] randomArray = new byte[36]; 92 92 new SecureRandom().nextBytes(randomArray); 93 if (_save(SAMPLE_KEY, (SAMPLE_KEY + new String(randomArray, StandardCharsets.UTF_8)).toCharArray(), 94 "Sample value ensuring that decryption is working.")) { 93 if (_save(SAMPLE_KEY, (SAMPLE_KEY + new String(randomArray, StandardCharsets.UTF_8)).toCharArray())) { 95 94 LOG.fine("saved sample key"); 96 95 return true; … … 117 116 @Override 118 117 public void save(String key, char[] password, String description) { 119 _save(key, password , description);118 _save(key, password); 120 119 } 121 private boolean _save(String key, char[] password, String description) { 120 121 private boolean _save(String key, char[] password) { 122 122 try { 123 123 prefs.putByteArray(key, encryption.encrypt(password)); -
applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/gnome/GnomeKeyringLibrary.java
r34504 r35665 43 43 package org.netbeans.modules.keyring.gnome; 44 44 45 import com.sun.jna.DefaultTypeMapper; 45 import com.sun.jna.DefaultTypeMapper; // NOSONAR 46 46 import com.sun.jna.FromNativeContext; 47 47 import com.sun.jna.Library; … … 68 68 // http://packages.ubuntu.com/search?suite=precise&arch=any&mode=exactfilename&searchon=contents&keywords=libgnome-keyring.so.0 69 69 private static final String EXPLICIT_ONEIRIC = "/usr/lib/libgnome-keyring.so.0"; 70 private static Objectload(Map<String,?> options) {70 private static GnomeKeyringLibrary load(Map<String,?> options) { 71 71 try { 72 return Native.load Library(GENERIC, GnomeKeyringLibrary.class, options);72 return Native.load(GENERIC, GnomeKeyringLibrary.class, options); 73 73 } catch (UnsatisfiedLinkError x) { 74 74 // #203735: on Oneiric, may have trouble finding right lib. … … 76 76 // Unclear if this workaround is still needed for Oneiric with 3.4, but seems harmless to leave it in for now. 77 77 if (new File(EXPLICIT_ONEIRIC).isFile()) { 78 return Native.load Library(EXPLICIT_ONEIRIC, GnomeKeyringLibrary.class, options);78 return Native.load(EXPLICIT_ONEIRIC, GnomeKeyringLibrary.class, options); 79 79 } else { 80 80 throw x; … … 85 85 } 86 86 87 GnomeKeyringLibrary LIBRARY = (GnomeKeyringLibrary)LibFinder.load(Collections.singletonMap(OPTION_TYPE_MAPPER, new DefaultTypeMapper() {87 GnomeKeyringLibrary LIBRARY = LibFinder.load(Collections.singletonMap(OPTION_TYPE_MAPPER, new DefaultTypeMapper() { 88 88 { 89 89 addTypeConverter(Boolean.TYPE, new TypeConverter() { // #198921 … … 107 107 108 108 // GnomeKeyringAttributeList gnome_keyring_attribute_list_new() = g_array_new(FALSE, FALSE, sizeof(GnomeKeyringAttribute)) 109 int GnomeKeyringAttribute_SIZE = Pointer.SIZE * 3; // conservatively: 2 pointers + 1 enum109 int GnomeKeyringAttribute_SIZE = Native.POINTER_SIZE * 3; // conservatively: 2 pointers + 1 enum 110 110 111 111 void gnome_keyring_attribute_list_append_string( … … 146 146 @Override 147 147 protected List<String> getFieldOrder() { 148 return Arrays.asList( new String[] {148 return Arrays.asList( 149 149 "keyring", 150 150 "item_id", 151 151 "attributes", 152 "secret" ,153 });152 "secret" 153 ); 154 154 } 155 155 } -
applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/kde/KWalletProvider.java
r34634 r35665 54 54 55 55 /** 56 * 56 * JNA wrapper for certain functions from KDE Wallet API. 57 57 * @author psychollek, ynov 58 58 */ 59 public class KWalletProvider implements KeyringProvider {59 public class KWalletProvider implements KeyringProvider { 60 60 61 61 private static final Logger logger = Logger.getLogger(KWalletProvider.class.getName()); -
applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/mac/SecurityLibrary.java
r30822 r35665 43 43 package org.netbeans.modules.keyring.mac; 44 44 45 import com.sun.jna.Library; 45 import com.sun.jna.Library; // NOSONAR 46 46 import com.sun.jna.Native; 47 47 import com.sun.jna.Pointer; … … 52 52 public interface SecurityLibrary extends Library { 53 53 54 SecurityLibrary LIBRARY = (SecurityLibrary) Native.loadLibrary("Security", SecurityLibrary.class);54 SecurityLibrary LIBRARY = Native.load("Security", SecurityLibrary.class); 55 55 56 56 int SecKeychainAddGenericPassword( -
applications/editors/josm/plugins/native-password-manager/src/org/netbeans/modules/keyring/win32/Win32Protect.java
r30822 r35665 43 43 package org.netbeans.modules.keyring.win32; 44 44 45 import com.sun.jna.Memory; 45 import com.sun.jna.Memory; // NOSONAR 46 46 import com.sun.jna.Native; 47 47 import com.sun.jna.Pointer; … … 126 126 127 127 public interface CryptLib extends StdCallLibrary { 128 CryptLib INSTANCE = (CryptLib) Native.loadLibrary("Crypt32", CryptLib.class); // NOI18N128 CryptLib INSTANCE = Native.load("Crypt32", CryptLib.class); // NOI18N 129 129 /** @see <a href="http://msdn.microsoft.com/en-us/library/aa380261(VS.85,printer).aspx">Reference</a> */ 130 130 boolean CryptProtectData( … … 167 167 @Override 168 168 protected List<String> getFieldOrder() { 169 return Arrays.asList( new String[] {169 return Arrays.asList( 170 170 "cbData", 171 "pbData" ,172 });171 "pbData" 172 ); 173 173 } 174 174 } -
applications/editors/josm/plugins/native-password-manager/src/org/openstreetmap/josm/plugins/npm/NPMCredentialsAgent.java
r34634 r35665 25 25 import org.openstreetmap.josm.io.auth.CredentialsAgentException; 26 26 import org.openstreetmap.josm.spi.preferences.Config; 27 import org.openstreetmap.josm.tools.Utils;28 27 29 28 public class NPMCredentialsAgent extends AbstractCredentialsAgent { … … 245 244 } 246 245 if (!sensitive.isEmpty()) { 247 text.append(tr("<br><strong>Warning:</strong> There may be sensitive data left in your preference file. ({0})", Utils.join(", ", sensitive)));246 text.append(tr("<br><strong>Warning:</strong> There may be sensitive data left in your preference file. ({0})", String.join(", ", sensitive))); 248 247 } 249 248 pnlMessage.setText(text.toString()); … … 255 254 return tr("Save user and password ({0})", type.getName()); 256 255 } 257 258 259 256 } -
applications/editors/josm/plugins/native-password-manager/src/org/openstreetmap/josm/plugins/npm/NPMType.java
r34472 r35665 41 41 tr("Encrypt data with Windows logon credentials") 42 42 ); 43 43 44 44 private static String genericIntro(String name) { 45 45 return tr("The native password manager plugin detected {0} on your system.", name); 46 // + "You can let {1} handle your sensitive data from now on. "47 // + "This means your username and password is no longer saved in plain text in your preferences file. "48 // + "(It is still transferred over the network unencrypted, though.)", name, name);49 46 } 50 47 51 48 private final String prefString; 52 private final Class<? extends KeyringProvider> providerClass;53 49 private final String name; 54 private KeyringProvider provider;50 private final KeyringProvider provider; 55 51 private final String introText; 56 52 private final String selectionText; … … 58 54 NPMType(String prefString, Class<? extends KeyringProvider> providerClass, String name, String selectionText) { 59 55 this.prefString = prefString; 60 this.providerClass = providerClass; 56 if (providerClass != null) { 57 try { 58 this.provider = providerClass.getDeclaredConstructor().newInstance(); 59 } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException ex) { 60 throw new JosmRuntimeException(ex); 61 } 62 } else { 63 this.provider = null; 64 } 61 65 this.name = name; 62 66 this.introText = genericIntro(name); … … 90 94 91 95 public KeyringProvider getProvider() { 92 if (providerClass == null) return null;93 if (provider == null) {94 try {95 provider = providerClass.getDeclaredConstructor().newInstance();96 } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException ex) {97 throw new JosmRuntimeException(ex);98 }99 }100 96 return provider; 101 97 }
Note:
See TracChangeset
for help on using the changeset viewer.