Search in sources :

Example 1 with OA2Client

use of edu.uiuc.ncsa.security.oauth_2_0.OA2Client in project OA4MP by ncsa.

the class OA2NewClientNotifier method getReplacements.

@Override
protected Map<String, String> getReplacements(Client client) {
    Map<String, String> replacements = super.getReplacements(client);
    OA2Client oa2Client = (OA2Client) client;
    // don't need for OA2 clients.
    replacements.remove(FAILURE_URI);
    replacements.put(SCOPES, String.valueOf(oa2Client.getScopes()));
    replacements.put(CALLBACK, String.valueOf(oa2Client.getCallbackURIs()));
    replacements.put(REFRESH_ENABLED, Boolean.toString(oa2Client.isRTLifetimeEnabled()));
    if (oa2Client.isRTLifetimeEnabled()) {
        replacements.put(REFRESH_LIFETIME, Long.toString(oa2Client.getRtLifetime()));
    } else {
        replacements.put(REFRESH_LIFETIME, "n/a");
    }
    replacements.put(SIGN_TOKEN_OK, Boolean.toString(oa2Client.isSignTokens()));
    if (oa2Client.getLdaps() == null || oa2Client.getLdaps().isEmpty()) {
        replacements.put(LDAP_CONFIGURATION, "(none)");
    } else {
        replacements.put(LDAP_CONFIGURATION, LDAPConfigurationUtil.toJSON(oa2Client.getLdaps()).toString(2));
    }
    if (oa2Client.getIssuer() == null) {
        replacements.put(ISSUER, "(none)");
    } else {
        replacements.put(ISSUER, oa2Client.getIssuer());
    }
    return replacements;
}
Also used : OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client)

Example 2 with OA2Client

use of edu.uiuc.ncsa.security.oauth_2_0.OA2Client in project OA4MP by ncsa.

the class AbstractDDServer method subset.

/**
 * This will take a client and a list of attributes and return the requested subset.
 *
 * @param client
 * @param attributes
 * @return
 */
protected OA2Client subset(OA2Client client, List<String> attributes) {
    ColumnMap map = new ColumnMap();
    cose.getClientStore().getACConverter().toMap(client, map);
    ColumnMap reducedMap = new ColumnMap();
    for (String key : attributes) {
        reducedMap.put(key, map.get(key));
    }
    // Have to always include the identifier.
    reducedMap.put(cose.getClientStore().getACConverter().getKeys().identifier(), client.getIdentifierString());
    OA2Client x = (OA2Client) cose.getClientStore().getACConverter().fromMap(reducedMap, null);
    return x;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client)

Example 3 with OA2Client

use of edu.uiuc.ncsa.security.oauth_2_0.OA2Client in project OA4MP by ncsa.

the class ResponseSerializer method clientToJSON.

private JSONObject clientToJSON(OA2Client client) {
    JSONObject json = new JSONObject();
    json.put("status", 0);
    OA2ClientKeys keys = (OA2ClientKeys) cose.getClientStore().getACConverter().getKeys();
    List<String> allKeys = keys.allKeys();
    allKeys.remove(keys.secret());
    OA2Client newClient = (OA2Client) cose.getClientStore().getACConverter().subset(client, allKeys);
    JSONObject jsonClient = new JSONObject();
    cose.getClientStore().getACConverter().toJSON(newClient, jsonClient);
    json.put("content", jsonClient);
    return json;
}
Also used : OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) JSONObject(net.sf.json.JSONObject) OA2ClientKeys(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientKeys)

Example 4 with OA2Client

use of edu.uiuc.ncsa.security.oauth_2_0.OA2Client in project OA4MP by ncsa.

the class AttributeServer method removeClient.

/**
 * Remove a subset of attributes for client.
 *
 * @param request
 * @return
 */
protected AttributeClientResponse removeClient(AttributeRemoveRequest request) {
    canWrite(request);
    OA2Client client = (OA2Client) getClientStore().get(request.getClient().getIdentifier());
    ColumnMap map = new ColumnMap();
    getClientConverter().toMap(client, map);
    for (String key : request.getAttributes()) {
        // don't let anyone change the identifier.
        if (!key.equals(getClientConverter().getKeys().identifier())) {
            map.remove(key);
        }
    }
    OA2Client updatedClient = getClientConverter().fromMap(map, null);
    getClientStore().save(updatedClient);
    AttributeClientResponse attributeClientResponse = new AttributeClientResponse(updatedClient);
    return attributeClientResponse;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client)

Example 5 with OA2Client

use of edu.uiuc.ncsa.security.oauth_2_0.OA2Client in project OA4MP by ncsa.

the class ClientManagerTest method testOA2Client.

@Test
public void testOA2Client() throws Exception {
    OA2ClientProvider clientProvider = new OA2ClientProvider(new OA4MPIdentifierProvider(OA4MPIdentifierProvider.CLIENT_ID));
    OA2ClientMemoryStore store = new OA2ClientMemoryStore(clientProvider);
    OA2ClientConverter converter = new OA2ClientConverter(clientProvider);
    OA2Client c = getOa2Client(store);
    JSONObject j = new JSONObject();
    converter.toJSON(c, j);
    System.out.println(j);
    Client c2 = converter.fromJSON(j);
    assert c2.equals(c);
}
Also used : OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) OA4MPIdentifierProvider(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.transactions.OA4MPIdentifierProvider) OA2ClientProvider(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientProvider) JSONObject(net.sf.json.JSONObject) OA2ClientMemoryStore(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.storage.OA2ClientMemoryStore) Client(edu.uiuc.ncsa.security.delegation.storage.Client) OA2Client(edu.uiuc.ncsa.security.oauth_2_0.OA2Client) OA2ClientConverter(edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter) Test(org.junit.Test)

Aggregations

OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)31 JSONObject (net.sf.json.JSONObject)10 OA2ClientKeys (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientKeys)7 LinkedList (java.util.LinkedList)7 ColumnMap (edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap)6 LDAPConfiguration (edu.uiuc.ncsa.security.oauth_2_0.server.config.LDAPConfiguration)5 AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)4 Permission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)4 Identifier (edu.uiuc.ncsa.security.core.Identifier)4 OA2ClientConverter (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter)4 JSONArray (net.sf.json.JSONArray)4 TypeAttribute (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeAttribute)3 TypePermission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission)3 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)3 OA2GeneralError (edu.uiuc.ncsa.security.oauth_2_0.OA2GeneralError)3 LDAPEntry (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.ldap.LDAPEntry)2 ActionAdd (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionAdd)2 TypeClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)2 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)2 ClaimSource (edu.uiuc.ncsa.security.oauth_2_0.server.ClaimSource)2