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


Java Parameters.containsKey方法代码示例

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


在下文中一共展示了Parameters.containsKey方法的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);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:46,代码来源:OidcController.java

示例2: setFrameOptions

import enkan.collection.Parameters; //导入方法依赖的package包/类
public void setFrameOptions(Parameters frameOptions) {
    if (!frameOptions.containsKey("allow-from")) {
        throw new MisconfigurationException("web.ILLEGAL_FRAME_OPTIONS");
    }
    this.frameOptions = frameOptions;
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:7,代码来源:FrameOptionsMiddleware.java

示例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);
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:7,代码来源:NestedParamsMiddleware.java

示例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;
    }
}
 
开发者ID:kawasima,项目名称:enkan,代码行数:52,代码来源:NestedParamsMiddleware.java


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