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);
}
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);
}
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();
}
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);
}
}
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());
}
Aggregations