Package org.apache.openmeetings.db.entity.server

Examples of org.apache.openmeetings.db.entity.server.OAuthServer


      private static final long serialVersionUID = -7701640237947383416L;

      @Override
      protected void populateItem(Item<OAuthServer> item) {
        final OAuthServer server = item.getModelObject();
        item.add(new Label("oauthServerId", String.valueOf(server.getId())));
        item.add(new Label("name", server.getName()));
        item.add(new AjaxEventBehavior("onclick") {

          private static final long serialVersionUID = 7380727643346943181L;

          @Override
          protected void onEvent(AjaxRequestTarget target) {
            form.setModelObject(server);
            form.hideNewRecord();
            target.add(form, listContainer);
            target.appendJavaScript("oauthPanelInit();");
          }
        });
        item.add(AttributeModifier.replace("class", "clickable ui-widget-content"
            + (server.getId().equals(form.getModelObject().getId()) ? " ui-state-active" : "")));
      }
     
    };
   
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {
      private static final long serialVersionUID = -1L;

      @Override
      protected void onEvent(AjaxRequestTarget target) {
        target.add(listContainer);
      }
    };
    DataViewContainer<OAuthServer> container = new DataViewContainer<OAuthServer>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<OAuthServer>("orderById", "oauthServerId", container))
      .addLink(new OmOrderByBorder<OAuthServer>("orderByName", "name", container));
    add(container.getLinks());
    add(navigator);
   
    form = new OAuthForm("form", listContainer, new OAuthServer());
    form.showNewRecord();
        add(form);
  }
View Full Code Here


  }
 
  public OAuthServer get(long id) {
    TypedQuery<OAuthServer> query = em.createNamedQuery("getOAuthServerById", OAuthServer.class);
    query.setParameter("id", id);
    OAuthServer result = null;
    try {
      result = query.getSingleResult();
    } catch (NoResultException e) {}
    return result;
  }
View Full Code Here

    log.debug("All languages are imported");
  }

  public void loadInitialOAuthServers() throws Exception {
    // Yandex
    OAuthServer yandexServer = new OAuthServer();
    yandexServer.setName("Yandex");
    yandexServer.setIconUrl("http://yandex.st/morda-logo/i/favicon.ico");
    yandexServer.setClientId("<put your client_id>");
    yandexServer.setClientSecret("<put your client_secret>");
    yandexServer.setEmailParamName("default_email");
    yandexServer.setEnabled(false);
    yandexServer.setLoginParamName("default_email");
    yandexServer.setRequestInfoUrl("https://login.yandex.ru/info?format=json&oauth_token={$access_token}");
    yandexServer.setRequestTokenUrl("https://oauth.yandex.ru/token");
    yandexServer.setRequestKeyUrl("https://oauth.yandex.ru/authorize?response_type=code&client_id={$client_id}");
    yandexServer.setRequestTokenAttributes("grant_type=authorization_code&code={$code}&client_id={$client_id}&client_secret={$client_secret}");
    yandexServer.setRequestTokenMethod(RequestMethod.POST);
    oauthDao.update(yandexServer, null);
   
    // Google
    OAuthServer googleServer = new OAuthServer();
    googleServer.setName("Google");
    googleServer.setIconUrl("https://www.google.ru/images/google_favicon_128.png");
    googleServer.setEnabled(false);
    googleServer.setClientId("<put your client_id>");
    googleServer.setClientSecret("<put your client_secret>");
    googleServer.setRequestKeyUrl("https://accounts.google.com/o/oauth2/auth?redirect_uri={$redirect_uri}&response_type=code&client_id={$client_id}"
        + "&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile");
    googleServer.setRequestTokenUrl("https://accounts.google.com/o/oauth2/token");
    googleServer.setRequestTokenMethod(RequestMethod.POST);
    googleServer.setRequestTokenAttributes("code={$code}&client_id={$client_id}&client_secret={$client_secret}&redirect_uri={$redirect_uri}&grant_type=authorization_code");
    googleServer.setRequestInfoUrl("https://www.googleapis.com/oauth2/v1/userinfo?access_token={$access_token}");
    googleServer.setLoginParamName("email");
    googleServer.setEmailParamName("email");
    googleServer.setFirstnameParamName("given_name");
    googleServer.setLastnameParamName("family_name");
    oauthDao.update(googleServer, null);
   
    // Facebook
    OAuthServer facebookServer = new OAuthServer();
    facebookServer.setName("Facebook");
    facebookServer.setIconUrl("https://www.facebook.com/images/fb_icon_325x325.png");
    facebookServer.setEnabled(false);
    facebookServer.setClientId("<put your client_id>");
    facebookServer.setClientSecret("<put your client_secret>");
    facebookServer.setRequestKeyUrl("https://www.facebook.com/dialog/oauth?client_id={$client_id}&redirect_uri={$redirect_uri}&scope=email");
    facebookServer.setRequestTokenUrl("https://graph.facebook.com/oauth/access_token");
    facebookServer.setRequestTokenMethod(RequestMethod.POST);
    facebookServer.setRequestTokenAttributes("client_id={$client_id}&redirect_uri={$redirect_uri}&client_secret={$client_secret}&code={$code}");
    facebookServer.setRequestInfoUrl("https://graph.facebook.com/me?access_token={$access_token}&fields=username,first_name,last_name,email");
    facebookServer.setLoginParamName("username");
    facebookServer.setEmailParamName("email");
    facebookServer.setFirstnameParamName("first_name");
    facebookServer.setLastnameParamName("last_name");
    oauthDao.update(facebookServer, null);
  }
View Full Code Here

      private static final long serialVersionUID = -7701640237947383416L;

      @Override
      protected void populateItem(Item<OAuthServer> item) {
        final OAuthServer server = item.getModelObject();
        item.add(new Label("oauthServerId", String.valueOf(server.getId())));
        item.add(new Label("name", server.getName()));
        item.add(new AjaxEventBehavior("onclick") {

          private static final long serialVersionUID = 7380727643346943181L;

          @Override
          protected void onEvent(AjaxRequestTarget target) {
            form.setModelObject(server);
            form.hideNewRecord();
            target.add(form, listContainer);
            target.appendJavaScript("oauthPanelInit();");
          }
        });
        item.add(AttributeModifier.replace("class", "clickable ui-widget-content"
            + (server.getId().equals(form.getModelObject().getId()) ? " selected" : "")));
      }
     
    };
   
    add(listContainer.add(dataView).setOutputMarkupId(true));
    PagedEntityListPanel navigator = new PagedEntityListPanel("navigator", dataView) {
      private static final long serialVersionUID = -1L;

      @Override
      protected void onEvent(AjaxRequestTarget target) {
        target.add(listContainer);
      }
    };
    DataViewContainer<OAuthServer> container = new DataViewContainer<OAuthServer>(listContainer, dataView, navigator);
    container.setLinks(new OmOrderByBorder<OAuthServer>("orderById", "oauthServerId", container),
               new OmOrderByBorder<OAuthServer>("orderByName", "name", container));
    add(container.orderLinks);
    add(navigator);
   
    form = new OAuthForm("form", listContainer, new OAuthServer());
    form.showNewRecord();
        add(form);
  }
View Full Code Here

TOP

Related Classes of org.apache.openmeetings.db.entity.server.OAuthServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.