本文整理汇总了Java中com.hp.autonomy.hod.client.api.authentication.EntityType.Application方法的典型用法代码示例。如果您正苦于以下问题:Java EntityType.Application方法的具体用法?Java EntityType.Application怎么用?Java EntityType.Application使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.autonomy.hod.client.api.authentication.EntityType
的用法示例。
在下文中一共展示了EntityType.Application方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: parseResponseToTypeReferenceWithRefreshedToken
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void parseResponseToTypeReferenceWithRefreshedToken() throws IOException {
final ResponseAndBody responseAndBody = createTestRefreshResponse();
@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 List<Object> expectedReturnValue = new ArrayList<>();
final JavaType listType = typeFactory.constructType(LIST_TYPE_REFERENCE);
when(objectMapper.readValue(isA(String.class), eq(AuthenticationToken.Json.class))).thenReturn(newTokenJson);
when(objectMapper.readValue(eq(responseAndBody.body), eq(listType))).thenReturn(expectedReturnValue);
final TokenProxy<EntityType.Application, TokenType.Simple> tokenProxy = new TokenProxy<>(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE);
final List<Object> returnValue = responseParser.parseResponse(tokenProxy, LIST_TYPE_REFERENCE, responseAndBody.response);
verify(tokenRepository).update(tokenProxy, newToken);
assertThat(returnValue, is(expectedReturnValue));
}
示例4: setUp
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Override
@Before
public void setUp() {
super.setUp();
// Creating the HodServiceConfig requires the TokenProxyService, but the TokenProxyService requires the
// TokenRepository, which requires the HodServiceConfig
final AtomicReference<TokenProxy<EntityType.Application, TokenType.Simple>> tokenProxyAtomicReference = new AtomicReference<>();
final TokenProxyService<EntityType.Application, TokenType.Simple> tokenProxyService = tokenProxyAtomicReference::get;
final HodServiceConfig<EntityType.Application, TokenType.Simple> hodServiceConfig = HodServiceConfigFactory.getHodServiceConfig(tokenProxyService, getEndpoint());
try {
tokenProxyAtomicReference.set(hodServiceConfig.getTokenRepository().insert(getToken()));
} catch (final IOException e) {
throw new TokenRepositoryException(e);
}
queryTextIndexService = QueryTextIndexServiceImpl.documentsService(hodServiceConfig);
}
示例5: createAuthentication
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Override
protected Authentication createAuthentication(final Collection<GrantedAuthority> baseAuthorities) {
final ResourceName application = new ResourceName(
environment.getProperty(HodTestConfiguration.DOMAIN_PROPERTY),
environment.getProperty(HodTestConfiguration.APPLICATION_PROPERTY)
);
final Collection<GrantedAuthority> hodAuthorities = new HashSet<>(baseAuthorities);
hodAuthorities.add(new HodApplicationGrantedAuthority(application));
@SuppressWarnings("unchecked") final HodAuthentication<EntityType.Application> authentication = mock(HodAuthentication.class);
when(authentication.getPrincipal()).thenReturn(testPrincipal);
when(authentication.getTokenProxy()).thenReturn(testTokenProxy);
when(authentication.getAuthorities()).thenReturn(hodAuthorities);
when(authentication.isAuthenticated()).thenReturn(true);
when(authentication.getName()).thenReturn("user");
return authentication;
}
示例6: 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));
}
示例7: 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));
}
示例8: 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));
}
示例9: testUpdateReturnsNullAndDoesNothingIfKeyNotPresent
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void testUpdateReturnsNullAndDoesNothingIfKeyNotPresent() throws IOException {
final TokenProxy<EntityType.Application, TokenType.Simple> key = new TokenProxy<>(EntityType.Application.INSTANCE, TokenType.Simple.INSTANCE);
final AuthenticationToken<EntityType.Application, TokenType.Simple> newToken = getAppToken(getExpiry(), getRefresh());
final AuthenticationToken<EntityType.Application, TokenType.Simple> oldToken = tokenRepository.update(key, newToken);
assertThat(oldToken, is(nullValue()));
assertThat(tokenRepository.get(key), is(nullValue()));
}
示例10: testRemove
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void testRemove() throws IOException {
final AuthenticationToken<EntityType.Application, TokenType.Simple> token = getAppToken(getExpiry(), getRefresh());
final TokenProxy<EntityType.Application, TokenType.Simple> key = tokenRepository.insert(token);
assertThat(tokenRepository.remove(key), is(token));
assertThat(tokenRepository.get(key), is(nullValue()));
}
示例11: parseResponseToInputStreamWithoutRefreshedToken
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void parseResponseToInputStreamWithoutRefreshedToken() throws IOException {
final ResponseAndBody responseAndBody = createTestResponse();
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, never()).update(isA(TokenProxy.class), isA(AuthenticationToken.class));
assertThat(returnValue, is(responseAndBody.body));
}
示例12: testUpdateThrowsIllegalArgumentExceptionForExpiredTokens
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testUpdateThrowsIllegalArgumentExceptionForExpiredTokens() throws IOException {
final AuthenticationToken<EntityType.Application, TokenType.Simple> token1 = getAppToken(getExpiry(), getRefresh());
final AuthenticationToken<EntityType.Application, TokenType.Simple> token2 = getAppToken(THE_PAST, THE_PAST);
TokenProxy<EntityType.Application, TokenType.Simple> key = null;
try {
key = tokenRepository.insert(token1);
} catch (final IllegalArgumentException e) {
fail("The initial token should not have expired");
}
tokenRepository.update(key, token2);
}
示例13: getAppToken
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
private AuthenticationToken<EntityType.Application, TokenType.Simple> getAppToken(final DateTime expiry, final DateTime refresh) {
return new AuthenticationToken<>(
EntityType.Application.INSTANCE,
TokenType.Simple.INSTANCE,
expiry,
"foo",
"bar",
refresh
);
}
示例14: getHodServiceConfig
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
public static HodServiceConfig<EntityType.Application, TokenType.Simple> getHodServiceConfig(
final TokenProxyService<EntityType.Application, TokenType.Simple> tokenProxyService,
final Endpoint endpoint
) {
final HttpClientBuilder builder = HttpClientBuilder.create();
builder.disableCookieManagement();
builder.setDefaultSocketConfig(SocketConfig.custom()
.setSoTimeout(60000)
.build());
final String proxyHost = System.getProperty("hp.hod.https.proxyHost");
if (proxyHost != null) {
final Integer proxyPort = Integer.valueOf(System.getProperty("hp.hod.https.proxyPort", "8080"));
builder.setProxy(new HttpHost(proxyHost, proxyPort));
}
final HodServiceConfig.Builder<EntityType.Application, TokenType.Simple> configBuilder = new HodServiceConfig.Builder<EntityType.Application, TokenType.Simple>(endpoint.getUrl())
.setHttpClient(builder.build());
if (tokenProxyService != null) {
configBuilder.setTokenProxyService(tokenProxyService);
}
return configBuilder.build();
}
示例15: testHodReturnsApiKeyError
import com.hp.autonomy.hod.client.api.authentication.EntityType; //导入方法依赖的package包/类
@Test
public void testHodReturnsApiKeyError() throws IOException {
final TokenProxy<EntityType.Application, TokenType.Simple> tokenProxy = getConfig().getTokenRepository().insert(new AuthenticationToken<>(
EntityType.Application.INSTANCE,
TokenType.Simple.INSTANCE,
DateTime.now().plus(Hours.ONE),
"ID",
"SECRET",
new DateTime(1234567890L)
));
testErrorCodeAndMessage(HodErrorCode.AUTHENTICATION_FAILED, "Authentication failed", () -> queryTextIndexService.queryTextIndexWithText(tokenProxy, "*", new QueryRequestBuilder()));
}