本文整理汇总了Java中javax.ws.rs.core.MultivaluedMap.putSingle方法的典型用法代码示例。如果您正苦于以下问题:Java MultivaluedMap.putSingle方法的具体用法?Java MultivaluedMap.putSingle怎么用?Java MultivaluedMap.putSingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.MultivaluedMap
的用法示例。
在下文中一共展示了MultivaluedMap.putSingle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseSessionDataFailsIfStampIsExpired
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void parseSessionDataFailsIfStampIsExpired() throws Exception {
ReflectionTestUtils.setField(parser, "clock", expired);
MultivaluedMap<String,String> initParams = getValidInitParams();
initParams.putSingle("sessionId", "1234567890");
when(authenticationHandlerUtils.popFromCache(any())).thenReturn(initParams);
Map<String,String> attributeNameMap = mock(Map.class);
when(attributeNameMap.get("B02K_CUSTID")).thenReturn("ATTRNAME_CUSTID");
when(attributeNameMap.get("B02K_CUSTNAME")).thenReturn("ATTRNAME_CUSTNAME");
MultivaluedMap<String,String> sessionParams = getValidSessionParamsWithHetu();
sessionParams.putSingle("sessionId", "1234567890");
assertNull(parser.parseSessionData(sessionParams));
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:18,代码来源:SessionParserServiceSessionTest.java
示例2: parseSessionData
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void parseSessionData() throws Exception {
MultivaluedMap<String,String> initParams = getValidInitParams();
initParams.putSingle("sessionId", "1234567890");
when(authenticationHandlerUtils.popFromCache(any())).thenReturn(initParams);
Map<String,String> attributeNameMap = mock(Map.class);
when(attributeNameMap.get("B02K_CUSTID")).thenReturn("ATTRNAME_CUSTID");
when(attributeNameMap.get("B02K_CUSTNAME")).thenReturn("ATTRNAME_CUSTNAME");
MultivaluedMap<String,String> sessionParams = getValidSessionParamsWithHetu();
sessionParams.putSingle("sessionId", "1234567890");
TupasIdentification identification = parser.parseSessionData(sessionParams);
assertThat(identification.getCkey(), equalTo(initParams.getFirst("ckey")));
assertThat(identification.getHetu(), equalTo("210280-928R"));
assertThat(identification.getName(), equalTo("CUSTNAME"));
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:19,代码来源:SessionParserServiceSessionTest.java
示例3: postProcess
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Override
public void postProcess(ServerResponse response)
{
final MultivaluedMap<String, Object> metadata = response.getMetadata();
final Object contentType = metadata.getFirst(CONTENT_TYPE_HEADER);
if( contentType != null )
{
final String ct;
if( contentType instanceof MediaType )
{
MediaType mct = (MediaType) contentType;
ct = mct.toString().toLowerCase();
}
else
{
ct = ((String) contentType).toLowerCase();
}
if( ct.contains("json") && !ct.contains("charset"))
{
metadata.putSingle(CONTENT_TYPE_HEADER, ct + "; charset=utf-8");
}
}
}
示例4: parseSessionDataFailsIfIdentifierNotPreserved
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void parseSessionDataFailsIfIdentifierNotPreserved() throws Exception {
MultivaluedMap<String,String> initParams = getValidInitParams();
// replace identifier
initParams.putSingle("ADPT_TSTAMP", "000000000");
initParams.putSingle("sessionId", "1234567890");
when(authenticationHandlerUtils.popFromCache(any())).thenReturn(initParams);
Map<String,String> attributeNameMap = mock(Map.class);
when(attributeNameMap.get("B02K_CUSTID")).thenReturn("ATTRNAME_CUSTID");
when(attributeNameMap.get("B02K_CUSTNAME")).thenReturn("ATTRNAME_CUSTNAME");
MultivaluedMap<String,String> sessionParams = getValidSessionParamsWithHetu();
sessionParams.putSingle("sessionId", "1234567890");
assertNull(parser.parseSessionData(sessionParams));
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:19,代码来源:SessionParserServiceSessionTest.java
示例5: getValidSessionParamsWithHetu
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private MultivaluedMap<String,String> getValidSessionParamsWithHetu() {
MultivaluedMap<String,String> sessionParams = new MultivaluedHashMap<>();
sessionParams.putSingle("token", "token");
sessionParams.putSingle("B02K_VERS", "0002");
sessionParams.putSingle("B02K_TIMESTMP", "000" + bankReady.instant().atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))+"000000");
sessionParams.putSingle("B02K_IDNBR", "0000000000");
sessionParams.putSingle("B02K_STAMP", VALID_IDENTIFIER);
sessionParams.putSingle("B02K_CUSTNAME", "CUSTNAME");
sessionParams.putSingle("B02K_KEYVERS", "0001");
sessionParams.putSingle("B02K_ALG", "03");
sessionParams.putSingle("B02K_CUSTID", "210280-928R");
sessionParams.putSingle("B02K_CUSTTYPE", "01");
sessionParams.putSingle("B02K_MAC", "1D609B7B2CAF04AF1C50C7C7A04FBE081E77566C7BDB023F26EB2739C63718E0");
return sessionParams;
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:17,代码来源:SessionParserServiceSessionTest.java
示例6: filter
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext containerRequestContext,
ContainerResponseContext containerResponseContext) throws IOException {
MultivaluedMap<String, Object> headers = containerResponseContext.getHeaders();
headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "orgin");
headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "content-type");
headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "accept");
headers.add(ACCESS_CONTROL_ALLOW_HEADERS, "authorization");
customHeaders.forEach(s -> headers.add(ACCESS_CONTROL_ALLOW_HEADERS, s));
// make sure there's only one header with this name
String headerString = (String) headers.get(ACCESS_CONTROL_ALLOW_HEADERS).stream()
.reduce((a, b) -> a.toString() + ", " + b.toString()).get();
headers.putSingle(ACCESS_CONTROL_ALLOW_HEADERS, headerString);
headers.putSingle("Access-Control-Allow-Credentials", "true");
headers.putSingle("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
}
示例7: testPutWithETag
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void testPutWithETag() throws Exception {
MockRepresentation content = new MockRepresentation();
content.setId(1L);
content.setETag(1L);
MockRequestParameters params = new MockRequestParameters();
params.setId(1L);
params.setMatch("1");
UriInfo uriinfo = mock(UriInfo.class);
MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
map.putSingle(CommonParams.PARAM_VERSION, "v" + Integer.valueOf(CommonParams.VERSION_1).toString());
Mockito.when(uriinfo.getPathParameters()).thenReturn(map);
Response response = put(uriinfo, backendPutETag, content, params);
assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
示例8: addResponseHeaders
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
/**
* 全てのレスポンスに共通するレスポンスヘッダーを追加する.
* Access-Control-Allow-Origin, Access-Control-Allow-Headers<br/>
* X-Personium-Version<br/>
* @param request
* @param response
*/
private void addResponseHeaders(final ContainerRequest request, final ContainerResponse response) {
MultivaluedMap<String, Object> mm = response.getHttpHeaders();
String acrh = request.getHeaderValue(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS);
if (acrh != null) {
mm.putSingle(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS, acrh);
} else {
mm.remove(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS);
}
mm.putSingle(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.Value.ASTERISK);
// X-Personium-Version
mm.putSingle(HttpHeaders.X_PERSONIUM_VERSION, PersoniumUnitConfig.getCoreVersion());
}
示例9: verifyTupasIdentification
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private void verifyTupasIdentification(HttpServletRequest request, HttpServletResponse response) throws ExternalAuthenticationException, IOException {
// Identification. Requests have encoding ISO-8859-1
String queryString = request.getQueryString();
queryString.replaceAll("%20", "+");
List<NameValuePair> queryParams = URLEncodedUtils.parse(queryString, Charset.forName("ISO-8859-1"));
MultivaluedMap<String, String> requestParams = convertToMap(queryParams);
String sessionId = request.getSession().getId();
requestParams.putSingle("sessionId", sessionId);
String token = requestParams.getFirst("token");
if (StringUtils.isBlank(token)) {
throw new ExternalAuthenticationException("Bad request, no token");
}
TupasIdentification identification = authenticationHandlerService.buildSession(requestParams);
if ( identification == null ) {
throw new ExternalAuthenticationException("Authentication verification failed");
}
AuthenticationContext ac = ExternalAuthentication.getProfileRequestContext(identification.getCkey(), request).getSubcontext(AuthenticationContext.class);
if ( ac == null ) {
logger.warn("Authentication context not valid");
request.setAttribute(ExternalAuthentication.AUTHENTICATION_ERROR_KEY, "Bad authentication");
ExternalAuthentication.finishExternalAuthentication(identification.getCkey(), request, response);
return;
}
TupasContext tupasContext = new TupasContext(identification.getName(), identification.getHetu());
ac.addSubcontext(tupasContext);
request.setAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY, token);
/** External authentication success. Give control back to Shibboleth IdP (4.) */
ExternalAuthentication.finishExternalAuthentication(identification.getCkey(), request, response);
return;
}
示例10: parseSessionDataFailsTokenHasNoRequestParams
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void parseSessionDataFailsTokenHasNoRequestParams() throws Exception {
when(authenticationHandlerUtils.popFromCache(any())).thenReturn(null);
Map<String,String> attributeNameMap = mock(Map.class);
when(attributeNameMap.get("B02K_CUSTID")).thenReturn("ATTRNAME_CUSTID");
when(attributeNameMap.get("B02K_CUSTNAME")).thenReturn("ATTRNAME_CUSTNAME");
MultivaluedMap<String,String> sessionParams = getValidSessionParamsWithHetu();
sessionParams.putSingle("sessionId", "1234567890");
assertNull(parser.parseSessionData(sessionParams));
}
开发者ID:vrk-kpa,项目名称:e-identification-tupas-idp-public,代码行数:14,代码来源:SessionParserServiceSessionTest.java
示例11: requestAccessToken
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private String requestAccessToken(final String username) throws UnsupportedEncodingException {
WebTarget oauth2Service = ClientBuilder.newClient().register(JacksonJaxbJsonProvider.class).target("http://localhost:7001/security");
MultivaluedMap<String, String> request = new MultivaluedHashMap<>();
request.putSingle("grant_type", "client_credentials");
String credentials = Base64.getEncoder().encodeToString((username + ":passw0rd").getBytes("UTF-8"));
Map<String, String> oauthResponse = oauth2Service.path("oauth2/token")
.request(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
.header("Authorization", "Basic " + credentials)
.header("X-Log-Token", DiagnosticContext.getLogToken())
.header("X-Service-Generation", "1")
.header("X-Client-Version", "1.0.0")
.post(Entity.form(request), Map.class);
return oauthResponse.get("access_token");
}
示例12: hasHetuReturnsTrueOn01
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void hasHetuReturnsTrueOn01() throws Exception {
MultivaluedMap<String,String> sessionData = new MultivaluedHashMap<>();
sessionData.putSingle("B02K_CUSTTYPE", "01");
sessionData.putSingle("B02K_CUSTID", "010101-1010");
assertTrue(parser.hasHetu(sessionData));
}
示例13: updateChannels
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Override
public AlertsPolicyChannels updateChannels(AlertsPolicyChannels channels) {
MultivaluedMap<String, String> form = new MultivaluedHashMap<>();
form.putSingle("policy_id", String.valueOf(channels.getPolicyId()));
form.putSingle("channel_ids",
channels.getChannelIds()
.stream()
.map(String::valueOf)
.collect(Collectors.joining(",")));
return client
.target(POLICY_CHANNELS_URL)
.request(APPLICATION_JSON_TYPE)
.put(Entity.form(form), AlertsPolicyChannelsWrapper.class)
.getPolicyChannels();
}
示例14: testDelete
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
@Test
public void testDelete() throws Exception {
MockRequestParameters params = new MockRequestParameters();
params.setId(1L);
UriInfo uriinfo = mock(UriInfo.class);
MultivaluedMap<String, String> map = new MultivaluedHashMap<>();
map.putSingle(CommonParams.PARAM_VERSION, "v" + Integer.valueOf(CommonParams.VERSION_1).toString());
Mockito.when(uriinfo.getPathParameters()).thenReturn(map);
Response response = delete(uriinfo, backendDelete, params);
assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
示例15: addOriginHeaders
import javax.ws.rs.core.MultivaluedMap; //导入方法依赖的package包/类
private static void addOriginHeaders(MultivaluedMap<String, Object> headers) {
for (Map.Entry<String, String> header : HEADERS.entrySet()) {
headers.putSingle(header.getKey(), header.getValue());
}
}