aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2019-11-12 14:53:46 +0200
committerGitHub <noreply@github.com>2019-11-12 14:53:46 +0200
commitea4105de7443d9388e80b6bbe4ad8fe74d3e9c81 (patch)
tree72bdcdb2aee995b118ba5a22c7e3b39de744c8db
parentf12a6e7c4cd003ef69aea188985415cf3bfab120 (diff)
downloadvaadin-framework-ea4105de7443d9388e80b6bbe4ad8fe74d3e9c81.tar.gz
vaadin-framework-ea4105de7443d9388e80b6bbe4ad8fe74d3e9c81.zip
Use APPLICATION_SCOPE for the session lock (#11792) (#11803)
The Vaadin session itself is also stored in APPLICATION_SCOPE. The default scope is PORTLET_SCOPE, so lock would otherwise not be in sync with the session. To be able to do this, relevant methods in VaadinService are made protected so that VaadinPortletService can override them. Fixes #11611
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinPortletService.java38
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinService.java4
-rw-r--r--server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java6
3 files changed, 44 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/server/VaadinPortletService.java b/server/src/main/java/com/vaadin/server/VaadinPortletService.java
index 1b804ad18c..0b2d28acc6 100644
--- a/server/src/main/java/com/vaadin/server/VaadinPortletService.java
+++ b/server/src/main/java/com/vaadin/server/VaadinPortletService.java
@@ -22,6 +22,8 @@ import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -366,4 +368,40 @@ public class VaadinPortletService extends VaadinService {
getWrappedPortletSession(wrappedSession).removeAttribute(
getSessionAttributeName(), PortletSession.APPLICATION_SCOPE);
}
+
+ @Override
+ protected void setSessionLock(WrappedSession wrappedSession, Lock lock) {
+ if (wrappedSession == null) {
+ throw new IllegalArgumentException(
+ "Can't set a lock for a null session");
+ }
+ Object currentSessionLock = getWrappedPortletSession(wrappedSession)
+ .getAttribute(getLockAttributeName(),
+ PortletSession.APPLICATION_SCOPE);
+ assert (currentSessionLock == null
+ || currentSessionLock == lock) : "Changing the lock for a session is not allowed";
+
+ getWrappedPortletSession(wrappedSession).setAttribute(
+ getLockAttributeName(), lock,
+ PortletSession.APPLICATION_SCOPE);
+ }
+
+ @Override
+ protected Lock getSessionLock(WrappedSession wrappedSession) {
+ Object lock = getWrappedPortletSession(wrappedSession)
+ .getAttribute(getLockAttributeName(),
+ PortletSession.APPLICATION_SCOPE);
+
+ if (lock instanceof ReentrantLock) {
+ return (ReentrantLock) lock;
+ }
+
+ if (lock == null) {
+ return null;
+ }
+
+ throw new RuntimeException(
+ "Something else than a ReentrantLock was stored in the "
+ + getLockAttributeName() + " in the session");
+ }
}
diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java
index 1e67db708b..9503db113f 100644
--- a/server/src/main/java/com/vaadin/server/VaadinService.java
+++ b/server/src/main/java/com/vaadin/server/VaadinService.java
@@ -622,7 +622,7 @@ public abstract class VaadinService implements Serializable {
* @param lock
* The lock object
*/
- private void setSessionLock(WrappedSession wrappedSession, Lock lock) {
+ protected void setSessionLock(WrappedSession wrappedSession, Lock lock) {
if (wrappedSession == null) {
throw new IllegalArgumentException(
"Can't set a lock for a null session");
@@ -640,7 +640,7 @@ public abstract class VaadinService implements Serializable {
*
* @return The attribute name for the lock
*/
- private String getLockAttributeName() {
+ protected String getLockAttributeName() {
return getServiceName() + ".lock";
}
diff --git a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java
index 2d7da64d20..2280e7d4f5 100644
--- a/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java
+++ b/server/src/test/java/com/vaadin/server/VaadinPortletServiceTest.java
@@ -9,6 +9,8 @@ import static org.mockito.Mockito.when;
import java.util.concurrent.locks.ReentrantLock;
+import javax.portlet.PortletSession;
+
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
@@ -185,9 +187,9 @@ public class VaadinPortletServiceTest {
ReentrantLock mockLock = Mockito.mock(ReentrantLock.class);
when(mockLock.isHeldByCurrentThread()).thenReturn(true);
- WrappedSession emptyWrappedSession = Mockito
+ WrappedPortletSession emptyWrappedSession = Mockito
.mock(WrappedPortletSession.class);
- when(emptyWrappedSession.getAttribute("null.lock"))
+ when(emptyWrappedSession.getAttribute("null.lock",PortletSession.APPLICATION_SCOPE))
.thenReturn(mockLock);
VaadinRequest requestWithUIIDSet = Mockito
.mock(VaadinRequest.class);
kport/47910/stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes/l10n/es_CO.json
blob: 3ac01555d96a80940b54969136340082614cccaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{ "translations": {
    "These are your backup codes. Please save and/or print them as you will not be able to read the codes again later" : "Estos son tus códigos de respaldo. Por favor resguárdalos y/o imprímelos ya que no podrás leerlos otra vez después.",
    "Save backup codes" : "Guardar códigos de respaldo",
    "Print backup codes" : "Imprimir códigos de respaldo",
    "Regenerate backup codes" : "Regenerar códigos de respaldo",
    "If you regenerate backup codes, you automatically invalidate old codes." : "Si regeneras los códigos de respaldo, automáticamente invalidarás los anteriores. ",
    "Generate backup codes" : "Generar los códigos de respaldo",
    "An error occurred while generating your backup codes" : "Se presentó un error al generar tus códigos de respaldo. ",
    "Nextcloud backup codes" : "Códigos de respaldo de Nextcloud",
    "You created two-factor backup codes for your account" : "Creaste códigos de respaldo de dos factores para tu cuenta",
    "Second-factor backup codes" : "Códigos de respaldo del segundo factor",
    "Backup code" : "Código de respaldo",
    "Use backup code" : "Usa el código de respaldo",
    "Two factor backup codes" : "Códigos de respaldo de dos factores",
    "Backup codes have been generated. {{used}} of {{total}} codes have been used." : "Los códigos de respaldo han sido generados. Se han usado {{used}} de {{total}} códigos."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}