use of edu.uiuc.ncsa.security.oauth_2_0.OA2ClientProvider 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);
}
use of edu.uiuc.ncsa.security.oauth_2_0.OA2ClientProvider in project OA4MP by ncsa.
the class ClientManagerTest method testThing.
@Test
public void testThing(ClientStore clientStore) throws Exception {
// create a request and use the SATFactory to pull it apart.
JSONObject request = new JSONObject();
JSONObject requestContent = new JSONObject();
OA2ClientProvider clientProvider = new OA2ClientProvider(new OA4MPIdentifierProvider(OA4MPIdentifierProvider.CLIENT_ID));
OA2ClientConverter converter = new OA2ClientConverter(clientProvider);
JSONObject jsonClient = new JSONObject();
converter.toJSON(getOa2Client(clientStore), jsonClient);
requestContent.put(KEYS_SUBJECT, jsonClient);
JSONObject action = new JSONObject();
action.put("type", "client");
action.put("method", ACTION_APPROVE);
requestContent.put(KEYS_ACTION, action);
JSONObject jsonClient2 = new JSONObject();
converter.toJSON(getOa2Client(clientStore), jsonClient2);
requestContent.put(KEYS_TARGET, jsonClient2);
request.put(KEYS_API, requestContent);
System.out.println(SATFactory.getSubject(request));
System.out.println(SATFactory.getMethod(request));
System.out.println(SATFactory.getType(request));
System.out.println(SATFactory.getTarget(request));
System.out.println(SATFactory.getContent(request));
}
use of edu.uiuc.ncsa.security.oauth_2_0.OA2ClientProvider in project OA4MP by ncsa.
the class ClientManagerTest method testGetSerialization.
@Test
public void testGetSerialization(CMTestStoreProvider tp2) throws Exception {
JSONObject request = new JSONObject();
JSONObject requestContent = new JSONObject();
DDServerTests.CC cc = setupClients(tp2);
OA2ClientProvider clientProvider = new OA2ClientProvider(new OA4MPIdentifierProvider(OA4MPIdentifierProvider.CLIENT_ID));
JSONObject jsonClient = new JSONObject();
getAdminClientConverter(tp2).toJSON(cc.adminClient, jsonClient);
requestContent.put(KEYS_SUBJECT, jsonClient);
JSONObject action = new JSONObject();
action.put("type", SAT.TYPE_CLIENT);
action.put("method", ACTION_GET);
requestContent.put(KEYS_ACTION, action);
JSONObject jsonClient2 = new JSONObject();
getClientConverter(tp2).toJSON(cc.client, jsonClient2);
requestContent.put(KEYS_TARGET, jsonClient2);
request.put(KEYS_API, requestContent);
}
use of edu.uiuc.ncsa.security.oauth_2_0.OA2ClientProvider in project OA4MP by ncsa.
the class ClientManagerTest method testApproveSerialization.
@Test
public void testApproveSerialization(ClientStore clientStore) throws Exception {
JSONObject request = new JSONObject();
JSONObject requestContent = new JSONObject();
OA2ClientProvider clientProvider = new OA2ClientProvider(new OA4MPIdentifierProvider(OA4MPIdentifierProvider.CLIENT_ID));
OA2ClientConverter converter = new OA2ClientConverter(clientProvider);
JSONObject jsonClient = new JSONObject();
converter.toJSON(getOa2Client(clientStore), jsonClient);
requestContent.put(KEYS_SUBJECT, jsonClient);
JSONObject action = new JSONObject();
action.put("type", "client");
action.put("method", ACTION_APPROVE);
requestContent.put(KEYS_ACTION, action);
JSONObject jsonClient2 = new JSONObject();
converter.toJSON(getOa2Client(clientStore), jsonClient2);
requestContent.put(KEYS_TARGET, jsonClient2);
request.put(KEYS_API, requestContent);
}
Aggregations