void NameEditDialog::formattedNameTypeChanged() { QString name; if ( formattedNameType() == CustomName ) name = mCustomFormattedName; else { KABC::Addressee addr; addr.setPrefix( prefix() ); addr.setFamilyName( familyName() ); addr.setAdditionalName( additionalName() ); addr.setGivenName( givenName() ); addr.setSuffix( suffix() ); addr.setOrganization( mAddressee.organization() ); name = formattedName( addr, formattedNameType() ); } mFormattedNameEdit->setText( name ); }
AuthenticationResultPtr OAuth2Response::parseTokenResponse(TokenResponsePtr tokenResponse, CallStatePtr/* callState*/) { Logger::info(Tag(), "parseTokenResponse"); AuthenticationResultPtr result = nullptr; if (!tokenResponse->accessToken.empty()) { auto curTimeUts = QDateTime::currentDateTimeUtc(); Logger::info(Tag(), "curTimeUTC: %; expiresIn: %", curTimeUts.toString("HH:mm:ss MM.dd.yy").toStdString(), tokenResponse->expiresIn); auto expiresUtc = curTimeUts.addSecs(tokenResponse->expiresIn); DateTimeOffset expiresOn = expiresUtc.toTime_t(); Logger::info(Tag(), "tonken expiresOn: % (%)", expiresUtc.toString("HH:mm:ss MM.dd.yy").toStdString(), expiresOn); result = std::make_shared<AuthenticationResult>(tokenResponse->tokenType, tokenResponse->accessToken, tokenResponse->refreshToken, expiresOn); // This is only needed for AcquireTokenByAuthorizationCode in which parameter resource is optional and we need // to get it from the STS response. result->resource(tokenResponse->resource); result->isMultipleResourceRefreshToken(!tokenResponse->refreshToken.empty() && !tokenResponse->resource.empty()); IdTokenPtr idToken = OAuth2Response::parseIdToken(tokenResponse->idToken); if (idToken != nullptr) { String tenantId = idToken->tenantId; String uniqueId; String displayableId; if (!idToken->objectId.empty()) { uniqueId = idToken->objectId; } else if (!idToken->subject.empty()) { uniqueId = idToken->subject; } if (!idToken->UPN.empty()) { displayableId = idToken->UPN; } else if (!idToken->email.empty()) { displayableId = idToken->email; } String givenName = idToken->givenName; String familyName = idToken->familyName; String identityProvider = idToken->identityProvider.empty() ? idToken->issuer : idToken->identityProvider; DateTimeOffset passwordExpiresOn = 0; if (idToken->passwordExpiration > 0) { passwordExpiresOn = QDateTime::currentDateTimeUtc().addSecs(idToken->passwordExpiration).toTime_t(); } String changePasswordUri; if (!idToken->passwordChangeUrl.empty()) { changePasswordUri = idToken->passwordChangeUrl; } auto userInfo = std::make_shared<UserInfo>(); userInfo->uniqueId(uniqueId); userInfo->displayableId(displayableId); userInfo->givenName(givenName); userInfo->familyName(familyName); userInfo->identityProvider(identityProvider); userInfo->passwordExpiresOn(passwordExpiresOn); userInfo->passwordChangeUrl(changePasswordUri); result->updateTenantAndUserInfo(tenantId, tokenResponse->idToken, userInfo ); } } else if (!tokenResponse->error.empty()) { Logger::error(Tag(), "error: %, description: %", tokenResponse->error, tokenResponse->errorDescription); throw RmsauthException(tokenResponse->error, tokenResponse->errorDescription); } else { throw RmsauthException(Constants::rmsauthError().Unknown); } return result; }