Search in sources :

Example 1 with OAuthServer

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

the class OAuthForm method onNewSubmit.

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

Example 2 with OAuthServer

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

the class OAuthForm method onRefreshSubmit.

@Override
protected void onRefreshSubmit(AjaxRequestTarget target, Form<?> form) {
    OAuthServer server = this.getModelObject();
    if (server.getId() != null) {
        server = oauthDao.get(getModelObject().getId());
    } else {
        server = new OAuthServer();
    }
    this.setModelObject(server);
    target.add(this);
    reinitJs(target);
}
Also used : OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer)

Example 3 with OAuthServer

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

the class OAuthPanel method onInitialize.

@Override
protected void onInitialize() {
    SearchableDataView<OAuthServer> dataView = new SearchableDataView<OAuthServer>("oauthServersList", new SearchableDataProvider<>(OAuth2Dao.class)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(Item<OAuthServer> item) {
            final OAuthServer server = item.getModelObject();
            item.add(new Label("id"));
            item.add(new Label("name"));
            item.add(new AjaxEventBehavior(EVT_CLICK) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    form.setModelObject(server);
                    form.hideNewRecord();
                    target.add(form, listContainer);
                    reinitJs(target);
                }
            });
            item.add(AttributeModifier.replace(ATTR_CLASS, getRowClass(server.getId(), form.getModelObject().getId())));
        }
    };
    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<>(listContainer, dataView, navigator);
    container.addLink(new OmOrderByBorder<>("orderById", "id", container)).addLink(new OmOrderByBorder<>("orderByName", "name", container));
    add(container.getLinks());
    add(navigator);
    form = new OAuthForm("form", listContainer, new OAuthServer());
    form.showNewRecord();
    add(form);
    super.onInitialize();
}
Also used : AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Label(org.apache.wicket.markup.html.basic.Label) OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer) OAuth2Dao(org.apache.openmeetings.db.dao.server.OAuth2Dao) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchableDataView(org.apache.openmeetings.web.admin.SearchableDataView) Item(org.apache.wicket.markup.repeater.Item) PagedEntityListPanel(org.apache.openmeetings.web.common.PagedEntityListPanel) OmOrderByBorder(org.apache.openmeetings.web.data.OmOrderByBorder) DataViewContainer(org.apache.openmeetings.web.data.DataViewContainer)

Example 4 with OAuthServer

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

the class UserForm method updateDomain.

public void updateDomain(AjaxRequestTarget target) {
    User u = getModelObject();
    final Map<Long, String> values = new HashMap<>();
    List<Long> ids = new ArrayList<>();
    if (u.getType() == Type.ldap) {
        for (LdapConfig c : ldapDao.getActive()) {
            ids.add(c.getId());
            values.put(c.getId(), c.getName());
        }
    }
    if (u.getType() == Type.oauth) {
        for (OAuthServer s : oauthDao.getActive()) {
            ids.add(s.getId());
            values.put(s.getId(), s.getName());
        }
    }
    domainId.setChoices(ids);
    domainId.setChoiceRenderer(new ChoiceRenderer<Long>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Object getDisplayValue(Long object) {
            return values.get(object);
        }

        @Override
        public String getIdValue(Long object, int index) {
            return "" + object;
        }
    });
    domain.setVisible(u.getType() == Type.ldap || u.getType() == Type.oauth);
    if (target != null) {
        target.add(domain);
    }
}
Also used : User(org.apache.openmeetings.db.entity.user.User) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer) LdapConfig(org.apache.openmeetings.db.entity.server.LdapConfig)

Example 5 with OAuthServer

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

the class TestOAuthUser method secondLevel.

@Test
public void secondLevel() {
    OAuthServer server = new OAuthServer();
    server.setLoginParamName("uid");
    server.setEmailParamName("email");
    server.setFirstnameParamName("first_name");
    server.setLastnameParamName("last_name");
    OAuthUser user = new OAuthUser("{'response':[{'uid':4uidhere4,'first_name':'John','last_name':'Doe'}]}", server);
    assertEquals("UID should be correct", "4uidhere4", user.getUid());
    assertNull("Email should be empty", user.getEmail());
    assertEquals("Firstname should be correct", "John", user.getFirstName());
    assertEquals("Lastname should be correct", "Doe", user.getLastName());
    server.setIconUrl("https://goo.gl/images/q23g7Y");
    user = new OAuthUser("{'response':[{'uid':4uidhere4,'first_name':'John','last_name':'Doe'}]}", server);
    assertEquals("Email should be constructed", "4uidhere4@goo.gl", user.getEmail());
}
Also used : OAuthServer(org.apache.openmeetings.db.entity.server.OAuthServer) Test(org.junit.Test)

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