s.getPrivateKeyBuilder().setKeyczar(keypair.toString());
user.setSecretData(Secrets.buildUserSecret(userSecret, s.build()));
}
UserData created = authRepository.getUsers().create(user);
{
CredentialData.Builder credentialBuilder = CredentialData.newBuilder();
credentialBuilder.setUserId(created.getId());
credentialBuilder.setKey(username);
// if (!Strings.isNullOrEmpty(password)) {
// PasswordHashData passwordHash = hasher.hash(password);
// credentialBuilder.setPasswordHash(passwordHash);
// }
try {
usernameStore.create(credentialBuilder);
} catch (DuplicateValueException e) {
// TODO: We need to be atomic! ZK supports multi, but it looks
// complicated
throw new WebApplicationException(Status.CONFLICT);
}
}
if (challengeKey != null) {
CredentialData.Builder b = CredentialData.newBuilder();
b.setUserId(created.getId());
b.setKey(challengeKey);
try {
authRepository.getPublicKeyCredentials(request.domain.getId()).create(b);
} catch (DuplicateValueException e) {