use of org.apache.wicket.util.string.StringValue in project openmeetings by apache.
the class GroupLogoResourceReference method getResource.
@Override
public IResource getResource() {
return new FileSystemResource() {
private static final long serialVersionUID = 1L;
@Override
protected String getMimeType() throws IOException {
return PNG_MIME_TYPE;
}
@Override
protected ResourceResponse newResourceResponse(Attributes attrs) {
Long id = null;
boolean allowed = false;
WebSession ws = WebSession.get();
if (ws.isSignedIn()) {
PageParameters params = attrs.getParameters();
StringValue _id = params.get("id");
try {
id = _id.toOptionalLong();
} catch (Exception e) {
// no-op expected
}
allowed = id == null || hasAdminLevel(getRights()) || null != groupUserDao.getByGroupAndUser(id, getUserId());
if (!allowed && ws.getInvitation() != null) {
Room r = ws.getInvitation().getRoom() == null ? null : roomDao.get(ws.getInvitation().getRoom().getId());
if (r != null && r.getGroups() != null) {
for (RoomGroup rg : r.getGroups()) {
if (id.equals(rg.getGroup().getId())) {
allowed = true;
break;
}
}
}
}
}
if (allowed) {
return createResourceResponse(attrs, getGroupLogo(id, true).toPath());
} else {
log.debug("Not authorized");
ResourceResponse rr = new ResourceResponse();
rr.setError(HttpServletResponse.SC_FORBIDDEN);
return rr;
}
}
};
}
use of org.apache.wicket.util.string.StringValue in project openmeetings by apache.
the class HashPage method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
StringValue secure = p.get(HASH);
StringValue invitation = p.get(INVITATION_HASH);
WebSession ws = WebSession.get();
ws.checkHashes(secure, invitation);
String errorMsg = getString("invalid.hash");
recContainer.setVisible(false);
add(new EmptyPanel(PANEL_MAIN).setVisible(false));
if (!invitation.isEmpty()) {
Invitation i = ws.getInvitation();
if (i == null) {
errorMsg = getString("error.hash.invalid");
} else if (!i.isAllowEntry()) {
FastDateFormat sdf = FormatHelper.getDateTimeFormat(i.getInvitee());
errorMsg = Valid.OneTime == i.getValid() ? getString("error.hash.used") : String.format("%s %s - %s, %s", getString("error.hash.period"), sdf.format(i.getValidFrom()), sdf.format(i.getValidTo()), i.getInvitee().getTimeZoneId());
} else {
Recording rec = i.getRecording();
if (rec != null) {
vi.setVisible(!i.isPasswordProtected());
vp.setVisible(!i.isPasswordProtected());
if (!i.isPasswordProtected()) {
vi.update(null, rec);
vp.update(null, rec);
}
recContainer.setVisible(true);
error = false;
}
Room r = i.getRoom();
if (r != null && !r.isDeleted()) {
createRoom(r.getId());
if (i.isPasswordProtected() && rp != null) {
mp.getChat().setVisible(false);
rp.setOutputMarkupPlaceholderTag(true).setVisible(false);
}
}
}
} else if (!secure.isEmpty()) {
Long recId = getRecordingId(), roomId = ws.getRoomId();
if (recId == null && roomId == null) {
errorMsg = getString("1599");
} else if (recId != null) {
recContainer.setVisible(true);
Recording rec = recDao.get(recId);
vi.update(null, rec);
vp.update(null, rec);
error = false;
} else {
createRoom(roomId);
}
}
StringValue swf = p.get(SWF);
StringValue app = swf.isEmpty() ? p.get(APP) : swf;
if (!app.isEmpty()) {
if (APP_TYPE_NETWORK.equals(app.toString())) {
replace(new NetTestPanel(PANEL_MAIN).add(AttributeModifier.append("class", "app")));
error = false;
}
if (APP_TYPE_SETTINGS.equals(app.toString())) {
replace(new VideoSettings(PANEL_MAIN).replace(new OmWebSocketPanel("ws-panel") {
private static final long serialVersionUID = 1L;
private WsClient c = null;
@Override
protected void onConnect(ConnectedMessage message) {
c = new WsClient(message.getSessionId(), message.getKey().hashCode());
}
@Override
protected IWsClient getWsClient() {
return c;
}
}).add(new OmAjaxClientInfoBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onClientInfo(AjaxRequestTarget target, WebClientInfo info) {
super.onClientInfo(target, info);
target.appendJavaScript(String.format("VideoSettings.init(%s);VideoSettings.open();", VideoSettings.getInitJson("noclient")));
}
}));
error = false;
}
}
add(recContainer.add(vi.setShowShare(false).setOutputMarkupPlaceholderTag(true), vp.setOutputMarkupPlaceholderTag(true)), new InvitationPasswordDialog("i-pass", this));
remove(urlParametersReceivingBehavior);
add(new MessageDialog("access-denied", getString("invalid.hash"), errorMsg, DialogButtons.OK, DialogIcon.ERROR) {
private static final long serialVersionUID = 1L;
@Override
public void onConfigure(JQueryBehavior behavior) {
super.onConfigure(behavior);
behavior.setOption("autoOpen", error);
behavior.setOption("resizable", false);
}
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
// no-op
}
});
}
use of org.apache.wicket.util.string.StringValue in project openmeetings by apache.
the class StreamClient method setScope.
public void setScope(String scope) {
this.scope = scope;
StringValue scn = StringValue.valueOf(scope);
long rId = scn.toLong(Long.MIN_VALUE);
if (rId > 0) {
this.roomId = rId;
}
}
use of org.apache.wicket.util.string.StringValue in project sandbox by irof.
the class ImageResourceReference method getResource.
@Override
public IResource getResource() {
return new DynamicImageResource() {
@Override
protected byte[] getImageData(Attributes attributes) {
try {
PageParameters parameters = attributes.getParameters();
StringValue key = parameters.get("key");
URL resource = this.getClass().getClassLoader().getResource("img/" + key.toString());
Path path = Paths.get(resource.toURI());
return Files.readAllBytes(path);
} catch (IOException | URISyntaxException e) {
throw new RuntimeException(e);
}
}
};
}
use of org.apache.wicket.util.string.StringValue in project midpoint by Evolveum.
the class PageRegistrationConfirmation method init.
private void init(final PageParameters pageParameters) {
PageParameters params = pageParameters;
if (params == null) {
params = getPageParameters();
}
OperationResult result = new OperationResult(OPERATION_FINISH_REGISTRATION);
if (params == null) {
LOGGER.error("Confirmation link is not valid. No credentials provided in it");
String msg = createStringResource("PageSelfRegistration.invalid.registration.link").getString();
getSession().error(createStringResource(msg));
result.recordFatalError(msg);
initLayout(result);
return;
}
StringValue userNameValue = params.get(SchemaConstants.USER_ID);
Validate.notEmpty(userNameValue.toString());
StringValue tokenValue = params.get(SchemaConstants.TOKEN);
Validate.notEmpty(tokenValue.toString());
try {
UserType user = checkUserCredentials(userNameValue.toString(), tokenValue.toString(), result);
PrismObject<UserType> administrator = getAdministratorPrivileged(result);
assignDefaultRoles(user.getOid(), administrator, result);
result.computeStatus();
if (result.getStatus() == OperationResultStatus.FATAL_ERROR) {
LOGGER.error("Failed to assign default roles, {}", result.getMessage());
} else {
NonceType nonceClone = user.getCredentials().getNonce().clone();
removeNonceAndSetLifecycleState(user.getOid(), nonceClone, administrator, result);
assignAdditionalRoleIfPresent(user.getOid(), nonceClone, administrator, result);
result.computeStatus();
}
initLayout(result);
} catch (CommonException | AuthenticationException e) {
result.computeStatus();
initLayout(result);
}
}
Aggregations