@SuppressWarnings("deprecation")
	public void loadFromRequest(HttpServletRequest request) 
	{
		header = request.getHeader("Authorization");
		System.out.println("Header: "+header);
		oauth_body_hash = null;
		if ( header != null ) {
			if (header.startsWith("OAuth ")) header = header.substring(5);
			String [] parms = header.split(",");
			for ( String parm : parms ) {
				parm = parm.trim();
				if ( parm.startsWith("oauth_body_hash=") ) {
					String [] pieces = parm.split("\"");
					if ( pieces.length == 2 ) oauth_body_hash = URLDecoder.decode(pieces[1]);
				}
				if ( parm.startsWith("oauth_consumer_key=") ) {
					String [] pieces = parm.split("\"");
					if ( pieces.length == 2 ) oauth_consumer_key = URLDecoder.decode(pieces[1]);
				}
			}
		}		

		if ( oauth_body_hash == null ) {
			errorMessage = "Did not find oauth_body_hash";
			Log.info(errorMessage+"\n"+header);
			return;
		}

		System.out.println("OBH="+oauth_body_hash);
        byte[] buf = new byte[1024];
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		int chars = 0;
		try {
			ServletInputStream is = request.getInputStream();
			int readNum;
			do {
				readNum = is.read(buf);
				if (readNum>0) {
					bos.write(buf, 0, readNum); 
					chars = chars + readNum;
					// We dont' want a DOS
					if ( chars > 10000000 ) {
						errorMessage = "Message body size exceeded";
						return;
					}
				}
			} while (readNum>=0);
		} catch(Exception e) {
			errorMessage = "Could not read message body:"+e.getMessage();
			return;
		}

        byte[] bytes = bos.toByteArray();

		try {
			postBody = new String(bytes, "UTF-8");
			MessageDigest md = MessageDigest.getInstance("SHA1");
			md.update(bytes); 
			byte[] output = Base64.encodeBase64(md.digest());
			String hash = new String(output);
			System.out.println("HASH="+hash+" bytes="+bytes.length);
			if ( ! hash.equals(oauth_body_hash) ) {
				errorMessage = "Body hash does not match. bytes="+bytes.length;
				System.out.println(postBody);
				return;
			}
		} catch (Exception e) {
			errorMessage = "Could not compute body hash.  bytes="+bytes.length;
			return;
		}
		valid = true;  // So far we are valid
	}
@SuppressWarnings("deprecation")
	public void loadFromRequest(HttpServletRequest request) 
	{
		header = request.getHeader("Authorization");
		System.out.println("Header: "+header);
		oauth_body_hash = null;
		if ( header != null ) {
			if (header.startsWith("OAuth ")) header = header.substring(5);
			String [] parms = header.split(",");
			for ( String parm : parms ) {
				parm = parm.trim();
				if ( parm.startsWith("oauth_body_hash=") ) {
					String [] pieces = parm.split("\"");
					if ( pieces.length == 2 ) oauth_body_hash = URLDecoder.decode(pieces[1]);
				}
				if ( parm.startsWith("oauth_consumer_key=") ) {
					String [] pieces = parm.split("\"");
					if ( pieces.length == 2 ) oauth_consumer_key = URLDecoder.decode(pieces[1]);
				}
			}
		}		

		if ( oauth_body_hash == null ) {
			errorMessage = "Did not find oauth_body_hash";
			Log.info(errorMessage+"\n"+header);
			return;
		}

		System.out.println("OBH="+oauth_body_hash);
        byte[] buf = new byte[1024];
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		int chars = 0;
		try {
			ServletInputStream is = request.getInputStream();
			int readNum;
			do {
				readNum = is.read(buf);
				if (readNum>0) {
					bos.write(buf, 0, readNum); 
					chars = chars + readNum;
					
					if ( chars > 10000000 ) {
						errorMessage = "Message body size exceeded";
						return;
					}
				}
			} while (readNum>=0);
		} catch(Exception e) {
			errorMessage = "Could not read message body:"+e.getMessage();
			return;
		}

        byte[] bytes = bos.toByteArray();

		try {
			postBody = new String(bytes, "UTF-8");
			MessageDigest md = MessageDigest.getInstance("SHA1");
			md.update(bytes); 
			byte[] output = Base64.encodeBase64(md.digest());
			String hash = new String(output);
			System.out.println("HASH="+hash+" bytes="+bytes.length);
			if ( ! hash.equals(oauth_body_hash) ) {
				errorMessage = "Body hash does not match. bytes="+bytes.length;
				System.out.println(postBody);
				return;
			}
		} catch (Exception e) {
			errorMessage = "Could not compute body hash.  bytes="+bytes.length;
			return;
		}
		valid = true;  
	}
@ SuppressWarnings ( "deprecation" ) public void loadFromRequest ( HttpServletRequest request ) { header = request . getHeader ( "Authorization" ) ; System . out . println ( "Header: " + header ) ; oauth_body_hash = null ; if ( header != null ) { if ( header . startsWith ( "OAuth " ) ) header = header . substring ( 5 ) ; String [ ] parms = header . split ( "," ) ; for ( String parm : parms ) { parm = parm . trim ( ) ; if ( parm . startsWith ( "oauth_body_hash=" ) ) { String [ ] pieces = parm . split ( "\"" ) ; if ( pieces . length == 2 ) oauth_body_hash = URLDecoder . decode ( pieces [ 1 ] ) ; } if ( parm . startsWith ( "oauth_consumer_key=" ) ) { String [ ] pieces = parm . split ( "\"" ) ; if ( pieces . length == 2 ) oauth_consumer_key = URLDecoder . decode ( pieces [ 1 ] ) ; } } } if ( oauth_body_hash == null ) { errorMessage = "Did not find oauth_body_hash" ; Log . info ( errorMessage + "\n" + header ) ; return ; } System . out . println ( "OBH=" + oauth_body_hash ) ; byte [ ] buf = new byte [ 1024 ] ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; int chars = 0 ; try { ServletInputStream is = request . getInputStream ( ) ; int readNum ; do { readNum = is . read ( buf ) ; if ( readNum > 0 ) { bos . write ( buf , 0 , readNum ) ; chars = chars + readNum ; // We dont' want a DOS if ( chars > 10000000 ) { errorMessage = "Message body size exceeded" ; return ; } } } while ( readNum >= 0 ) ; } catch ( Exception e ) { errorMessage = "Could not read message body:" + e . getMessage ( ) ; return ; } byte [ ] bytes = bos . toByteArray ( ) ; try { postBody = new String ( bytes , "UTF-8" ) ; MessageDigest md = MessageDigest . getInstance ( "SHA1" ) ; md . update ( bytes ) ; byte [ ] output = Base64 . encodeBase64 ( md . digest ( ) ) ; String hash = new String ( output ) ; System . out . println ( "HASH=" + hash + " bytes=" + bytes . length ) ; if ( ! hash . equals ( oauth_body_hash ) ) { errorMessage = "Body hash does not match. bytes=" + bytes . length ; System . out . println ( postBody ) ; return ; } } catch ( Exception e ) { errorMessage = "Could not compute body hash.  bytes=" + bytes . length ; return ; } valid = true ; // So far we are valid }
Load but do not check the authentication
Load but do not check the authentication