本文整理汇总了Java中com.hp.autonomy.hod.client.api.authentication.EntityType类的典型用法代码示例。如果您正苦于以下问题:Java EntityType类的具体用法?Java EntityType怎么用?Java EntityType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityType类属于com.hp.autonomy.hod.client.api.authentication包,在下文中一共展示了EntityType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@SuppressWarnings("ProhibitedExceptionDeclared")
@Override
protected void configure(final HttpSecurity http) throws Exception {
final AuthenticationEntryPoint ssoEntryPoint = new SsoAuthenticationEntryPoint(SsoController.SSO_PAGE);
final SsoAuthenticationFilter<?> ssoAuthenticationFilter = new SsoAuthenticationFilter<>(SsoController.SSO_AUTHENTICATION_URI, EntityType.CombinedSso.INSTANCE);
ssoAuthenticationFilter.setAuthenticationManager(authenticationManager());
final LogoutSuccessHandler logoutSuccessHandler = new HodTokenLogoutSuccessHandler(SsoController.SSO_LOGOUT_PAGE, tokenRepository);
http.regexMatcher("/public(/.*)?|/sso|/authenticate-sso|/api/authentication/.*|/logout")
.csrf()
.disable()
.exceptionHandling()
.authenticationEntryPoint(ssoEntryPoint)
.accessDeniedPage(DispatcherServletConfiguration.AUTHENTICATION_ERROR_PATH)
.and()
.authorizeRequests()
.antMatchers(FindController.APP_PATH + "/**").hasRole(FindRole.USER.name())
.and()
.logout()
.logoutSuccessHandler(logoutSuccessHandler)
.and()
.addFilterAfter(ssoAuthenticationFilter, AbstractPreAuthenticatedProcessingFilter.class);
}
示例2: authenticationInformationRetriever
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Bean
@Primary
@ConditionalOnProperty(value = MOCK_AUTHENTICATION_RETRIEVER_PROPERTY, matchIfMissing = true)
public AuthenticationInformationRetriever<HodAuthentication<EntityType.Application>, HodAuthenticationPrincipal> authenticationInformationRetriever(
final HodAuthenticationPrincipal testPrincipal,
final TokenProxy<EntityType.Application, TokenType.Simple> testTokenProxy
) throws HodErrorException {
@SuppressWarnings("unchecked")
final HodAuthentication<EntityType.Application> mockAuthentication = mock(HodAuthentication.class);
when(mockAuthentication.getPrincipal()).thenReturn(testPrincipal);
when(mockAuthentication.getTokenProxy()).thenReturn(testTokenProxy);
@SuppressWarnings("unchecked")
final AuthenticationInformationRetriever<HodAuthentication<EntityType.Application>, HodAuthenticationPrincipal> retriever = mock(AuthenticationInformationRetriever.class);
when(retriever.getAuthentication()).thenReturn(mockAuthentication);
when(retriever.getPrincipal()).thenReturn(testPrincipal);
return retriever;
}
示例3: testTokenProxy
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Bean
@ConditionalOnProperty(value = MOCK_AUTHENTICATION_PROPERTY, matchIfMissing = true)
public TokenProxy<EntityType.Application, TokenType.Simple> testTokenProxy(
final HttpClient httpClient,
final TokenRepository tokenRepository,
final ObjectMapper objectMapper
) throws HodErrorException {
final String application = environment.getProperty(APPLICATION_PROPERTY);
final String domain = environment.getProperty(DOMAIN_PROPERTY);
final ApiKey apiKey = new ApiKey(environment.getProperty(API_KEY_PROPERTY));
// We can't use the HodServiceConfig bean here since the AuthenticationInformationRetrieverTokenProxyService depends on this bean
final HodServiceConfig<?, TokenType.Simple> hodServiceConfig = new HodServiceConfig.Builder<EntityType.Combined, TokenType.Simple>(HOD_URL)
.setHttpClient(httpClient)
.setTokenRepository(tokenRepository)
.setObjectMapper(objectMapper)
.build();
final AuthenticationService authenticationService = new AuthenticationServiceImpl(hodServiceConfig);
return authenticationService.authenticateApplication(apiKey, application, domain, TokenType.Simple.INSTANCE);
}
示例4: remove
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Override
public <E extends EntityType, T extends TokenType> AuthenticationToken<E, T> remove(final TokenProxy<E, T> tokenProxy) throws IOException {
try(final Jedis jedis = jedisPool.getResource()) {
final byte[] keyBytes = serialize(tokenProxy);
final Transaction transaction = jedis.multi();
final Response<byte[]> oldTokenResponse = transaction.get(keyBytes);
transaction.del(keyBytes);
transaction.exec();
//noinspection unchecked
return (AuthenticationToken<E, T>) deserialize(oldTokenResponse.get());
}
}
示例5: testExpiryOnInsert
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Test
public void testExpiryOnInsert() throws IOException, InterruptedException {
final DateTime expiry1 = DateTime.now().plusSeconds(2);
final DateTime expiry2 = DateTime.now().plusSeconds(12);
final AuthenticationToken<EntityType.Application, TokenType.Simple> token1 = getAppToken(expiry1, getRefresh());
final TokenProxy<EntityType.Application, TokenType.Simple> key1 = tokenRepository.insert(token1);
final AuthenticationToken<EntityType.Application, TokenType.Simple> token2 = getAppToken(expiry2, getRefresh());
final TokenProxy<EntityType.Application, TokenType.Simple> key2 = tokenRepository.insert(token2);
TimeUnit.SECONDS.sleep(3L);
assertThat(tokenRepository.get(key1), is(nullValue()));
assertThat(tokenRepository.get(key2), is(token2));
}
示例6: initialise
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Before
public void initialise() throws IOException, HodErrorException {
tokenProxy = new TokenProxy<>(EntityType.Combined.INSTANCE, TokenType.Simple.INSTANCE);
combinedToken = mockToken(EntityType.Combined.INSTANCE, TokenType.Simple.INSTANCE);
unboundToken = mockToken(EntityType.Unbound.INSTANCE, TokenType.HmacSha1.INSTANCE);
combinedSsoToken = mockToken(EntityType.CombinedSso.INSTANCE, TokenType.Simple.INSTANCE);
when(unboundTokenService.getUnboundToken()).thenReturn(unboundToken);
when(authenticationService.authenticateCombinedGet(combinedSsoToken, unboundToken)).thenReturn(mockApplicationAndUsersList(TokenType.Simple.INSTANCE));
when(authenticationService.authenticateCombined(
combinedSsoToken,
unboundToken,
APPLICATION_DOMAIN,
APPLICATION_NAME,
USERSTORE_DOMAIN,
USERSTORE_NAME,
TokenType.Simple.INSTANCE
)).thenReturn(combinedToken);
when(authenticationService.getCombinedTokenInformation(combinedToken)).thenReturn(mockCombinedTokenInformation());
when(tokenRepository.insert(combinedToken)).thenReturn(tokenProxy);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
}
示例10: testParseResponseToClassWithoutARefreshedToken
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Test
public void testParseResponseToClassWithoutARefreshedToken() throws IOException {
final ResponseAndBody responseAndBody = createTestResponse();
final Object expectedReturnValue = new Object();
final JavaType objectType = typeFactory.uncheckedSimpleType(Object.class);
when(objectMapper.constructType(eq(Object.class))).thenReturn(objectType);
when(objectMapper.readValue(eq(responseAndBody.body), eq(objectType))).thenReturn(expectedReturnValue);
final TokenProxy<EntityType.Application, TokenType.Simple> tokenProxy = new TokenProxy<>(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE);
final Object returnValue = responseParser.parseResponse(tokenProxy, Object.class, responseAndBody.response);
verify(tokenRepository, never()).update(isA(TokenProxy.class), isA(AuthenticationToken.class));
assertThat(returnValue, is(expectedReturnValue));
}
示例11: 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));
}
示例12: parseResponseToInputStreamWithRefreshedToken
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Test
public void parseResponseToInputStreamWithRefreshedToken() throws IOException {
@SuppressWarnings("unchecked")
final AuthenticationToken<EntityType.Application, TokenType.Simple> newToken = mock(AuthenticationToken.class);
final AuthenticationToken.Json newTokenJson = mock(AuthenticationToken.Json.class);
when(newTokenJson.buildToken(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE)).thenReturn(newToken);
final ResponseAndBody responseAndBody = createTestRefreshResponse();
when(objectMapper.readValue(isA(String.class), eq(AuthenticationToken.Json.class))).thenReturn(newTokenJson);
final TokenProxy<EntityType.Application, TokenType.Simple> tokenProxy = new TokenProxy<>(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE);
final InputStream returnValue = responseParser.parseResponse(tokenProxy, responseAndBody.response);
verify(tokenRepository).update(tokenProxy, newToken);
assertThat(returnValue, is(responseAndBody.body));
}
示例13: setUp
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
tokenProxy = new TokenProxy<>(EntityType.Combined.INSTANCE, TokenType.Simple.INSTANCE);
final AuthenticationToken<EntityType.Combined, TokenType.Simple> token = new AuthenticationToken<>(
EntityType.Combined.INSTANCE,
TokenType.Simple.INSTANCE,
DateTime.now().plus(standardHours(2)),
"token-id",
"token-secret",
DateTime.now().plus(standardHours(1))
);
final TokenRepository tokenRepository = mock(TokenRepository.class);
when(tokenRepository.get(tokenProxy)).thenReturn(token);
logoutSuccessHandler = new HodTokenLogoutSuccessHandler(REDIRECT_PATH, tokenRepository);
}
示例14: testMakeRequestThrowsAndRemovesExpiredTokensFromRepository
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Test
public void testMakeRequestThrowsAndRemovesExpiredTokensFromRepository() throws IOException, HodErrorException {
@SuppressWarnings("unchecked")
final AuthenticationToken<EntityType.Application, TokenType.Simple> token = mock(AuthenticationToken.class);
final TokenProxy<EntityType.Application, TokenType.Simple> tokenProxy = new TokenProxy<>(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE);
when(token.hasExpired()).thenReturn(true);
when(tokenRepository.get(tokenProxy)).thenReturn(token);
try {
requester.makeRequest(tokenProxy, Object.class, null);
fail("HodAuthenticationFailedException not thrown");
} catch (final HodAuthenticationFailedException e) {
verify(tokenRepository).remove(tokenProxy);
}
}
示例15: parseResponseToJavaTypeWithRefreshedToken
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入依赖的package包/类
@Test
public void parseResponseToJavaTypeWithRefreshedToken() throws IOException {
final ResponseAndBody responseAndBody = createTestRefreshResponse();
final Object expectedReturnValue = new Object();
@SuppressWarnings("unchecked")
final AuthenticationToken<EntityType.Application, TokenType.Simple> newToken = mock(AuthenticationToken.class);
final AuthenticationToken.Json newTokenJson = mock(AuthenticationToken.Json.class);
when(newTokenJson.buildToken(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE)).thenReturn(newToken);
final JavaType objectType = typeFactory.uncheckedSimpleType(Object.class);
when(objectMapper.readValue(isA(String.class), eq(AuthenticationToken.Json.class))).thenReturn(newTokenJson);
when(objectMapper.readValue(eq(responseAndBody.body), eq(objectType))).thenReturn(expectedReturnValue);
final TokenProxy<EntityType.Application, TokenType.Simple> tokenProxy = new TokenProxy<>(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE);
final Object returnValue = responseParser.unsafeParseResponse(tokenProxy, objectType, responseAndBody.response);
verify(tokenRepository).update(tokenProxy, newToken);
assertThat(returnValue, is(expectedReturnValue));
}