DefaultPlexusCipher cipher = new DefaultPlexusCipher(); cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); DefaultPlexusCipher cipher = new DefaultPlexusCipher(); String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); System.out.println( cipher.encryptAndDecorate( passwd, masterPasswd ) );
public MavenSecDispatcher() { try { _cipher = new DefaultPlexusCipher(); } catch (PlexusCipherException e) { throw new RuntimeException(e); } } }
private static String decodePassword(final String encodedPassword, final String key) throws PlexusCipherException { final DefaultPlexusCipher cipher = new DefaultPlexusCipher(); return cipher.decryptDecorated(encodedPassword, key); }
private void decryptCredentials(Settings settings) { try { String masterPassword = null; DefaultPlexusCipher cipher = new DefaultPlexusCipher(); File settingsSecurityFile = new File(SETTINGS_SECURITY_FILE_LOCATION); boolean hasSettingsSecurity = false; SettingsSecurity settingsSecurity = SecUtil.read(SETTINGS_SECURITY_FILE_LOCATION, true); masterPassword = cipher.decryptDecorated( settingsSecurity.getMaster(), DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION); hasSettingsSecurity = true; if (cipher.isEncryptedString(server.getPassword())) { if (hasSettingsSecurity) { server.setPassword(cipher.decryptDecorated(server.getPassword(), masterPassword)); } else { throw new RuntimeException( if (cipher.isEncryptedString(server.getPassphrase())) { if (hasSettingsSecurity) { server.setPassphrase(cipher.decryptDecorated(server.getPassphrase(), masterPassword)); } else { throw new RuntimeException(
private static void show( boolean showMaster ) throws Exception { if( showMaster ) System.out.print("\nsettings master password\n"); else System.out.print("\nsettings server password\n"); System.out.print("enter password: "); BufferedReader r = new BufferedReader( new InputStreamReader( System.in ) ); String pass = r.readLine(); System.out.println("\n"); DefaultPlexusCipher dc = new DefaultPlexusCipher(); DefaultSecDispatcher dd = new DefaultSecDispatcher(); dd._cipher = dc; if( showMaster ) System.out.println( dc.encryptAndDecorate( pass, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); else { SettingsSecurity sec = dd.getSec(); System.out.println( dc.encryptAndDecorate( pass, dd.getMaster(sec) ) ); } } //---------------------------------------------------------------
masterPassword = cipher.decryptDecorated(mavenSecuritySettings.getMaster(), masterMasterPassword); DefaultSecDispatcher dispatcher = new DefaultSecDispatcher(); DefaultSettingsDecrypter decrypter = new DefaultSettingsDecrypter(); if (!cipher.isEncryptedString(proxy.getPassword())) { proxyPasswords.put(proxy.getId(), proxy.getPassword()); if (!cipher.isEncryptedString(server.getPassword())) { serverPasswords.put(server.getId(), server.getPassword());
System.out.println("Encrypted password: " + cipher.encryptAndDecorate(password, masterPassword)); System.out.println("You can use this encrypted password when defining repositories and proxies"); return; String encryptedPassword = cipher.encryptAndDecorate(password, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION); System.out.println("Encrypted master password: " + encryptedPassword); if (persist) {
/** * Adds information used by proxy/server * @param row {@link org.apache.karaf.shell.support.table.ShellTable}'s row to add information to * @param id2Password mapping of ids (servers/proxies to decrypted passwords) * @param id ID of proxy or server from <code>settings.xml</code> * @param password password to use if decryption failed */ protected void addPasswordInfo(Row row, Map<String, String> id2Password, String id, String password) { if (id2Password.containsKey(id)) { row.addContent(id2Password.get(id)); } else { if (cipher.isEncryptedString(password)) { row.addContent(password + " (can't decrypt)"); } else { row.addContent(password == null ? "" : password); } } }
public MavenSecDispatcher() { _configurationFile = "~/.m2/settings-security.xml"; try { _cipher = new DefaultPlexusCipher(); } catch (PlexusCipherException e) { LOGGER.error("Error creating sec dispatcher"); } } }
private static String decodePassword(String encodedPassword, String key) throws PlexusCipherException { DefaultPlexusCipher cipher = new DefaultPlexusCipher(); return cipher.decryptDecorated(encodedPassword, key); }
private String encryptAndDecorate( String passwd ) throws IllegalStateException, SecDispatcherException, PlexusCipherException { String configurationFile = secDispatcher.getConfigurationFile(); if ( configurationFile.startsWith( "~" ) ) { configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); } String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); String master = null; SettingsSecurity sec = SecUtil.read( file, true ); if ( sec != null ) { master = sec.getMaster(); } if ( master == null ) { throw new IllegalStateException( "Master password is not set in the setting security file: " + file ); } DefaultPlexusCipher cipher = new DefaultPlexusCipher(); String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); return cipher.encryptAndDecorate( passwd, masterPasswd ); }
private static PlexusCipher buildCipher() { try { return new DefaultPlexusCipher(); } catch (PlexusCipherException e) { log.error( "Unable to create PlexusCipher in order to decrypt Maven passwords" ); return null; } }
private String encryptAndDecorate( String passwd ) throws IllegalStateException, SecDispatcherException, PlexusCipherException { String configurationFile = secDispatcher.getConfigurationFile(); if ( configurationFile.startsWith( "~" ) ) { configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); } String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); String master = null; SettingsSecurity sec = SecUtil.read( file, true ); if ( sec != null ) { master = sec.getMaster(); } if ( master == null ) { throw new IllegalStateException( "Master password is not set in the setting security file: " + file ); } DefaultPlexusCipher cipher = new DefaultPlexusCipher(); String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); return cipher.encryptAndDecorate( passwd, masterPasswd ); }
public MavenSecDispatcher() { _configurationFile = "~/.m2/settings-security.xml"; try { _cipher = new DefaultPlexusCipher(); } catch (PlexusCipherException e) { LOGGER.error("Error creating sec dispatcher"); } } }
DefaultPlexusCipher cipher = new DefaultPlexusCipher(); System.out.println( cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); DefaultPlexusCipher cipher = new DefaultPlexusCipher(); String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); System.out.println( cipher.encryptAndDecorate( passwd, masterPasswd ) );
SpringBootSecDispatcher() { File file = new File(MavenSettingsReader.this.homeDir, SECURITY_XML); this._configurationFile = file.getAbsolutePath(); try { this._cipher = new DefaultPlexusCipher(); } catch (PlexusCipherException e) { throw new IllegalStateException(e); } }
DefaultPlexusCipher cipher = new DefaultPlexusCipher(); cliRequest.stdout.println( cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); DefaultPlexusCipher cipher = new DefaultPlexusCipher(); String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); cliRequest.stdout.println( cipher.encryptAndDecorate( passwd, masterPasswd ) );
SpringBootSecDispatcher() { File file = getSettingsSecurityFile(); this._configurationFile = file.getAbsolutePath(); try { this._cipher = new DefaultPlexusCipher(); } catch (PlexusCipherException e) { throw new IllegalStateException(e); } } }
DefaultPlexusCipher cipher = new DefaultPlexusCipher(); cliRequest.stdout.println( cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); DefaultPlexusCipher cipher = new DefaultPlexusCipher(); String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); cliRequest.stdout.println( cipher.encryptAndDecorate( passwd, masterPasswd ) );
SpringBootSecDispatcher() { File file = new File(MavenSettingsReader.this.homeDir, SECURITY_XML); this._configurationFile = file.getAbsolutePath(); try { this._cipher = new DefaultPlexusCipher(); } catch (PlexusCipherException ex) { throw new IllegalStateException(ex); } }