public static void storeAccessToken(Graph graph, XDI3Segment userXri, String accessToken) { XDI3Segment contextNodeXri = new XDI3Segment( "" + GoogleCalendarMapping.XRI_S_GOOGLE_CALENDAR_CONTEXT + userXri + XDIMessagingConstants.XRI_S_OAUTH_TOKEN); ContextNode contextNode = graph.findContextNode(contextNodeXri, true); if (contextNode.containsLiteral()) contextNode.getLiteral().setLiteralData(accessToken); else contextNode.createLiteral(accessToken); }
public static void removeAccessToken(Graph graph, XDI3Segment userXri) { XDI3Segment contextNodeXri = new XDI3Segment( "" + GoogleCalendarMapping.XRI_S_GOOGLE_CALENDAR_CONTEXT + userXri + XDIMessagingConstants.XRI_S_OAUTH_TOKEN); ContextNode contextNode = graph.findContextNode(contextNodeXri, false); if (contextNode == null) return; contextNode.delete(); }
public static String retrieveAccessToken(Graph graph, XDI3Segment userXri) { XDI3Segment contextNodeXri = new XDI3Segment( "" + GoogleCalendarMapping.XRI_S_GOOGLE_CALENDAR_CONTEXT + userXri + XDIMessagingConstants.XRI_S_OAUTH_TOKEN); ContextNode contextNode = graph.findContextNode(contextNodeXri, false); if (contextNode == null) return null; Literal literal = contextNode.getLiteral(); if (literal == null) return null; return literal.getLiteralData(); }