本文整理汇总了Java中enkan.collection.Parameters.put方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.put方法的具体用法?Java Parameters.put怎么用?Java Parameters.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enkan.collection.Parameters
的用法示例。
在下文中一共展示了Parameters.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorize
import enkan.collection.Parameters; //导入方法依赖的package包/类
/**
* Authorization endpoint.
*
* @param params Request parameters
* @param principal User principal
* @param request HttpRequest object
* @return Authorization response
*/
public HttpResponse authorize(Parameters params, UserPermissionPrincipal principal, HttpRequest request) {
if (principal != null) {
Parameters responseParams = Parameters.of();
if (params.containsKey("state")) {
responseParams.put("state", params.get("state"));
}
String clientId = params.get("client_id");
OidcApplicationDao oidcApplicationDao = daoProvider.getDao(OidcApplicationDao.class);
OidcApplication oidcApplication = oidcApplicationDao.selectByClientId(clientId);
String redirectUrl = (String) params.getOrDefault("redirect_url", oidcApplication.getCallbackUrl());
Set<ResponseType> responseTypes = Arrays.stream(((String) params.getOrDefault("response_type", "code")).split("[ ,]+"))
.map(rt -> ResponseType.of(rt))
.filter(Objects::nonNull)
.collect(Collectors.toSet());
if (responseTypes.contains(ID_TOKEN)) {
String nonce = params.get("nonce");
responseParams.put("id_token", createIdToken(principal.getId(), oidcApplication, nonce));
}
if (responseTypes.contains(TOKEN)) {
responseParams.put("access_token", createAccessToken(principal.getName(), clientId, Collections.emptyList()));
responseParams.put("token_type", "bearer");
responseParams.put("expires_in", 3600);
}
if (responseTypes.contains(CODE)) {
KeyValueStore authorizationCodeStore = storeProvider.getStore(AUTHORIZATION_CODE);
String code = RandomUtils.generateRandomString(16, config.getSecureRandom());
authorizationCodeStore.write(code, principal.getId());
responseParams.put("code", code);
}
return HttpResponseUtils.redirect(makeCallbackUrl(redirectUrl, responseParams, responseTypes), FOUND);
} else {
return HttpResponseUtils.redirect("/my/signIn?url=" + request.getUri() + "?" + CodecUtils.urlEncode(request.getQueryString()), SEE_OTHER);
}
}
示例2: formDecode
import enkan.collection.Parameters; //导入方法依赖的package包/类
public static Parameters formDecode(String encoded, String encoding) {
Parameters m = Parameters.empty();
for(String param : encoded.split("&")) {
String[] kv = param.split("=", 2);
if (kv.length == 1) {
m.put(formDecodeStr(kv[0], encoding), null);
} else if (kv.length == 2) {
m.put(formDecodeStr(kv[0], encoding),
formDecodeStr(kv[1], encoding));
}
}
return m;
}
示例3: assocVector
import enkan.collection.Parameters; //导入方法依赖的package包/类
protected Parameters assocVector(Parameters map, String key, Object value) {
if (!map.containsKey(key)) {
map.put(key, new ArrayList<>());
}
return assocConj(map, key, value);
}
示例4: assocNested
import enkan.collection.Parameters; //导入方法依赖的package包/类
protected Object assocNested(Parameters map, String[] keys, List<String> values) {
if (keys.length > 0) {
String[] ks = new String[keys.length - 1];
if (ks.length > 0) {
System.arraycopy(keys, 1, ks, 0, ks.length);
String j = ks[0];
if (j.isEmpty()) {
// Array
String[] js = new String[keys.length - 2];
if (js.length > 0) {
System.arraycopy(keys, 2, js, 0, js.length);
}
List<Object> nestedList = map.getList(keys[0]);
for (int i = nestedList.size(); i < values.size(); i++) nestedList.add(null);
for (int i = 0; i < values.size(); i++) {
List<String> vs = new ArrayList<>();
vs.add(values.get(i));
if (js.length > 0) {
nestedList.set(i,
assocNested((Parameters) Optional.ofNullable(nestedList.get(i)).orElse(Parameters.empty())
, js, vs));
} else {
nestedList.set(i, vs.get(0));
}
}
if (map.containsKey(keys[0])) {
map.replace(keys[0], nestedList);
} else {
map.put(keys[0], nestedList);
}
return map;
} else {
// Map
Parameters submap = (Parameters) map.getRawType(keys[0]);
if (submap == null) submap = Parameters.empty();
map.put(keys[0], assocNested(submap, ks, values));
return map;
}
} else {
return assocConj(map, keys[0], values);
}
} else {
return values;
}
}