Search in sources :

Example 36 with JSONArray

use of net.sf.json.JSONArray in project OA4MP by ncsa.

the class ThingTester method getExample.

public static JSONObject getExample() {
    JSONObject admin = new JSONObject();
    JSONObject adminSecrets = new JSONObject();
    adminSecrets.put("id", "123");
    adminSecrets.put("secret", "456");
    admin.put("admin", adminSecrets);
    JSONObject client = new JSONObject();
    JSONObject clientSecret = new JSONObject();
    clientSecret.put("id", "777");
    client.put("client", clientSecret);
    JSONObject actionItems = new JSONObject();
    actionItems.put("method", "get");
    actionItems.put("type", "attribute");
    JSONArray contentItems = new JSONArray();
    contentItems.add("limited_proxies");
    contentItems.add("callbacks");
    JSONObject api = new JSONObject();
    JSONObject apiItems = new JSONObject();
    apiItems.put("subject", admin);
    apiItems.put("action", actionItems);
    apiItems.put("object", client);
    apiItems.put("content", contentItems);
    api.put("api", apiItems);
    prettyPrint(api);
    return api;
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray)

Example 37 with JSONArray

use of net.sf.json.JSONArray in project OA4MP by ncsa.

the class ThingTester method ldapExampleSSL.

public static JSONObject ldapExampleSSL() {
    JSONObject ldapContent = new JSONObject();
    ldapContent.put("authorization_type", "none");
    ldapContent.put("address", "ldap2.bigstate.edu");
    ldapContent.put("port", 636);
    ldapContent.put("search_base", "o=bigstate,dc=co,dc=cilogon,dc=org");
    JSONArray attr = new JSONArray();
    JSONObject attr1 = new JSONObject();
    attr1.put("name", "isMemberOf");
    attr.add(attr1);
    JSONObject attr2 = new JSONObject();
    attr2.put("name", "affiliation");
    attr.add(attr2);
    ldapContent.put("search_attributes", attr);
    JSONObject sslContent = new JSONObject();
    sslContent.put("use_java_trust_store", false);
    sslContent.put("tls_version", "1.1");
    sslContent.put("store", "xWJrngnHV-WnsbMuSlvc9CnUiX9rSZB7oFB7rcb_zT2GxlBZ7NlJSOsttcfm-AaN0wWGXYXrR1pJ7yVocHPTw0rX0sre_CySQnh98Kf");
    sslContent.put("password", "reallyBadPassword");
    ldapContent.put("ssl", sslContent);
    JSONObject ldap = new JSONObject();
    ldap.put("ldap", ldapContent);
    prettyPrint(ldap);
    return ldap;
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray)

Example 38 with JSONArray

use of net.sf.json.JSONArray in project OA4MP by ncsa.

the class ThingTester method adminGetExample.

public static JSONObject adminGetExample() {
    JSONObject admin = new JSONObject();
    JSONObject adminSecrets = new JSONObject();
    adminSecrets.put("id", "123");
    adminSecrets.put("secret", "456");
    admin.put("admin", adminSecrets);
    JSONObject actionItems = new JSONObject();
    actionItems.put("method", "get");
    actionItems.put("type", "attribute");
    JSONArray contentItems = new JSONArray();
    contentItems.add("vo");
    contentItems.add("issuer");
    JSONObject api = new JSONObject();
    JSONObject apiItems = new JSONObject();
    apiItems.put("subject", admin);
    apiItems.put("action", actionItems);
    apiItems.put("content", contentItems);
    api.put("api", apiItems);
    prettyPrint(api);
    return api;
// now for the response
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray)

Example 39 with JSONArray

use of net.sf.json.JSONArray in project OA4MP by ncsa.

the class ThingTester method ldapExample.

public static JSONObject ldapExample() {
    JSONObject ldap = new JSONObject();
    JSONObject ldapContent = new JSONObject();
    ldapContent.put("authorization_type", "none");
    ldapContent.put("address", "ldap.ncsa.illinois.edu");
    ldapContent.put("port", 636);
    ldapContent.put("search_base", "o=MESS,dc=co,dc=cilogon,dc=org");
    JSONArray attr = new JSONArray();
    JSONObject attr1 = new JSONObject();
    attr1.put("name", "memberOf");
    attr1.put("return_name", "isMemberOf");
    attr1.put("return_as_list", false);
    attr.add(attr1);
    JSONObject attr2 = new JSONObject();
    attr2.put("name", "eduPersonOrcid");
    attr2.put("return_as_list", true);
    attr.add(attr2);
    ldapContent.put("search_attributes", attr);
    ldap.put("ldap", ldapContent);
    prettyPrint(ldap);
    return ldap;
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray)

Example 40 with JSONArray

use of net.sf.json.JSONArray in project OA4MP by ncsa.

the class OA2TConverter method toMap.

@Override
public void toMap(V t, ConversionMap<String, Object> map) {
    super.toMap(t, map);
    if (t.getRefreshToken() != null) {
        map.put(getTCK().refreshToken(), t.getRefreshToken().getToken());
    }
    map.put(getTCK().refreshTokenValid(), t.isRefreshTokenValid());
    if (t.getCallback() != null) {
        map.put(getTCK().callbackUri(), t.getCallback().toString());
    }
    map.put(getTCK().expiresIn(), t.getRefreshTokenLifetime());
    if (t.getNonce() != null && 0 < t.getNonce().length()) {
        map.put(getTCK().nonce(), t.getNonce());
    }
    if (t.getScopes().isEmpty()) {
        return;
    }
    JSONArray jsonArray = new JSONArray();
    for (String s : t.getScopes()) {
        jsonArray.add(s);
    }
    map.put(getTCK().scopes(), jsonArray.toString());
    if (t.hasAuthTime()) {
        map.put(getTCK().authTime(), t.getAuthTime());
    }
    map.put(getTCK().flowStates(), t.getFlowStates().toJSON().toString());
}
Also used : JSONArray(net.sf.json.JSONArray)

Aggregations

JSONArray (net.sf.json.JSONArray)144 JSONObject (net.sf.json.JSONObject)109 ArrayList (java.util.ArrayList)31 IOException (java.io.IOException)22 HashMap (java.util.HashMap)20 File (java.io.File)16 Test (org.junit.Test)15 JSON (net.sf.json.JSON)14 Map (java.util.Map)12 JsonConfig (net.sf.json.JsonConfig)10 URISyntaxException (java.net.URISyntaxException)9 URL (java.net.URL)9 URI (java.net.URI)8 SimpleChartData (com.sohu.cache.web.chart.model.SimpleChartData)6 Date (java.util.Date)6 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)5 OutputStream (java.io.OutputStream)5 List (java.util.List)5 CAFunctorFactory (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.claims.CAFunctorFactory)4 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)4