1/* 2 * Copyright 2007 Netflix, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package net.oauth.signature; 18 19import net.oauth.OAuth; 20import net.oauth.OAuthException; 21 22/** 23 * @author John Kristian 24 * @hide 25 */ 26class PLAINTEXT extends OAuthSignatureMethod { 27 28 @Override 29 public String getSignature(String baseString) { 30 return getSignature(); 31 } 32 33 @Override 34 protected boolean isValid(String signature, String baseString) 35 throws OAuthException { 36 return signature.equals(getSignature()); 37 } 38 39 private synchronized String getSignature() { 40 if (signature == null) { 41 signature = OAuth.percentEncode(getConsumerSecret()) + '&' 42 + OAuth.percentEncode(getTokenSecret()); 43 } 44 return signature; 45 } 46 47 private String signature = null; 48 49 @Override 50 public void setConsumerSecret(String consumerSecret) { 51 synchronized (this) { 52 signature = null; 53 } 54 super.setConsumerSecret(consumerSecret); 55 } 56 57 @Override 58 public void setTokenSecret(String tokenSecret) { 59 synchronized (this) { 60 signature = null; 61 } 62 super.setTokenSecret(tokenSecret); 63 } 64 65} 66