if (challengeKey != null) {
secretService.addPublicKeyAuth(user, challengeKey, request.publicKeyChallengeResponse);
}
KeyczarKey keypair = KeyczarUtils.createKey(new KeyMetadata("RSA Key", KeyPurpose.DECRYPT_AND_ENCRYPT,
DefaultKeyType.RSA_PRIV));
user.getPublicKeyBuilder().setKeyczar(KeyczarUtils.getPublicKey(keypair).toString());
// Create the secret data
{
if (user.hasSecretData()) {
throw new IllegalStateException();
}
UserSecretData.Builder s = UserSecretData.newBuilder();
if (Strings.isNullOrEmpty(user.getName())) {
throw new IllegalArgumentException();
}
// s.setVerifyPublicKey(Hashing.md5().hashBytes(publicKey).asLong());
s.getPrivateKeyBuilder().setKeyczar(keypair.toString());
user.setSecretData(Secrets.buildUserSecret(userSecret, s.build()));
}
UserData created = authRepository.getUsers().create(user);