List of usage examples for org.apache.wicket.util.string StringValue valueOf
public static StringValue valueOf(final AppendingStringBuffer buffer)
From source file:org.apache.openmeetings.calendar.TestAppointmentAddAppointment.java
License:Apache License
@Test public void testCreate() { Appointment a = new Appointment(); a.setTitle("Test title"); setTime(a);/*from w w w .j a va 2s . c o m*/ a.setReminder(Reminder.ical); a.setMeetingMembers(new ArrayList<>()); User owner = userDao.get(1L); a.setOwner(owner); a.setRoom(new Room()); a.getRoom().setAppointment(true); a.getRoom().setType(Room.Type.conference); for (int i = 0; i < 3; ++i) { MeetingMember mm = new MeetingMember(); mm.setUser(getContact(randomUUID().toString(), owner.getId())); a.getMeetingMembers().add(mm); } a = appointmentDao.update(a, owner.getId()); assertNotNull("Saved appointment should have valid id: " + a.getId(), a.getId()); assertEquals("Saved appointment should have corect count of guests: ", 3, a.getMeetingMembers().size()); for (MeetingMember mm : a.getMeetingMembers()) { assertNotNull("Saved guest should have valid id: ", mm.getId()); assertNotNull("Saved guest should have valid invitation: ", mm.getInvitation()); assertNotNull("Saved guest should have invitation with ID: ", mm.getInvitation().getId()); } WebSession ws = WebSession.get(); Appointment a1 = appointmentDao.get(a.getId()); ws.checkHashes(StringValue.valueOf(""), StringValue.valueOf(a1.getMeetingMembers().get(0).getInvitation().getHash())); assertTrue("Login via secure hash should be successful", ws.isSignedIn()); }
From source file:org.apache.openmeetings.cli.Admin.java
License:Apache License
private WebApplicationContext getApplicationContext() { if (ctx == null) { Long lngId = StringValue.valueOf(cfg.defaultLangId).toLong(1L); ctx = ApplicationHelper.getApplicationContext(lngId); SchedulerFactoryBean sfb = ctx.getBean(SchedulerFactoryBean.class); try {//from w ww . j av a 2 s . c o m sfb.getScheduler().shutdown(false); } catch (Exception e) { handleError("Unable to shutdown schedulers", e); } } return ctx; }
From source file:org.apache.openmeetings.core.remote.red5.ScopeApplicationAdapter.java
License:Apache License
@Override public boolean roomConnect(IConnection conn, Object[] params) { log.debug("roomConnect : "); IServiceCapableConnection service = (IServiceCapableConnection) conn; String streamId = conn.getClient().getId(); log.debug("### Client connected to OpenMeetings, register Client StreamId: " + streamId + " scope " + conn.getScope().getName()); // Set StreamId in Client service.invoke("setId", new Object[] { streamId }, this); Map<String, Object> map = conn.getConnectParams(); String swfURL = map.containsKey("swfUrl") ? (String) map.get("swfUrl") : ""; String tcUrl = map.containsKey("tcUrl") ? (String) map.get("tcUrl") : ""; Map<String, Object> connParams = getConnParams(params); String uid = (String) connParams.get("uid"); String securityCode = (String) connParams.get(SECURITY_CODE_PARAM); if (!Strings.isEmpty(securityCode)) { //FIXME TODO add better mechanism, this is for external applications like ffmpeg Client parent = sessionManager.getClientByPublicSID(securityCode, null); if (parent == null || !parent.getScope().equals(conn.getScope().getName())) { return rejectClient(); }//from ww w . ja v a2 s .com } if ("networktest".equals(uid)) { return true; } Client parentClient = null; //TODO add similar code for other connections if (map.containsKey("screenClient")) { String parentSid = (String) map.get("parentSid"); parentClient = sessionManager.getClientByPublicSID(parentSid, null); if (parentClient == null) { return rejectClient(); } } Client rcm = new Client(); rcm.setStreamid(conn.getClient().getId()); StringValue scn = StringValue.valueOf(conn.getScope().getName()); rcm.setScope(scn.toString()); long roomId = scn.toLong(Long.MIN_VALUE); if (Long.MIN_VALUE != roomId) { rcm.setRoomId(roomId); } else if (!"hibernate".equals(scn.toString())) { return rejectClient(); } rcm.setUserport(conn.getRemotePort()); rcm.setUserip(conn.getRemoteAddress()); rcm.setSwfurl(swfURL); rcm.setTcUrl(tcUrl); rcm.setNativeSsl(Boolean.TRUE.equals(connParams.get(NATIVE_SSL_PARAM))); rcm.setPublicSID(uid); rcm.setSecurityCode(securityCode); rcm = sessionManager.add(rcm, null); if (rcm == null) { log.warn("Failed to create Client on room connect"); return false; } SessionVariablesUtil.initClient(conn.getClient(), rcm.getPublicSID()); //TODO add similar code for other connections, merge with above block if (map.containsKey("screenClient")) { //TODO add check for room rights String parentSid = parentClient.getPublicSID(); rcm.setRoomId(Long.valueOf(conn.getScope().getName())); rcm.setScreenClient(true); SessionVariablesUtil.setIsScreenClient(conn.getClient()); rcm.setUserId(parentClient.getUserId()); Long userId = rcm.getUserId(); SessionVariablesUtil.setUserId(conn.getClient(), userId); rcm.setStreamPublishName(parentSid); User u = null; if (userId != null) { long _uid = userId.longValue(); u = userDao.get(_uid < 0 ? -_uid : _uid); } if (u != null) { rcm.setUsername(u.getLogin()); rcm.setFirstname(u.getFirstname()); rcm.setLastname(u.getLastname()); } log.debug("publishName :: " + rcm.getStreamPublishName()); sessionManager.updateClientByStreamId(streamId, rcm, false, null); } // Log the User conferenceLogDao.add(ConferenceLog.Type.clientConnect, rcm.getUserId(), streamId, null, rcm.getUserip(), rcm.getScope()); return true; }
From source file:org.apache.openmeetings.installation.ImportInitvalues.java
License:Apache License
public void loadAll(InstallationConfig cfg, boolean force) throws Exception { // FIXME dummy check if installation was performed before if (!force && userDao.count() > 0) { log.debug("System contains users, no need to install data one more time."); return;// w ww . j av a 2 s . c o m } loadSystem(cfg, force); loadInitUserAndGroup(cfg); progress = 84; loadDefaultRooms("1".equals(cfg.createDefaultRooms), StringValue.valueOf(cfg.defaultLangId).toLong(1L)); progress = 100; }
From source file:org.apache.openmeetings.webservice.TestUserService.java
License:Apache License
@Test public void hashTest() throws OmException { ServiceResult r = login();//from w ww . j a v a 2 s.co m ServiceResult r1 = getHash(r.getMessage(), false); assertEquals("OM Call should be successful", Type.SUCCESS.name(), r1.getType()); ensureApplication(-1L); // to ensure WebSession is attached WebSession ws = WebSession.get(); assertTrue(ws.signIn(adminUsername, userpass, User.Type.user, null)); Long userId0 = WebSession.getUserId(); ws.checkHashes(StringValue.valueOf(r1.getMessage()), StringValue.valueOf("")); assertTrue("Login via secure hash should be successful", ws.isSignedIn()); Long userId1 = WebSession.getUserId(); assertNotEquals(userId0, userId1); User u = getBean(UserDao.class).get(userId1); assertNotNull("User should be created successfuly", u); assertEquals("Picture URL should be preserved", DUMMY_PICTURE_URL, u.getPictureUri()); }
From source file:org.artifactory.common.wicket.component.form.SecureForm.java
License:Open Source License
@Override protected void onValidate() { // Check the random id in the hidden field. This guards against CSRF attacks. StringValue requestToken = getRequest().getPostParameters().getParameterValue(TOKEN_NAME); if (!requestToken.equals(StringValue.valueOf(getToken()))) { String message = "Attempted unauthorized form submission"; log.warn(message);/*from www . ja v a2s . c o m*/ AccessLogger.unauthorizedFormSubmit(message); throw new UnauthorizedActionException(this, new Action("submit without CSRF token")); } super.onValidate(); }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebRequest.java
License:Apache License
protected Map<String, List<StringValue>> generatePostParameters() { Map<String, List<StringValue>> postParameters = new HashMap<>(); IRequestParameters queryParams = getQueryParameters(); @SuppressWarnings("unchecked") Map<String, String[]> params = getContainerRequest().getParameterMap(); for (Map.Entry<String, String[]> param : params.entrySet()) { final String name = param.getKey(); final String[] values = param.getValue(); // build a mutable list of query params that have the same name as the post param List<StringValue> queryValues = queryParams.getParameterValues(name); if (queryValues == null) { queryValues = Collections.emptyList(); } else {/* w w w .jav a 2 s .c o m*/ queryValues = new ArrayList<>(queryValues); } // the list that will contain accepted post param values List<StringValue> postValues = new ArrayList<>(); for (String value : values) { StringValue val = StringValue.valueOf(value); if (queryValues.contains(val)) { // if a query param with this value exists remove it and continue queryValues.remove(val); } else { // there is no query param with this value, assume post postValues.add(val); } } if (!postValues.isEmpty()) { postParameters.put(name, postValues); } } return postParameters; }
From source file:org.brixcms.web.nodepage.BrixPageParameters.java
License:Apache License
public List<StringValue> getQueryParams(String name) { if (name == null) { throw new IllegalArgumentException("Parameter name may not be null."); }//from w ww .j a v a 2 s. c o m if (queryStringParameters != null) { List<StringValue> result = new ArrayList<StringValue>(); for (QueryStringParameter entry : queryStringParameters) { if (entry.key.equals(name)) { result.add(StringValue.valueOf(entry.value)); } } return Collections.unmodifiableList(result); } else { return Collections.emptyList(); } }
From source file:org.brixcms.web.nodepage.BrixPageParameters.java
License:Apache License
public StringValue getIndexedParam(int index) { if (indexedParameters != null) { if (index >= 0 && index < indexedParameters.size()) { String value = indexedParameters.get(index); return StringValue.valueOf(value); }//from w ww .j a v a 2 s .c om } return StringValue.valueOf((String) null); }
From source file:org.brixcms.web.nodepage.BrixPageParameters.java
License:Apache License
public StringValue getQueryParam(String name) { if (name == null) { throw new IllegalArgumentException("Parameter name may not be null."); }//from www .j av a 2 s . c om if (queryStringParameters != null) { for (QueryStringParameter entry : queryStringParameters) { if (entry.key.equals(name)) { return StringValue.valueOf(entry.value); } } } return StringValue.valueOf((String) null); }