- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中com.github.robozonky.app.tenant.ZonkyApiTokenSupplier
类的一些代码示例,展示了ZonkyApiTokenSupplier
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZonkyApiTokenSupplier
类的具体详情如下:
包路径:com.github.robozonky.app.tenant.ZonkyApiTokenSupplier
类名称:ZonkyApiTokenSupplier
[英]Will keep permanent user authentication running in the background.
[中]将保持永久用户身份验证在后台运行。
代码示例来源:origin: com.github.robozonky/robozonky-app
@Override
public void close() { // cancel existing tokens
tokens.forEach((k, v) -> v.close());
}
代码示例来源:origin: RoboZonky/robozonky
@Override
public boolean isAvailable(final OAuthScope scope) {
// either Zonky is not available, or we have already logged out prior to daemon shutdown
return availability.getAsBoolean() && !getTokenSupplier(scope).isClosed();
}
代码示例来源:origin: RoboZonky/robozonky
private ZonkyApiToken refreshOrLogin(final ZonkyApiToken token) {
final ZonkyApiToken result = actuallyRefreshOrLogin(token);
LOGGER.debug("Token changed from {} to {}.", token, result);
return result;
}
代码示例来源:origin: com.github.robozonky/robozonky-app
private synchronized ZonkyApiToken getTokenInAnyWay(final ZonkyApiToken currentToken) {
return currentToken == null ? login() : refreshTokenIfNecessary(currentToken);
}
代码示例来源:origin: com.github.robozonky/robozonky-app
private ZonkyApiToken refreshTokenIfNecessary(final ZonkyApiToken token) {
if (!token.willExpireIn(refresh)) {
return token;
}
LOGGER.debug("Token refresh commencing.");
isUpdating.set(true);
try {
return refreshToken(token);
} catch (final Exception ex) {
LOGGER.debug("Failed refreshing access token, falling back to password.", ex);
return login();
} finally {
isUpdating.set(false);
LOGGER.debug("Token refresh over.");
}
}
代码示例来源:origin: RoboZonky/robozonky
private ZonkyApiToken actuallyRefreshOrLogin(final ZonkyApiToken token) {
if (token.isExpired()) {
LOGGER.debug("Found expired token #{}.", token.getId());
return login();
}
LOGGER.debug("Current token #{} expiring on {}.", token.getId(), token.getExpiresOn());
try {
return refresh(token);
} catch (final Exception ex) {
LOGGER.debug("Failed refreshing access token, falling back to password.", ex);
return login();
}
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void closingLoaded() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
final ZonkyApiToken token = getTokenExpiringIn(Duration.ofSeconds(5));
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> token);
when(oAuth.refresh(any())).thenReturn(token);
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
t.get();
verify(oAuth).login(any(), any(), any());
assertThat(t.isClosed()).isFalse();
t.close();
verify(zonky, only()).logout();
assertThat(t.isClosed()).isTrue();
assertThatThrownBy(t::get).isInstanceOf(IllegalStateException.class);
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void refreshes() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
final ZonkyApiToken token = getTokenExpiringIn(Duration.ofMinutes(5));
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> token);
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
assertThat(t.get()).isEqualTo(token);
skipAheadBy(Duration.ofSeconds(4 * 60 + 56)); // get over the refresh period
final ZonkyApiToken secondToken = getTokenExpiringIn(Duration.ofMinutes(5));
when(oAuth.refresh(any())).thenReturn(secondToken);
assertThat(t.get()).isEqualTo(secondToken);
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void notClosingWhenExpired() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
final ZonkyApiToken token = getTokenExpiringIn(Duration.ZERO);
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> token);
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
t.close();
verify(zonky, never()).logout();
}
}
代码示例来源:origin: com.github.robozonky/robozonky-app
public PowerTenant build(final Duration tokenRefresh) {
if (secrets == null) {
throw new IllegalStateException("Secret provider must be provided.");
}
final ApiProvider apis = api == null ? new ApiProvider() : api;
final Function<ZonkyScope, ZonkyApiTokenSupplier> tokenSupplier =
scope -> new ZonkyApiTokenSupplier(scope, apis, secrets, tokenRefresh);
final SessionInfo sessionInfo = new SessionInfo(secrets.getUsername(), name, dryRun);
return new PowerTenantImpl(sessionInfo, apis, strategyProvider, tokenSupplier);
}
代码示例来源:origin: com.github.robozonky/robozonky-app
@Override
public boolean isAvailable(final ZonkyScope scope) {
return getTokenSupplier(scope).isAvailable();
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void failsOnRefresh() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> getTokenExpiringIn(Duration.ofMinutes(5)));
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
final ZonkyApiToken token = t.get();
assertThat(token).isNotNull();
skipAheadBy(Duration.ofSeconds(4 * 60 + 55)); // get over the refresh period, but not over expiration
doThrow(IllegalStateException.class).when(oAuth).refresh(any());
assertThat(t.get())
.isNotNull()
.isNotSameAs(token);
verify(oAuth).refresh(any()); // make sure refresh was rejected before login was called
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void closingNeverLoaded() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
final ZonkyApiToken token = getTokenExpiringIn(Duration.ofSeconds(5));
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> token);
when(oAuth.refresh(any())).thenReturn(token);
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
t.close();
verify(oAuth, never()).login(any(), any(), any());
verify(zonky, never()).logout();
assertThatThrownBy(t::get).isInstanceOf(IllegalStateException.class);
}
代码示例来源:origin: RoboZonky/robozonky
public PowerTenant build() {
if (secrets == null) {
throw new IllegalStateException("Secret provider must be provided.");
}
final ApiProvider apis = api == null ? new ApiProvider() : api;
final Function<OAuthScope, ZonkyApiTokenSupplier> tokenSupplier =
scope -> new ZonkyApiTokenSupplier(scope, apis, secrets);
final SessionInfo sessionInfo = new SessionInfo(secrets.getUsername(), name, dryRun);
final BooleanSupplier zonkyAvailability = lifecycle == null ? () -> true : () -> lifecycle.get().isOnline();
return new PowerTenantImpl(sessionInfo, apis, zonkyAvailability, strategyProvider, tokenSupplier);
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void newLoginWhenTokenExpiredWithoutRefresh() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
final ZonkyApiToken token = getTokenExpiringIn(Duration.ofMinutes(5));
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> token);
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
assertThat(t.get()).isEqualTo(token);
skipAheadBy(Duration.ofMinutes(6)); // get over the expiration period
final ZonkyApiToken secondToken = getTokenExpiringIn(Duration.ofMinutes(5));
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> secondToken);
assertThat(t.get()).isEqualTo(secondToken);
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void failsOnLogin() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
doThrow(IllegalStateException.class).when(oAuth).login(any(), any(), any());
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
assertThatThrownBy(t::get).isInstanceOf(IllegalStateException.class);
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void availabilityOfToken() {
final ZonkyApiTokenSupplier s = mock(ZonkyApiTokenSupplier.class);
final PowerTenantImpl t = new PowerTenantImpl(SESSION_DRY, null, () -> true, null, scope -> s);
assertThat(t.isAvailable(OAuthScope.SCOPE_APP_WEB)).isTrue();
when(s.isClosed()).thenReturn(true);
assertThat(t.isAvailable(OAuthScope.SCOPE_APP_WEB)).isFalse();
}
代码示例来源:origin: RoboZonky/robozonky
@Override
public void close() {
tokens.forEach((k, v) -> v.close()); // cancel existing tokens
loanCache.get().close(); // clean up the cache
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void reloginsWhenAlreadyExpired() {
final Zonky zonky = mock(Zonky.class);
final OAuth oAuth = mock(OAuth.class);
final ZonkyApiToken token = getTokenExpiringIn(Duration.ofMinutes(5));
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> token);
final ApiProvider api = mockApi(oAuth, zonky);
final ZonkyApiTokenSupplier t = new ZonkyApiTokenSupplier(api, SECRETS);
assertThat(t.get()).isEqualTo(token);
skipAheadBy(Duration.ofMinutes(6)); // get over the expiration period
final ZonkyApiToken secondToken = getTokenExpiringIn(Duration.ofMinutes(5));
when(oAuth.login(eq(OAuthScope.SCOPE_APP_WEB), eq(SECRETS.getUsername()), eq(SECRETS.getPassword())))
.thenAnswer(invocation -> secondToken);
assertThat(t.get()).isEqualTo(secondToken);
}
代码示例来源:origin: RoboZonky/robozonky
@Test
void availabilityOfZonky() {
final ZonkyApiTokenSupplier s = mock(ZonkyApiTokenSupplier.class);
final PowerTenantImpl t = new PowerTenantImpl(SESSION_DRY, null, () -> false, null, scope -> s);
assertThat(t.isAvailable(OAuthScope.SCOPE_APP_WEB)).isFalse();
when(s.isClosed()).thenReturn(true); // token availability makes no difference
assertThat(t.isAvailable(OAuthScope.SCOPE_APP_WEB)).isFalse();
}
我正在尝试与 Outlook 的 API 集成(更具体地说,我想列出用户的联系人,并能够对他们进行一些 CRUD)。 我在 Azure 上创建了一个 Azure 帐户、一个 Office 365 开发
我开始在我的项目中使用 django-tenant-schemas,所有数据表(用户等)完全分离。 我的要求是我可以在私有(private)服务器上为单个客户部署相同的代码库,也可以在云上为多个客户部
我已经完成了单租户身份验证,这对我来说效果很好。现在我正在将应用程序更改为 Multi-Tenancy 身份验证。我已将应用程序从 azure 的单租户更改为 Multi-Tenancy 。但我无法在
我正在尝试使用 Microsoft Graph API 访问电子邮件。当我尝试访问电子邮件时,出现以下错误。 Microsoft.Graph.ServiceException: 'Code: Orga
登录 Azure 网站后收到此错误: AADSTS50194: Application 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx' is not configur
我想从控制台应用程序定期访问 Microsoft Graph,以便将邮件从 Outlook 邮箱复制到数据库。为了以编程方式进行身份验证,我必须使用 Microsoft Graph 的“客户端凭据流”
在尝试使用 prefect server config 生成的 Docker Compose 文件为跨多个代理的 Flow 执行设置 Prefect 0.14.15 时,我惊讶地发现 Prefect
所以我正在开发一个具有多个客户端的应用程序。在每种情况下,用户都可以访问多个具有不同角色的客户端。例如,用户 A 有 ROLE_XX 为 客户端 C1 ,但是 ROLE_YY 为 客户端 C2 . 据
我目前正在制作一个将订阅作为 Multi-Tenancy 应用程序出售的 web 应用程序。我使用的技术是导轨。 但是,它不仅仅是使用当前应用程序的孤立租户。 每个租户创建产品并将其发布到他们的个人应
我试图在STS中使用带有Grails的Multi-Tenant插件。为此,我在BuildConfig.groovy中输入了一个条目,该条目编译为“:multi-tenant-single-db:0.8
我正在使用 Multi-Tenancy 架构设置 django。我浏览了https://django-tenant-schemas.readthedocs.io/en/latest/install.h
在我的终端我可以执行1)第一个命令 python manage.py tenant_command rebuild_index 2)第二个命令。 终端会询问我应该执行哪个模式。为此,我输入名为 xxx
本文整理了Java中com.github.robozonky.app.tenant.ZonkyApiTokenSupplier类的一些代码示例,展示了ZonkyApiTokenSupplier类的具体
我已经安装了 keycloak-angular 包,我使用它就像这样的描述: https://www.npmjs.com/package/keycloak-angular 问题是在我的应用程序中我想要
我正在尝试启动 Prefect 代理,以完成与 Prefect 服务器的设置。我没有使用 prefect server start 进行开箱即用的设置,而是使用 prefect server conf
我们计划将 Azure Service Fabric 用于面向数据的 Multi-Tenancy 应用程序。通常有 100 多个客户,每个客户有 5 - 100 个用户。 查看文档,我得出的结论是,最
我正在尝试在我的应用程序模型上使用 manage.py dumpdata,但我无法在我的转储文件中看到 json 数据,因为我正在使用 django-tenant-schemas 应用程序来管理各种客
我们正在为我们正在构建的自定义 Saas 应用程序评估 Shiro。似乎一个伟大的框架可以完成我们想要的 90% 的工作,开箱即用。我对 Shiro 的理解是基本的,这就是我想要完成的。 我们有多个客
当我尝试使用个人帐户连接 Microsoft Graph 时,我收到以下错误消息:AADSTS7000012:为其他租户获得了授权。 我正在学习本教程 https://github.com/Azure
我正在关注这个:https://learn.microsoft.com/en-us/graph/toolkit/get-started/build-a-web-app 正如所料,我的代码非常简单。我有
我是一名优秀的程序员,十分优秀!