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