當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.keySet方法代碼示例

本文整理匯總了Java中net.minidev.json.JSONObject.keySet方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.keySet方法的具體用法?Java JSONObject.keySet怎麽用?Java JSONObject.keySet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minidev.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.keySet方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doExecute

import net.minidev.json.JSONObject; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {

    if (getOidcResponseContext().getIDToken() == null) {
        log.error("{} No id token", getLogPrefix());
        ActionSupport.buildEvent(profileRequestContext, EventIds.INVALID_MSG_CTX);
        return;
    }

    for (IdPAttribute attribute : attributeCtx.getIdPAttributes().values()) {
        final Set<AttributeEncoder<?>> encoders = attribute.getEncoders();
        if (encoders.isEmpty()) {
            log.debug("{} Attribute {} does not have any encoders, nothing to do", getLogPrefix(),
                    attribute.getId());
            continue;
        }
        for (final AttributeEncoder<?> encoder : encoders) {
            try {
                if (encoder instanceof AbstractOIDCAttributeEncoder) {
                    // TODO: missing a activation condition check for
                    // encoder!
                    JSONObject obj = (JSONObject) encoder.encode(attribute);
                    // There should be exactly one key
                    for (String name : obj.keySet()) {
                        log.debug("Adding claim {} with value {}", name, obj.get(name));
                        getOidcResponseContext().getIDToken().setClaim(name, obj.get(name));
                    }

                }
            } catch (AttributeEncodingException e) {
                log.warn("{} Unable to encode attribute {} as OIDC attribute", 
                        getLogPrefix(), attribute.getId(), e);
            }
        }
    }
    log.debug("{} id token after mapping attributes to claims {}", getLogPrefix(), getOidcResponseContext()
            .getIDToken().toJSONObject().toJSONString());
}
 
開發者ID:CSCfi,項目名稱:shibboleth-idp-oidc-extension,代碼行數:40,代碼來源:AddClaimsToIDToken.java

示例2: loadConfigHierarchy

import net.minidev.json.JSONObject; //導入方法依賴的package包/類
private void loadConfigHierarchy() throws Exception {
    if (resource != null && bundle != null) {
        String key = resource.getPath();

        if (USE_CACHE_FOR_CONFIGURATION && configCache.containsKey(key)) {
            configMembers = configCache.get(key);
        } else {
            ExtendedNodeType extendedNodeType = resource.getNode().getPrimaryNodeType();
            Map<String, ExtendedNodeType> map = getAllNodeTypesForNode(extendedNodeType, new LinkedHashMap<String, ExtendedNodeType>());
            if ( map.size() > 0 ){
                for (String keyMap : map.keySet()){
                    ExtendedNodeType nodeTypeToEvaluate = map.get(keyMap);

                    JSONObject xkConfigJSONObj = getJSON( nodeTypeToEvaluate );
                    if (xkConfigJSONObj != null) {
                        Map<String, InertProperty> propsMap = new LinkedHashMap<>();
                        for (String jsonKey : xkConfigJSONObj.keySet()) {
                            Object object = xkConfigJSONObj.get(jsonKey);
                            InertProperty property = new InertProperty(jsonKey, object);
                            propsMap.put(jsonKey, property);
                        }
                        configMembers.put(keyMap, propsMap);
                    } else {
                        // TODO review if LOG is needed here or not.
                        // LOG.error(LOG_PRE + "Not able to load file into JSON Object: {}, check your configuration node",nodeTypeToEvaluate);
                    }
                }
                if (USE_CACHE_FOR_CONFIGURATION) {
                    configCache.put(key, configMembers);
                }
            }
        }
    }
    propNamesDeepCache = names(false);
}
 
開發者ID:DantaFramework,項目名稱:JahiaDF,代碼行數:36,代碼來源:JahiaConfigurationProviderImpl.java


注:本文中的net.minidev.json.JSONObject.keySet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。