@Test public void testGetPasswordAuthentication() { Properties props = mock( Properties.class ); doReturn( "default_test_user_name" ).when( props ).getProperty( "mail.user" ); doReturn( "default_test_user_password" ).when( props ).getProperty( "mail.password" ); doReturn( "test_user_name" ).when( props ).getProperty( "mail.null.user", "default_test_user_name" ); doReturn( "test_user_password" ).when( props ).getProperty( "mail.null.password", "default_test_user_password" ); DefaultAuthenticator auth = new DefaultAuthenticator( props ); PasswordAuthentication credential = auth.getPasswordAuthentication(); assertThat( credential, is( notNullValue() ) ); assertThat( credential.getUserName(), is( equalTo( "test_user_name" ) ) ); assertThat( credential.getPassword(), is( equalTo( "test_user_password" ) ) ); }
protected PasswordAuthentication getPasswordAuthentication() { final String protocol = getRequestingProtocol(); final String userName = properties.getProperty( "mail." + protocol + ".user", properties.getProperty( "mail.user" ) ); final String password = properties.getProperty( "mail." + protocol + ".password", properties.getProperty( "mail.password" ) ); return new PasswordAuthentication( userName, password ); }
DefaultAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { final String protocol = getRequestingProtocol(); final String userName = properties.getProperty( "mail." + protocol + ".user", properties.getProperty( "mail.user" ) ); final String password = properties.getProperty( "mail." + protocol + ".password", properties.getProperty( "mail.password" ) ); return new PasswordAuthentication( userName, password ); } }
DefaultAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { final String protocol = getRequestingProtocol(); final String userName = properties.getProperty( "mail." + protocol + ".user", properties.getProperty( "mail.user" ) ); final String password = properties.getProperty( "mail." + protocol + ".password", properties.getProperty( "mail.password" ) ); return new PasswordAuthentication( userName, password ); } DefaultAuthenticator( final Properties properties ); }
DefaultAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { final String protocol = getRequestingProtocol(); final String userName = properties.getProperty( "mail." + protocol + ".user", properties.getProperty( "mail.user" ) ); final String password = properties.getProperty( "mail." + protocol + ".password", properties.getProperty( "mail.password" ) ); return new PasswordAuthentication( userName, password ); } DefaultAuthenticator( final Properties properties );  }
DefaultAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { final String protocol = getRequestingProtocol(); final String userName = properties.getProperty( "mail." + protocol + ".user", properties.getProperty( "mail.user" ) ); final String password = properties.getProperty( "mail." + protocol + ".password", properties.getProperty( "mail.password" ) ); return new PasswordAuthentication( userName, password ); } DefaultAuthenticator( final Properties properties );   }