当前位置: 首页>>代码示例>>Java>>正文


Java EntityType.Unbound方法代码示例

本文整理汇总了Java中com.hp.autonomy.hod.client.api.authentication.EntityType.Unbound方法的典型用法代码示例。如果您正苦于以下问题:Java EntityType.Unbound方法的具体用法?Java EntityType.Unbound怎么用?Java EntityType.Unbound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.autonomy.hod.client.api.authentication.EntityType的用法示例。


在下文中一共展示了EntityType.Unbound方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHmacSign

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
private void testHmacSign(final String expectedHmacToken, final String application) {
    final String tokenId = "DF7aRd8VEeSiCdSFZKbA7w";
    final String tokenSecret = "Ba90fFmxdioyouz06xr1fhn6Nxq4nB90jWEQ2UzDQr8";

    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> token = new AuthenticationToken<>(
        EntityType.Unbound.INSTANCE,
        TokenType.HmacSha1.INSTANCE,
        new DateTime(123),
        tokenId,
        tokenSecret,
        new DateTime(456)
    );

    final Map<String, List<String>> queryParameters = new HashMap<>();
    queryParameters.put("allowed_origins", Collections.singletonList("http://localhost:8080"));

    final Map<String, List<Object>> body = new HashMap<>();
    body.put("domain", Collections.<Object>singletonList("IOD-TEST-DOMAIN"));
    body.put("application", Collections.<Object>singletonList(application));
    body.put("token_type", Collections.<Object>singletonList(TokenType.Simple.INSTANCE.getParameter()));

    final Request<String, Object> request = new Request<>(Request.Verb.POST, "/2/authenticate/combined", queryParameters, body);
    final String hmacToken = hmac.generateToken(request, token);

    assertThat(hmacToken, is(expectedHmacToken));
}
 
开发者ID:hpe-idol,项目名称:java-hod-client,代码行数:27,代码来源:HmacTest.java

示例2: getsNewUnboundToken

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void getsNewUnboundToken() throws InterruptedException, HodErrorException {
    final CountDownLatch latch = new CountDownLatch(1);
    final List<Try<AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1>>> outputs = Collections.synchronizedList(new ArrayList<Try<AuthenticationToken<EntityType.Unbound,TokenType.HmacSha1>>>());

    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> unboundToken = createToken(Hours.ONE);
    mockAuthenticateUnbound().then(new DelayedAnswer<>(unboundToken));
    mockTokenInformation(unboundToken);

    executorService.execute(new UnboundTokenGetter(unboundTokenService, outputs, latch));
    awaitLatch(latch);

    assertThat(outputs, hasSize(1));
    verify(authenticationService, times(1)).authenticateUnbound(any(ApiKey.class), eq(TokenType.HmacSha1.INSTANCE));
    checkOutput(outputs.get(0), unboundToken, null);
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:17,代码来源:UnboundTokenServiceImplTest.java

示例3: getsUnboundTokenFiveTimesButOnlyFetchesOnce

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void getsUnboundTokenFiveTimesButOnlyFetchesOnce() throws HodErrorException, InterruptedException {
    final int times = 5;
    final CountDownLatch latch = new CountDownLatch(times);
    final List<Try<AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1>>> outputs = Collections.synchronizedList(new ArrayList<Try<AuthenticationToken<EntityType.Unbound,TokenType.HmacSha1>>>());

    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> unboundToken = createToken(Hours.ONE);
    mockAuthenticateUnbound().then(new DelayedAnswer<>(unboundToken));
    mockTokenInformation(unboundToken);

    for (int i = 0; i < times; i++) {
        executorService.execute(new UnboundTokenGetter(unboundTokenService, outputs, latch));
    }

    awaitLatch(latch);

    assertThat(outputs, hasSize(times));
    verify(authenticationService, times(1)).authenticateUnbound(any(ApiKey.class), eq(TokenType.HmacSha1.INSTANCE));

    for (int i = 0; i < times; i++) {
        checkOutput(outputs.get(i), unboundToken, null);
    }
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:24,代码来源:UnboundTokenServiceImplTest.java

示例4: getsUnboundTokenAndUUIDButOnlyFetchesOnce

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void getsUnboundTokenAndUUIDButOnlyFetchesOnce() throws HodErrorException, InterruptedException {
    final int times = 2;
    final CountDownLatch latch = new CountDownLatch(times);
    final List<Try<AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1>>> tokenOutputs = Collections.synchronizedList(new ArrayList<Try<AuthenticationToken<EntityType.Unbound,TokenType.HmacSha1>>>());
    final List<Try<UUID>> authenticationUUIDOutputs = Collections.synchronizedList(new ArrayList<Try<UUID>>());

    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> unboundToken = createToken(Hours.ONE);
    mockAuthenticateUnbound().then(new DelayedAnswer<>(unboundToken));
    mockTokenInformation(unboundToken);

    executorService.execute(new UnboundTokenGetter(unboundTokenService, tokenOutputs, latch));
    executorService.execute(new UnboundAuthenticationUUIDGetter(unboundTokenService, authenticationUUIDOutputs, latch));

    awaitLatch(latch);

    assertThat(tokenOutputs, hasSize(1));
    assertThat(authenticationUUIDOutputs, hasSize(1));
    verify(authenticationService, times(1)).authenticateUnbound(any(ApiKey.class), eq(TokenType.HmacSha1.INSTANCE));

    checkOutput(tokenOutputs.get(0), unboundToken, null);
    checkOutput(authenticationUUIDOutputs.get(0), AUTH_UUID, null);
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:24,代码来源:UnboundTokenServiceImplTest.java

示例5: getsUnboundTokenAfterException

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void getsUnboundTokenAfterException() throws HodErrorException, InterruptedException {
    final List<Try<AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1>>> outputs = Collections.synchronizedList(new ArrayList<Try<AuthenticationToken<EntityType.Unbound,TokenType.HmacSha1>>>());
    final CountDownLatch latch = new CountDownLatch(3);

    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> unboundToken = createToken(Hours.ONE);
    final HodErrorException exception = createException();
    mockAuthenticateUnbound().then(new DelayedAnswer<>(exception)).then(new DelayedAnswer<>(unboundToken));
    mockTokenInformation(unboundToken);

    for (int i = 0; i < 3; i++) {
        executorService.execute(new UnboundTokenGetter(unboundTokenService, outputs, latch));
    }

    awaitLatch(latch);

    assertThat(outputs, hasSize(3));
    verify(authenticationService, times(2)).authenticateUnbound(any(ApiKey.class), eq(TokenType.HmacSha1.INSTANCE));

    checkOutput(outputs.get(0), null, exception);
    checkOutput(outputs.get(1), unboundToken, null);
    checkOutput(outputs.get(2), unboundToken, null);
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:24,代码来源:UnboundTokenServiceImplTest.java

示例6: authenticate

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
private TokenAndUuid authenticate() throws HodErrorException {
    final ApiKey apiKey = configService.getConfig().getApiKey();

    TokenAndUuid tokenAndUuid = cache.get();

    if (!isTokenValid(tokenAndUuid)) {
        synchronized (lock) {
            tokenAndUuid = cache.get();

            // Check that the token is valid again because another thread might have updated it
            if (!isTokenValid(tokenAndUuid)) {
                final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> unboundToken = authenticationService.authenticateUnbound(apiKey, TokenType.HmacSha1.INSTANCE);

                final UUID uuid;

                if (tokenAndUuid == null) {
                    final UnboundTokenInformation information = authenticationService.getHmacUnboundTokenInformation(unboundToken);
                    uuid = information.getAuthentication().getUuid();
                } else {
                    uuid = tokenAndUuid.uuid;
                }

                tokenAndUuid = new TokenAndUuid(unboundToken, uuid);
                cache.set(tokenAndUuid);
            }
        }
    }

    return tokenAndUuid;
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:31,代码来源:UnboundTokenServiceImpl.java

示例7: getsAuthenticationUUID

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void getsAuthenticationUUID() throws HodErrorException {
    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> token = createToken(Hours.ONE);
    mockAuthenticateUnbound().thenReturn(token);
    mockTokenInformation(token);

    assertThat(unboundTokenService.getAuthenticationUuid(), is(AUTH_UUID));
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:9,代码来源:UnboundTokenServiceImplTest.java

示例8: fetchesWhenTokenExpires

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void fetchesWhenTokenExpires() throws InterruptedException, HodErrorException {
    final List<Try<AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1>>> outputs = Collections.synchronizedList(new ArrayList<Try<AuthenticationToken<EntityType.Unbound,TokenType.HmacSha1>>>());

    // The first token is created just before it expires so the second call to getUnboundToken should fetch again
    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> expiredUnboundToken = createToken(new Period(UnboundTokenServiceImpl.EXPIRY_TOLERANCE).plus(Seconds.ONE));
    final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> newToken = createToken(Days.ONE);
    mockAuthenticateUnbound().then(new DelayedAnswer<>(expiredUnboundToken)).then(new DelayedAnswer<>(newToken));
    mockTokenInformation(expiredUnboundToken);

    final CountDownLatch latch1 = new CountDownLatch(1);
    executorService.execute(new UnboundTokenGetter(unboundTokenService, outputs, latch1));
    awaitLatch(latch1);

    // Wait for the first token to be expired
    TimeUnit.SECONDS.sleep(2);

    final CountDownLatch latch2 = new CountDownLatch(1);
    executorService.execute(new UnboundTokenGetter(unboundTokenService, outputs, latch2));
    awaitLatch(latch2);

    assertThat(outputs, hasSize(2));
    verify(authenticationService, times(2)).authenticateUnbound(any(ApiKey.class), eq(TokenType.HmacSha1.INSTANCE));

    checkOutput(outputs.get(0), expiredUnboundToken, null);
    checkOutput(outputs.get(1), newToken, null);
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:28,代码来源:UnboundTokenServiceImplTest.java

示例9: getUnboundToken

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Override
public AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> getUnboundToken() throws HodErrorException {
    return authenticate().token;
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:5,代码来源:UnboundTokenServiceImpl.java

示例10: mockAuthenticateUnbound

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
private OngoingStubbing<AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1>> mockAuthenticateUnbound() throws HodErrorException {
    return when(authenticationService.authenticateUnbound(API_KEY, TokenType.HmacSha1.INSTANCE));
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:4,代码来源:UnboundTokenServiceImplTest.java

示例11: createToken

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
private AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> createToken(final ReadablePeriod expiryOffset) {
    final DateTime expiry = DateTime.now().plus(expiryOffset);
    return new AuthenticationToken<>(EntityType.Unbound.INSTANCE, TokenType.HmacSha1.INSTANCE, expiry, "id-" + UUID.randomUUID(), "secret", new DateTime(0));
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:5,代码来源:UnboundTokenServiceImplTest.java

示例12: mockTokenInformation

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
private void mockTokenInformation(final AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1> token) throws HodErrorException {
    final UnboundTokenInformation tokenInformation = new UnboundTokenInformation(new AuthenticationInformation(AUTH_UUID, AuthenticationType.LEGACY_API_KEY));
    when(authenticationService.getHmacUnboundTokenInformation(token)).thenReturn(tokenInformation);
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:5,代码来源:UnboundTokenServiceImplTest.java

示例13: UnboundTokenGetter

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
private UnboundTokenGetter(final UnboundTokenService<TokenType.HmacSha1> unboundTokenService, final List<Try<AuthenticationToken<EntityType.Unbound, TokenType.HmacSha1>>> outputs, final CountDownLatch latch) {
    super(unboundTokenService, outputs, latch, UnboundTokenService::getUnboundToken);
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:4,代码来源:UnboundTokenServiceImplTest.java

示例14: getUnboundToken

import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
/**
 * @return An unbound token from HP Haven OnDemand
 * @throws HodErrorException If a problem occurs
 */
AuthenticationToken<EntityType.Unbound, T> getUnboundToken() throws HodErrorException;
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:6,代码来源:UnboundTokenService.java


注:本文中的com.hp.autonomy.hod.client.api.authentication.EntityType.Unbound方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。