public String decrypt( String encodedPassword, String encoding ) throws PlexusCipherException { // check if the password is encrypted if ( !plexusCipher.isEncryptedString( encodedPassword ) ) { return encodedPassword; } if ( encodedPassword != null ) { return plexusCipher.decryptDecorated( encodedPassword, encoding ); } return null; } }
public String encrypt( String password, String encoding ) throws PlexusCipherException { // check if the password is encrypted if ( plexusCipher.isEncryptedString( password ) ) { return password; } if ( password != null ) { return plexusCipher.encryptAndDecorate( password, encoding ); } return null; }
private boolean isEncryptedString(String str) { if (str == null) { return false; } return cipher.isEncryptedString(str); }
private String decrypt(String string, String password) { try { return cipher.decryptDecorated( string, password ); } catch (PlexusCipherException e) { log.warn( "Unable to decrypt Maven password using PlexusCipher", e ); return string; } } }
@Override public String decrypt(String str) throws SecDispatcherException { if (!isEncryptedString(str)) { return str; } String bare = null; try { bare = cipher.unDecorate(str); } catch (PlexusCipherException e1) { throw new SecDispatcherException(e1); } Map<String, String> attr = stripAttributes(bare); String res = null; if (attr == null || attr.get("type") == null) { String master = getMaster(); try { res = cipher.decrypt(bare, master); } catch (PlexusCipherException e) { throw new SecDispatcherException("Unable to decrypt encrypted string", e); } } else { String type = (String) attr.get(TYPE_ATTR); throw new UnsupportedOperationException("Unable to lookup security dispatched of type " + type); } return res; }
public String encrypt( String password, String encoding ) throws PlexusCipherException { if ( password != null ) { return plexusCipher.encryptAndDecorate( password, encoding ); } return null; }
private boolean isEncryptedString(String str) { if (str == null) { return false; } return cipher.isEncryptedString(str); }
private String getMaster() throws SecDispatcherException { if (securitySettings == null) { throw new IllegalStateException( "Unable to get security configuration from " + securitySettingsPath.getPath() + "."); } String master = securitySettings.getMaster(); if (master == null) { throw new IllegalStateException("Security configuration from " + securitySettingsPath.getPath() + " does not contain master password"); } try { return cipher.decryptDecorated(master, DEFAULT_PASSPHRASE); } catch (PlexusCipherException e) { throw new SecDispatcherException(e); } } }
@Override public String decrypt(String str) throws SecDispatcherException { if (!isEncryptedString(str)) { return str; } String bare = null; try { bare = cipher.unDecorate(str); } catch (PlexusCipherException e1) { throw new SecDispatcherException(e1); } Map<String, String> attr = stripAttributes(bare); String res = null; if (attr == null || attr.get("type") == null) { String master = getMaster(); try { res = cipher.decrypt(bare, master); } catch (PlexusCipherException e) { throw new SecDispatcherException("Unable to decrypt encrypted string", e); } } else { String type = (String) attr.get(TYPE_ATTR); throw new UnsupportedOperationException("Unable to lookup security dispatched of type " + type); } return res; }
public String decrypt( String encodedPassword, String encoding ) throws PlexusCipherException { // check if the password is encrypted if ( !plexusCipher.isEncryptedString( encodedPassword ) ) { return encodedPassword; } if ( encodedPassword != null ) { return plexusCipher.decryptDecorated( encodedPassword, encoding ); } return null; } }
private boolean isEncryptedString( String str ) { if( str == null ) return false; return _cipher.isEncryptedString( str ); } //----------------------------------------------------------------------------
private String getMaster() throws SecDispatcherException, InvalidConfigurationFileException { if (securitySettings == null) { throw new InvalidConfigurationFileException( "Unable to get security configuration from " + securitySettingsPath.getPath() + ". Please define path to the settings-security.xml file via -D" + MavenSettingsBuilder.ALT_SECURITY_SETTINGS_XML_LOCATION + ", or put it the the default location defined by Maven."); } String master = securitySettings.getMaster(); if (master == null) { throw new InvalidConfigurationFileException("Security configuration from " + securitySettingsPath.getPath() + " does not contain master password"); } try { return cipher.decryptDecorated(master, DEFAULT_PASSPHRASE); } catch (PlexusCipherException e) { throw new SecDispatcherException(e); } } }
@Override public String decrypt(String str) throws SecDispatcherException { if (!isEncryptedString(str)) { return str; } String bare = null; try { bare = cipher.unDecorate(str); } catch (PlexusCipherException e1) { throw new SecDispatcherException(e1); } Map<String, String> attr = stripAttributes(bare); String res = null; if (attr == null || attr.get("type") == null) { String master = getMaster(); try { res = cipher.decrypt(bare, master); } catch (PlexusCipherException e) { throw new SecDispatcherException("Unable to decrypt encrypted string", e); } } else { String type = (String) attr.get(TYPE_ATTR); throw new UnsupportedOperationException("Unable to lookup security dispatched of type " + type); } return res; }
private boolean isEncryptedString(String str) { if (str == null) { return false; } return cipher.isEncryptedString(str); }
private String getMaster() throws SecDispatcherException, InvalidConfigurationFileException { if (securitySettings == null) { throw new InvalidConfigurationFileException( "Unable to get security configuration from " + securitySettingsPath.getPath() + ". Please define path to the settings-security.xml file via -D" + MavenSettingsBuilder.ALT_SECURITY_SETTINGS_XML_LOCATION + ", or put it the the default location defined by Maven."); } String master = securitySettings.getMaster(); if (master == null) { throw new InvalidConfigurationFileException("Security configuration from " + securitySettingsPath.getPath() + " does not contain master password"); } try { return cipher.decryptDecorated(master, DEFAULT_PASSPHRASE); } catch (PlexusCipherException e) { throw new SecDispatcherException(e); } } }
bare = _cipher.unDecorate( str ); res = _cipher.decrypt( bare, master );
private boolean isEncryptedString( String str ) { return cipher.isEncryptedString( str ); }
private String getMaster( SettingsSecurity sec ) throws SecDispatcherException { String master = sec.getMaster(); if( master == null ) throw new SecDispatcherException( "master password is not set" ); try { return _cipher.decryptDecorated( master, SYSTEM_PROPERTY_SEC_LOCATION ); } catch ( PlexusCipherException e ) { throw new SecDispatcherException(e); } } //---------------------------------------------------------------
/** * Gets a {@link PasswordProcessor} instance for the given password. * * @param password The password to handle. * @return A processor for the given password. */ public static PasswordProcessor getInstance(String password) { PlexusCipher cipher = buildCipher(); if ( cipher == null || !cipher.isEncryptedString( password ) ) { return new DefaultPasswordProcessor( password ); } else { return new DecryptionProcessor( password, cipher ); } }