Commit 12f8dece authored by Evan W. Patton's avatar Evan W. Patton Committed by Susan Rati Lane

Address internal error in localhost when adding ChatBot

Change-Id: I3137482dd11767872b0cd3dea06e4c2e180a7a82
parent 0c18ce53
......@@ -94,7 +94,7 @@ public class MockChatBot extends MockNonVisibleComponent {
token.setType(tokenType);
getTokenFromServer();
return; // Callback from getTokenFromServer finishes up
} else if (newValue.substring(0, 1) == "%") {
} else if (newValue.charAt(0) == '%') {
tokenType &= ~EditableProperty.TYPE_NONPERSISTED;
}
token.setType(tokenType);
......@@ -107,13 +107,19 @@ public class MockChatBot extends MockNonVisibleComponent {
Ode.getInstance().getTokenAuthService().getChatBotToken(new OdeAsyncCallback<String>() {
@Override
public void onSuccess(String token) {
EditableProperty tokenProperty = MockChatBot.this.properties.getProperty(PROPERTY_NAME_TOKEN);
if (tokenProperty != null) {
String existingToken = tokenProperty.getValue();
if (!existingToken.isEmpty()) {
LOG.info("bailing on getTokenFromServer existingToken = " + existingToken);
return; // If we have a value, don't over-write it
}
if (token == null) {
onFailure(new UnsupportedOperationException(
"Server is not configured to generate ChatBot tokens."));
return;
}
EditableProperty tokenProperty = properties.getProperty(PROPERTY_NAME_TOKEN);
if (tokenProperty == null) {
return;
}
String existingToken = tokenProperty.getValue();
if (!existingToken.isEmpty()) {
LOG.info("bailing on getTokenFromServer existingToken = " + existingToken);
return; // If we have a value, don't over-write it
}
int tokenType = tokenProperty.getType();
tokenType |= EditableProperty.TYPE_NONPERSISTED;
......
......@@ -5,6 +5,7 @@
package com.google.appinventor.server.tokenauth;
import com.google.appinventor.server.CrashReport;
import com.google.appinventor.server.OdeRemoteServiceServlet;
import com.google.appinventor.server.flags.Flag;
......@@ -17,6 +18,7 @@ import com.google.protobuf.ByteString;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Logger;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
......@@ -58,6 +60,7 @@ import javax.crypto.spec.SecretKeySpec;
*/
public class TokenAuthServiceImpl extends OdeRemoteServiceServlet
implements TokenAuthService {
private static final Logger LOG = Logger.getLogger(TokenAuthServiceImpl.class.getName());
private String SECRET_KEY_UUID = Flag.createFlag("clouddb.uuid.secret", "").get();
private String SECRET_KEY_CLOUD_DB = Flag.createFlag("clouddb.secret", "").get();
......@@ -160,8 +163,7 @@ public class TokenAuthServiceImpl extends OdeRemoteServiceServlet
.setSignature(ByteString.copyFrom(signature)).build().toByteArray();
return (Base58Util.encode(token));
} catch (Exception e) {
e.printStackTrace();
return null;
throw CrashReport.createAndLogError(LOG, null, null, e);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment