lib/src/main/java/edu/berkeley/boinc/rpc/RpcClient.java
public synchronized boolean authorize(String password) {
		if (!isConnected()) {
			return false;
		}
		if(password.length() == 0) return false;
		try {
			// Phase 1: get nonce
			sendRequest("<auth1/>\n");
			String auth1Rsp = receiveReply();
			mRequest.setLength(0);
			Xml.parse(auth1Rsp, new Auth1Parser(mRequest)); // get nonce value
			// Operation: combine nonce & password, make MD5 hash
			mRequest.append(password);
			String nonceHash = Md5.hash(mRequest.toString());
			// Phase 2: send hash to client
			mRequest.setLength(0);
			mRequest.append("<auth2>\n<nonce_hash>");
			mRequest.append(nonceHash);
			mRequest.append("</nonce_hash>\n</auth2>\n");
			sendRequest(mRequest.toString());
			String auth2Rsp = receiveReply();
			mRequest.setLength(0);
			Xml.parse(auth2Rsp, new Auth2Parser(mRequest));
			if (!mRequest.toString().equals("authorized")) {
				if(Logging.DEBUG) Log.d(Logging.TAG, "authorize() - Failure");
				return false;
			}
		}
		catch (IOException e) {
			if(Logging.WARNING) Log.w(Logging.TAG, "error in authorize()", e);
			return false;
		}
		catch (SAXException e) {
			Log.i(Logging.TAG, "Malformed XML received in authorize()");
			return false;
		}
		if(Logging.DEBUG) Log.d(Logging.TAG, "authorize() - Successful");
		return true;
	}
/**
	 * Performs the BOINC authorization towards currently connected client. 
	 * The authorization uses MD5 hash of client's password and random value. 
	 * Clear-text password is never sent over network.
	 * @param password Clear text password used for authorization
	 * @return true for success, false for failure
	 */
Performs the BOINC authorization towards currently connected client.
The authorization uses MD5 hash of client's password and random value.
Clear-text password is never sent over network.
@param password Clear text password used for authorization
@return true for success, false for failure
Performs the BOINC authorization towards currently connected client . The authorization uses MD5 hash of client ' s password and random value . Clear - text password is never sent over network . @param password Clear text password used for authorization @return true for success false for failure
public synchronized boolean authorize(String password) {
		if (!isConnected()) {
			return false;
		}
		if(password.length() == 0) return false;
		try {
			sendRequest("<auth1/>\n");
			String auth1Rsp = receiveReply();
			mRequest.setLength(0);
			Xml.parse(auth1Rsp, new Auth1Parser(mRequest)); 
			mRequest.append(password);
			String nonceHash = Md5.hash(mRequest.toString());
			mRequest.setLength(0);
			mRequest.append("<auth2>\n<nonce_hash>");
			mRequest.append(nonceHash);
			mRequest.append("</nonce_hash>\n</auth2>\n");
			sendRequest(mRequest.toString());
			String auth2Rsp = receiveReply();
			mRequest.setLength(0);
			Xml.parse(auth2Rsp, new Auth2Parser(mRequest));
			if (!mRequest.toString().equals("authorized")) {
				if(Logging.DEBUG) Log.d(Logging.TAG, "authorize() - Failure");
				return false;
			}
		}
		catch (IOException e) {
			if(Logging.WARNING) Log.w(Logging.TAG, "error in authorize()", e);
			return false;
		}
		catch (SAXException e) {
			Log.i(Logging.TAG, "Malformed XML received in authorize()");
			return false;
		}
		if(Logging.DEBUG) Log.d(Logging.TAG, "authorize() - Successful");
		return true;
	}
public synchronized boolean authorize ( String password ) { if ( ! isConnected ( ) ) { return false ; } if ( password . length ( ) == 0 ) return false ; try { sendRequest ( "<auth1/>\n" ) ; String auth1Rsp = receiveReply ( ) ; mRequest . setLength ( 0 ) ; Xml . parse ( auth1Rsp , new Auth1Parser ( mRequest ) ) ; mRequest . append ( password ) ; String nonceHash = Md5 . hash ( mRequest . toString ( ) ) ; mRequest . setLength ( 0 ) ; mRequest . append ( "<auth2>\n<nonce_hash>" ) ; mRequest . append ( nonceHash ) ; mRequest . append ( "</nonce_hash>\n</auth2>\n" ) ; sendRequest ( mRequest . toString ( ) ) ; String auth2Rsp = receiveReply ( ) ; mRequest . setLength ( 0 ) ; Xml . parse ( auth2Rsp , new Auth2Parser ( mRequest ) ) ; if ( ! mRequest . toString ( ) . equals ( "authorized" ) ) { if ( Logging . DEBUG ) Log . d ( Logging . TAG , "authorize() - Failure" ) ; return false ; } } catch ( IOException e ) { if ( Logging . WARNING ) Log . w ( Logging . TAG , "error in authorize()" , e ) ; return false ; } catch ( SAXException e ) { Log . i ( Logging . TAG , "Malformed XML received in authorize()" ) ; return false ; } if ( Logging . DEBUG ) Log . d ( Logging . TAG , "authorize() - Successful" ) ; return true ; }
Performs the BOINC authorization towards currently connected client.
Performs the BOINC authorization towards currently connected client .
// Phase 1: get nonce // get nonce value // Operation: combine nonce & password, make MD5 hash // Phase 2: send hash to client