Search in sources :

Example 6 with OAuthServer

use of org.apache.openmeetings.db.entity.server.OAuthServer in project openmeetings by apache.

the class BackupExport method exportOauth.

/*
	 * ##################### OAuth2 servers
	 */
private void exportOauth(ZipOutputStream zos, ProgressHolder progressHolder) throws Exception {
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    List<OAuthServer> list = auth2Dao.get(0, Integer.MAX_VALUE);
    bindDate(registry, list);
    writeList(serializer, zos, "oauth2servers.xml", "oauth2servers", list);
    progressHolder.setProgress(45);
}
Also used : RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer) Serializer(org.simpleframework.xml.Serializer)

Example 7 with OAuthServer

use of org.apache.openmeetings.db.entity.server.OAuthServer in project openmeetings by apache.

the class ImportInitvalues method loadInitialOAuthServers.

public void loadInitialOAuthServers() {
    // Yandex
    OAuthServer yaServer = new OAuthServer();
    yaServer.setName("Yandex");
    yaServer.setIconUrl("https://yandex.st/morda-logo/i/favicon.ico");
    yaServer.setClientId(CLIENT_PLACEHOLDER);
    yaServer.setClientSecret(SECRET_PLACEHOLDER);
    yaServer.setEnabled(false);
    yaServer.setRequestInfoUrl("https://login.yandex.ru/info?format=json&oauth_token={$access_token}");
    yaServer.setRequestTokenUrl("https://oauth.yandex.ru/token");
    yaServer.setRequestKeyUrl("https://oauth.yandex.ru/authorize?response_type=code&client_id={$client_id}");
    yaServer.setRequestTokenAttributes("grant_type=authorization_code&code={$code}&client_id={$client_id}&client_secret={$client_secret}");
    yaServer.setRequestTokenMethod(RequestMethod.POST);
    yaServer.setLoginParamName("login");
    yaServer.setEmailParamName("default_email");
    yaServer.setFirstnameParamName(FNAME_PARAM);
    yaServer.setLastnameParamName(LNAME_PARAM);
    oauthDao.update(yaServer, null);
    // Google
    OAuthServer googleServer = new OAuthServer();
    googleServer.setName("Google");
    googleServer.setIconUrl("https://www.google.com/images/google_favicon_128.png");
    googleServer.setEnabled(false);
    googleServer.setClientId(CLIENT_PLACEHOLDER);
    googleServer.setClientSecret(SECRET_PLACEHOLDER);
    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_PARAM);
    googleServer.setEmailParamName(EMAIL_PARAM);
    googleServer.setFirstnameParamName("given_name");
    googleServer.setLastnameParamName("family_name");
    oauthDao.update(googleServer, null);
    // Facebook
    OAuthServer fbServer = new OAuthServer();
    fbServer.setName("Facebook");
    fbServer.setIconUrl("https://www.facebook.com/images/fb_icon_325x325.png");
    fbServer.setEnabled(false);
    fbServer.setClientId(CLIENT_PLACEHOLDER);
    fbServer.setClientSecret(SECRET_PLACEHOLDER);
    fbServer.setRequestKeyUrl("https://www.facebook.com/v2.10/dialog/oauth?client_id={$client_id}&redirect_uri={$redirect_uri}&scope=email");
    fbServer.setRequestTokenUrl("https://graph.facebook.com/v2.10/oauth/access_token");
    fbServer.setRequestTokenMethod(RequestMethod.POST);
    fbServer.setRequestTokenAttributes("client_id={$client_id}&redirect_uri={$redirect_uri}&client_secret={$client_secret}&code={$code}");
    fbServer.setRequestInfoUrl("https://graph.facebook.com/me?access_token={$access_token}&fields=id,first_name,last_name,email");
    fbServer.setLoginParamName("id");
    fbServer.setEmailParamName(EMAIL_PARAM);
    fbServer.setFirstnameParamName(FNAME_PARAM);
    fbServer.setLastnameParamName(LNAME_PARAM);
    oauthDao.update(fbServer, null);
    // VK
    OAuthServer vkServer = new OAuthServer();
    vkServer.setName("VK");
    vkServer.setIconUrl("https://vk.com/images/safari_152.png");
    vkServer.setEnabled(false);
    vkServer.setClientId(CLIENT_PLACEHOLDER);
    vkServer.setClientSecret(SECRET_PLACEHOLDER);
    vkServer.setRequestKeyUrl("https://oauth.vk.com/authorize?client_id={$client_id}&scope=email&redirect_uri={$redirect_uri}&response_type=code&v=5.68");
    vkServer.setRequestTokenUrl("https://oauth.vk.com/access_token");
    vkServer.setRequestTokenMethod(RequestMethod.POST);
    vkServer.setRequestTokenAttributes("client_id={$client_id}&client_secret={$client_secret}&code={$code}&redirect_uri={$redirect_uri}");
    vkServer.setRequestInfoUrl("https://api.vk.com/method/users.get?user_ids=&access_token={$access_token}&fields=id,first_name,last_name,email&name_case=nom");
    vkServer.setLoginParamName("uid");
    vkServer.setEmailParamName(EMAIL_PARAM);
    vkServer.setFirstnameParamName(FNAME_PARAM);
    vkServer.setLastnameParamName(LNAME_PARAM);
    oauthDao.update(vkServer, null);
}
Also used : OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer)

Example 8 with OAuthServer

use of org.apache.openmeetings.db.entity.server.OAuthServer in project openmeetings by apache.

the class TestOAuthUser method firstLevel.

@Test
public void firstLevel() {
    OAuthServer server = new OAuthServer();
    server.setLoginParamName("id");
    server.setEmailParamName("email");
    server.setFirstnameParamName("given_name");
    server.setLastnameParamName("family_name");
    OAuthUser user = new OAuthUser("{'id': '11klahjsfwehf5', 'email': 'alsfkvslvmclqwkdsm@gmail.com', 'verified_email': true, 'name': 'John Doe', 'given_name': 'John', 'family_name': 'Doe', 'link': 'https://plus.google.com/+JohnDoe', 'picture': 'https://lh3.googleusercontent.com/somehash/photo.jpg', 'gender': 'male', 'locale': 'en'}", server);
    assertEquals("UID should be correct", "11klahjsfwehf5", user.getUid());
    assertEquals("Email should be correct", "alsfkvslvmclqwkdsm@gmail.com", user.getEmail());
    assertEquals("Firstname should be correct", "John", user.getFirstName());
    assertEquals("Lastname should be correct", "Doe", user.getLastName());
}
Also used : OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer) Test(org.junit.Test)

Example 9 with OAuthServer

use of org.apache.openmeetings.db.entity.server.OAuthServer in project openmeetings by apache.

the class BackupImport method importOauth.

/*
	 * ##################### OAuth2 servers
	 */
private void importOauth(File f, Serializer simpleSerializer) throws Exception {
    log.info("Ldap config import complete, starting OAuth2 server import");
    List<OAuthServer> list = readList(simpleSerializer, f, "oauth2servers.xml", "oauth2servers", OAuthServer.class);
    for (OAuthServer s : list) {
        s.setId(null);
        auth2Dao.update(s, null);
    }
}
Also used : OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer)

Example 10 with OAuthServer

use of org.apache.openmeetings.db.entity.server.OAuthServer in project openmeetings by apache.

the class OAuthForm method onDeleteSubmit.

@Override
protected void onDeleteSubmit(AjaxRequestTarget target, Form<?> form) {
    oauthDao.delete(getModelObject(), getUserId());
    this.setModelObject(new OAuthServer());
    target.add(listContainer);
    target.add(this);
    reinitJs(target);
}
Also used : OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer)

Aggregations

OAuthServer (org.apache.openmeetings.db.entity.server.OAuthServer)11 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 OAuth2Dao (org.apache.openmeetings.db.dao.server.OAuth2Dao)1 LdapConfig (org.apache.openmeetings.db.entity.server.LdapConfig)1 User (org.apache.openmeetings.db.entity.user.User)1 SearchableDataView (org.apache.openmeetings.web.admin.SearchableDataView)1 PagedEntityListPanel (org.apache.openmeetings.web.common.PagedEntityListPanel)1 DataViewContainer (org.apache.openmeetings.web.data.DataViewContainer)1 OmOrderByBorder (org.apache.openmeetings.web.data.OmOrderByBorder)1 AjaxEventBehavior (org.apache.wicket.ajax.AjaxEventBehavior)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 Label (org.apache.wicket.markup.html.basic.Label)1 Item (org.apache.wicket.markup.repeater.Item)1 Serializer (org.simpleframework.xml.Serializer)1 Registry (org.simpleframework.xml.convert.Registry)1 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)1 Persister (org.simpleframework.xml.core.Persister)1 Strategy (org.simpleframework.xml.strategy.Strategy)1