コード例 #1
0
  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);
  }
コード例 #2
0
  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();
  }
コード例 #3
0
  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();
  }