public TotpBean(KeycloakSession session, RealmModel realm, UserModel user, URI baseUri) { this.enabled = session.users().configuredForCredentialType(realm.getOTPPolicy().getType(), realm, user); this.contextUrl = baseUri.getPath(); this.totpSecret = randomString(20); this.totpSecretEncoded = Base32.encode(totpSecret.getBytes()); this.keyUri = realm.getOTPPolicy().getKeyURI(realm, user, this.totpSecret); }