private PeopleData readPeopleData(PersonImpl person) throws ClientServicesException {
   if (!person.isAuthenticatedUser()) {
     // should never happen as this should be guarded
     return null;
   }
   Endpoint ep = EndpointFactory.getEndpointUnchecked(EndpointFactory.SERVER_SMARTCLOUD);
   if (ep != null) {
     if (ep.isAuthenticated()) {
       // Find the SmartCloud id
       GenericService service = new GenericService(ep);
       //                    service.get("/manage/oauth/getUserIdentity",null, "json");
       //
       // TODO - Padraic
       HandlerJson json = new HandlerJson();
       Object result = service.get("/manage/oauth/getUserIdentity", json).getData();
       if (result instanceof JsonJavaObject) {
         JsonNavigator jsonUtil = new JsonNavigator(result);
         PeopleData data = new PeopleData();
         data.smartCloudSubscriberId = jsonUtil.stringValue("subscriberid");
         return data;
       }
     }
   }
   return EMPTY_DATA;
 }
Ejemplo n.º 2
0
 public static void authenticateEndpoint(Endpoint endpoint, String user, String password) {
   try {
     Field userField = endpoint.getClass().getSuperclass().getDeclaredField("user");
     userField.setAccessible(true);
     userField.set(endpoint, user);
     Field passwordField = endpoint.getClass().getSuperclass().getDeclaredField("password");
     passwordField.setAccessible(true);
     passwordField.set(endpoint, password);
   } catch (SecurityException e) {
     fail(e.getMessage());
     e.printStackTrace();
   } catch (NoSuchFieldException e) {
     fail(e.getMessage());
     e.printStackTrace();
   } catch (IllegalArgumentException e) {
     fail(e.getMessage());
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     fail(e.getMessage());
     e.printStackTrace();
   }
 }