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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations