mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 15:11:52 -05:00
xargs astyle --style=ansi --mode=java --indent-switches \
--indent=spaces=4 --convert-tabs --unpad=paren
This commit is contained in:
parent
5a85446779
commit
3914a78b53
@ -433,7 +433,8 @@ public class Account implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean getLeftHanded() {
|
public boolean getLeftHanded()
|
||||||
|
{
|
||||||
return mLeftHanded;
|
return mLeftHanded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +739,7 @@ public class MessagingController implements Runnable
|
|||||||
if (K9.DEBUG)
|
if (K9.DEBUG)
|
||||||
{
|
{
|
||||||
Log.d(K9.LOG_TAG, "SYNC: About to process pending commands for account " +
|
Log.d(K9.LOG_TAG, "SYNC: About to process pending commands for account " +
|
||||||
account.getDescription() );
|
account.getDescription());
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ public class ActivityListener extends MessagingListener
|
|||||||
String progress = null;
|
String progress = null;
|
||||||
if (mLoadingAccountDescription != null || mSendingAccountDescription != null || mProcessingAccountDescription != null)
|
if (mLoadingAccountDescription != null || mSendingAccountDescription != null || mProcessingAccountDescription != null)
|
||||||
{
|
{
|
||||||
progress = (mFolderTotal > 0 ? context.getString(R.string.folder_progress, mFolderCompleted, mFolderTotal) : "" );
|
progress = (mFolderTotal > 0 ? context.getString(R.string.folder_progress, mFolderCompleted, mFolderTotal) : "");
|
||||||
|
|
||||||
if (mLoadingFolderName != null)
|
if (mLoadingFolderName != null)
|
||||||
{
|
{
|
||||||
|
@ -130,8 +130,8 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||||||
|
|
||||||
SpinnerOption authTypes[] =
|
SpinnerOption authTypes[] =
|
||||||
{
|
{
|
||||||
new SpinnerOption(0, "PLAIN" ),
|
new SpinnerOption(0, "PLAIN"),
|
||||||
new SpinnerOption(1, "CRAM_MD5" )
|
new SpinnerOption(1, "CRAM_MD5")
|
||||||
};
|
};
|
||||||
|
|
||||||
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
ArrayAdapter<SpinnerOption> securityTypesAdapter = new ArrayAdapter<SpinnerOption>(this,
|
||||||
|
@ -1907,11 +1907,11 @@ public class ImapStore extends Store
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( mAuthType == AuthType.CRAM_MD5 )
|
if (mAuthType == AuthType.CRAM_MD5)
|
||||||
{
|
{
|
||||||
authCramMD5();
|
authCramMD5();
|
||||||
}
|
}
|
||||||
else if ( mAuthType == AuthType.PLAIN )
|
else if (mAuthType == AuthType.PLAIN)
|
||||||
{
|
{
|
||||||
executeSimpleCommand("LOGIN \"" + escapeString(mUsername) + "\" \"" + escapeString(mPassword) + "\"", true);
|
executeSimpleCommand("LOGIN \"" + escapeString(mUsername) + "\" \"" + escapeString(mPassword) + "\"", true);
|
||||||
}
|
}
|
||||||
@ -2022,78 +2022,78 @@ public class ImapStore extends Store
|
|||||||
String tag = sendCommand("AUTHENTICATE CRAM-MD5", false);
|
String tag = sendCommand("AUTHENTICATE CRAM-MD5", false);
|
||||||
byte[] buf = new byte[ 1024 ];
|
byte[] buf = new byte[ 1024 ];
|
||||||
int b64NonceLen = 0;
|
int b64NonceLen = 0;
|
||||||
for ( int i = 0; i < buf.length; i++ )
|
for (int i = 0; i < buf.length; i++)
|
||||||
{
|
{
|
||||||
buf[ i ] = (byte)mIn.read();
|
buf[ i ] = (byte)mIn.read();
|
||||||
if ( buf[i] == 0x0a )
|
if (buf[i] == 0x0a)
|
||||||
{
|
{
|
||||||
b64NonceLen = i;
|
b64NonceLen = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( b64NonceLen == 0 )
|
if (b64NonceLen == 0)
|
||||||
{
|
{
|
||||||
throw new AuthenticationFailedException( "Error negotiating CRAM-MD5: nonce too long." );
|
throw new AuthenticationFailedException("Error negotiating CRAM-MD5: nonce too long.");
|
||||||
}
|
}
|
||||||
byte[] b64NonceTrim = new byte[ b64NonceLen - 2 ];
|
byte[] b64NonceTrim = new byte[ b64NonceLen - 2 ];
|
||||||
System.arraycopy(buf, 1, b64NonceTrim, 0, b64NonceLen - 2);
|
System.arraycopy(buf, 1, b64NonceTrim, 0, b64NonceLen - 2);
|
||||||
byte[] nonce = Base64.decodeBase64(b64NonceTrim);
|
byte[] nonce = Base64.decodeBase64(b64NonceTrim);
|
||||||
if ( K9.DEBUG )
|
if (K9.DEBUG)
|
||||||
{
|
{
|
||||||
Log.d(K9.LOG_TAG, "Got nonce: " + new String( b64NonceTrim, "US-ASCII" ) );
|
Log.d(K9.LOG_TAG, "Got nonce: " + new String(b64NonceTrim, "US-ASCII"));
|
||||||
Log.d(K9.LOG_TAG, "Plaintext nonce: " + new String( nonce, "US-ASCII" ) );
|
Log.d(K9.LOG_TAG, "Plaintext nonce: " + new String(nonce, "US-ASCII"));
|
||||||
}
|
}
|
||||||
byte[] ipad = new byte[64];
|
byte[] ipad = new byte[64];
|
||||||
byte[] opad = new byte[64];
|
byte[] opad = new byte[64];
|
||||||
byte[] secretBytes = mPassword.getBytes("US-ASCII");
|
byte[] secretBytes = mPassword.getBytes("US-ASCII");
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
if ( secretBytes.length > 64 )
|
if (secretBytes.length > 64)
|
||||||
{
|
{
|
||||||
secretBytes = md.digest(secretBytes);
|
secretBytes = md.digest(secretBytes);
|
||||||
}
|
}
|
||||||
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
||||||
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
||||||
for ( int i = 0; i < ipad.length; i++ ) ipad[i] ^= 0x36;
|
for (int i = 0; i < ipad.length; i++) ipad[i] ^= 0x36;
|
||||||
for ( int i = 0; i < opad.length; i++ ) opad[i] ^= 0x5c;
|
for (int i = 0; i < opad.length; i++) opad[i] ^= 0x5c;
|
||||||
md.update(ipad);
|
md.update(ipad);
|
||||||
byte[] firstPass = md.digest(nonce);
|
byte[] firstPass = md.digest(nonce);
|
||||||
md.update(opad);
|
md.update(opad);
|
||||||
byte[] result = md.digest(firstPass);
|
byte[] result = md.digest(firstPass);
|
||||||
String plainCRAM = mUsername + " " + new String(Hex.encodeHex(result));
|
String plainCRAM = mUsername + " " + new String(Hex.encodeHex(result));
|
||||||
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
||||||
if ( K9.DEBUG )
|
if (K9.DEBUG)
|
||||||
{
|
{
|
||||||
Log.d(K9.LOG_TAG, "Username == " + mUsername);
|
Log.d(K9.LOG_TAG, "Username == " + mUsername);
|
||||||
Log.d( K9.LOG_TAG, "plainCRAM: " + plainCRAM );
|
Log.d(K9.LOG_TAG, "plainCRAM: " + plainCRAM);
|
||||||
Log.d( K9.LOG_TAG, "b64CRAM: " + new String(b64CRAM, "US-ASCII"));
|
Log.d(K9.LOG_TAG, "b64CRAM: " + new String(b64CRAM, "US-ASCII"));
|
||||||
}
|
}
|
||||||
mOut.write( b64CRAM );
|
mOut.write(b64CRAM);
|
||||||
mOut.write( new byte[] { 0x0d, 0x0a } );
|
mOut.write(new byte[] { 0x0d, 0x0a });
|
||||||
mOut.flush();
|
mOut.flush();
|
||||||
int respLen = 0;
|
int respLen = 0;
|
||||||
for ( int i = 0; i < buf.length; i++ )
|
for (int i = 0; i < buf.length; i++)
|
||||||
{
|
{
|
||||||
buf[ i ] = (byte)mIn.read();
|
buf[ i ] = (byte)mIn.read();
|
||||||
if ( buf[i] == 0x0a )
|
if (buf[i] == 0x0a)
|
||||||
{
|
{
|
||||||
respLen = i;
|
respLen = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String toMatch = tag + " OK";
|
String toMatch = tag + " OK";
|
||||||
String respStr = new String( buf, 0, respLen );
|
String respStr = new String(buf, 0, respLen);
|
||||||
if ( !respStr.startsWith( toMatch ) )
|
if (!respStr.startsWith(toMatch))
|
||||||
{
|
{
|
||||||
throw new AuthenticationFailedException( "CRAM-MD5 error: " + respStr );
|
throw new AuthenticationFailedException("CRAM-MD5 error: " + respStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( IOException ioe )
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
throw new AuthenticationFailedException( "CRAM-MD5 Auth Failed." );
|
throw new AuthenticationFailedException("CRAM-MD5 Auth Failed.");
|
||||||
}
|
}
|
||||||
catch ( NoSuchAlgorithmException nsae )
|
catch (NoSuchAlgorithmException nsae)
|
||||||
{
|
{
|
||||||
throw new AuthenticationFailedException( "MD5 Not Available." );
|
throw new AuthenticationFailedException("MD5 Not Available.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1478,7 +1478,7 @@ public class LocalStore extends Store implements Serializable
|
|||||||
cv.put("internal_date", message.getInternalDate() == null
|
cv.put("internal_date", message.getInternalDate() == null
|
||||||
? System.currentTimeMillis() : message.getInternalDate().getTime());
|
? System.currentTimeMillis() : message.getInternalDate().getTime());
|
||||||
String messageId = message.getMessageId();
|
String messageId = message.getMessageId();
|
||||||
if (messageId != null )
|
if (messageId != null)
|
||||||
{
|
{
|
||||||
cv.put("message_id", messageId);
|
cv.put("message_id", messageId);
|
||||||
}
|
}
|
||||||
@ -2281,7 +2281,8 @@ public class LocalStore extends Store implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void loadHeaders() {
|
private void loadHeaders()
|
||||||
|
{
|
||||||
ArrayList<LocalMessage> messages = new ArrayList<LocalMessage>();
|
ArrayList<LocalMessage> messages = new ArrayList<LocalMessage>();
|
||||||
messages.add(this);
|
messages.add(this);
|
||||||
mHeadersLoaded = true; // set true before calling populate headers to stop recursion
|
mHeadersLoaded = true; // set true before calling populate headers to stop recursion
|
||||||
|
@ -500,10 +500,10 @@ public class SmtpTransport extends Transport
|
|||||||
private void saslAuthCramMD5(String username, String password) throws MessagingException,
|
private void saslAuthCramMD5(String username, String password) throws MessagingException,
|
||||||
AuthenticationFailedException, IOException
|
AuthenticationFailedException, IOException
|
||||||
{
|
{
|
||||||
List<String> respList = executeSimpleCommand( "AUTH CRAM-MD5" );
|
List<String> respList = executeSimpleCommand("AUTH CRAM-MD5");
|
||||||
if ( respList.size() != 1 ) throw new AuthenticationFailedException( "Unable to negotiate CRAM-MD5" );
|
if (respList.size() != 1) throw new AuthenticationFailedException("Unable to negotiate CRAM-MD5");
|
||||||
String b64Nonce = respList.get(0);
|
String b64Nonce = respList.get(0);
|
||||||
byte[] nonce = Base64.decodeBase64( b64Nonce.getBytes("US-ASCII") );
|
byte[] nonce = Base64.decodeBase64(b64Nonce.getBytes("US-ASCII"));
|
||||||
byte[] ipad = new byte[64];
|
byte[] ipad = new byte[64];
|
||||||
byte[] opad = new byte[64];
|
byte[] opad = new byte[64];
|
||||||
byte[] secretBytes = password.getBytes("US-ASCII");
|
byte[] secretBytes = password.getBytes("US-ASCII");
|
||||||
@ -512,32 +512,32 @@ public class SmtpTransport extends Transport
|
|||||||
{
|
{
|
||||||
md = MessageDigest.getInstance("MD5");
|
md = MessageDigest.getInstance("MD5");
|
||||||
}
|
}
|
||||||
catch ( NoSuchAlgorithmException nsae )
|
catch (NoSuchAlgorithmException nsae)
|
||||||
{
|
{
|
||||||
throw new AuthenticationFailedException( "MD5 Not Available." );
|
throw new AuthenticationFailedException("MD5 Not Available.");
|
||||||
}
|
}
|
||||||
if ( secretBytes.length > 64 )
|
if (secretBytes.length > 64)
|
||||||
{
|
{
|
||||||
secretBytes = md.digest(secretBytes);
|
secretBytes = md.digest(secretBytes);
|
||||||
}
|
}
|
||||||
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
System.arraycopy(secretBytes, 0, ipad, 0, secretBytes.length);
|
||||||
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
System.arraycopy(secretBytes, 0, opad, 0, secretBytes.length);
|
||||||
for ( int i = 0; i < ipad.length; i++ ) ipad[i] ^= 0x36;
|
for (int i = 0; i < ipad.length; i++) ipad[i] ^= 0x36;
|
||||||
for ( int i = 0; i < opad.length; i++ ) opad[i] ^= 0x5c;
|
for (int i = 0; i < opad.length; i++) opad[i] ^= 0x5c;
|
||||||
md.update(ipad);
|
md.update(ipad);
|
||||||
byte[] firstPass = md.digest(nonce);
|
byte[] firstPass = md.digest(nonce);
|
||||||
md.update(opad);
|
md.update(opad);
|
||||||
byte[] result = md.digest(firstPass);
|
byte[] result = md.digest(firstPass);
|
||||||
String plainCRAM = username + " " + new String(Hex.encodeHex(result));
|
String plainCRAM = username + " " + new String(Hex.encodeHex(result));
|
||||||
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
byte[] b64CRAM = Base64.encodeBase64(plainCRAM.getBytes("US-ASCII"));
|
||||||
String b64CRAMString = new String( b64CRAM, "US-ASCII" );
|
String b64CRAMString = new String(b64CRAM, "US-ASCII");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
executeSimpleCommand( b64CRAMString );
|
executeSimpleCommand(b64CRAMString);
|
||||||
}
|
}
|
||||||
catch ( MessagingException me )
|
catch (MessagingException me)
|
||||||
{
|
{
|
||||||
throw new AuthenticationFailedException( "Unable to negotiate MD5 CRAM" );
|
throw new AuthenticationFailedException("Unable to negotiate MD5 CRAM");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user