private String generateSignature(URL url, String consumerSecret,
			String tokenSecret, String httpMethod, List<QParameter> parameters,
			StringBuffer normalizedUrl, StringBuffer normalizedRequestParameters) {

		String signatureBase = generateSignatureBase(url, httpMethod,
				parameters, normalizedUrl, normalizedRequestParameters);
		byte[] oauthSignature = null;
		try {
			Mac mac = Mac.getInstance(HMACSHA1SignatureType);
			String oauthKey = encode(consumerSecret)
					+ "&"
					+ ((tokenSecret == null || tokenSecret.equals("")) ? ""
							: encode(tokenSecret));
			SecretKeySpec spec = new SecretKeySpec(
					oauthKey.getBytes("US-ASCII"), HMACSHA1SignatureType);
			mac.init(spec);
			oauthSignature = mac.doFinal(signatureBase.getBytes("US-ASCII"));
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
		} catch (InvalidKeyException e) {
			e.printStackTrace();
		} catch (IllegalStateException e) {
			e.printStackTrace();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}

		return Base64Encoder.encode(oauthSignature);
	}