You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by pa...@apache.org on 2019/03/20 04:16:14 UTC
[turbine-archetypes] branch master updated: Update to work with
latest turbine 5 changes
This is an automated email from the ASF dual-hosted git repository.
painter pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
The following commit(s) were added to refs/heads/master by this push:
new 997f804 Update to work with latest turbine 5 changes
997f804 is described below
commit 997f804c3a7be0f31eee4ba1117b1116a9d8e30a
Author: Jeffery Painter <pa...@apache.org>
AuthorDate: Wed Mar 20 00:15:38 2019 -0400
Update to work with latest turbine 5 changes
---
.../main/java/flux/modules/actions/FluxAction.java | 17 +-
.../main/java/flux/modules/actions/FluxLogin.java | 4 +-
.../main/java/flux/modules/actions/FluxLogout.java | 11 +-
.../java/flux/modules/actions/SecureAction.java | 11 +-
.../modules/actions/group/FluxGroupAction.java | 10 +-
.../actions/permission/FluxPermissionAction.java | 10 +-
.../flux/modules/actions/role/FluxRoleAction.java | 15 +-
.../flux/modules/actions/user/FluxUserAction.java | 17 +-
.../main/java/flux/modules/screens/FluxError.java | 2 +-
.../main/java/flux/modules/screens/FluxIndex.java | 5 +-
.../main/java/flux/modules/screens/FluxScreen.java | 16 +-
.../java/flux/modules/screens/group/Default.java | 2 +-
.../flux/modules/screens/permission/Default.java | 2 +-
.../java/flux/modules/screens/role/Default.java | 2 +-
.../java/flux/modules/screens/user/Default.java | 2 +-
.../java/modules/actions/ChangePasswordAction.java | 93 ++++----
.../src/main/java/modules/actions/LoginUser.java | 2 +-
.../main/java/modules/actions/LoginUserIntake.java | 249 ++++++++++-----------
.../src/main/java/modules/actions/LogoutUser.java | 7 +-
.../main/java/modules/actions/SecureAction.java | 146 ++++++------
.../src/main/java/modules/actions/ShowRecords.java | 2 +-
.../src/main/java/modules/screens/Index.java | 2 +-
.../main/java/modules/screens/SecureScreen.java | 104 ++++-----
.../src/main/java/wrapper/TurbineUserWrapper.java | 2 +-
24 files changed, 346 insertions(+), 387 deletions(-)
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxAction.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxAction.java
index 3ba889e..a95fbb3 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxAction.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -53,9 +53,11 @@ public class FluxAction extends VelocitySecureAction {
* flux.admin.role which you should define
*/
@Override
- protected boolean isAuthorized(PipelineData data) throws Exception {
+ protected boolean isAuthorized(PipelineData pipelineData) throws Exception {
boolean isAuthorized = false;
+ RunData data = (RunData) pipelineData;
+
/*
* Grab the Flux Admin role listed in the Flux.properties file that is included
* in the the standard TurbineResources.properties file.
@@ -63,15 +65,15 @@ public class FluxAction extends VelocitySecureAction {
String fluxAdminRole = Turbine.getConfiguration().getString("flux.admin.role");
// Get the Turbine ACL implementation
- TurbineAccessControlList acl = getRunData(data).getACL();
+ TurbineAccessControlList acl = data.getACL();
if (acl == null || !(acl.hasRole(fluxAdminRole))) {
String msg = localizationService.getString(localizationService.getDefaultBundleName(),
localizationService.getLocale(((RunData) data).getRequest()), "no_permission");
- getRunData(data).setMessage(msg);
+ data.setMessage(msg);
- getRunData(data).setScreenTemplate("Login.vm");
+ data.setScreenTemplate("Login.vm");
isAuthorized = false;
} else if (acl.hasRole(fluxAdminRole)) {
isAuthorized = true;
@@ -90,8 +92,9 @@ public class FluxAction extends VelocitySecureAction {
* @exception Exception,
* a generic exception.
*/
- public void doPerform(PipelineData data, Context context) throws Exception {
- User user = getRunData(data).getUser();
+ public void doPerform(PipelineData pipelineData, Context context) throws Exception {
+ RunData data = (RunData) pipelineData;
+ User user = data.getUser();
context.put("user", user);
}
}
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogin.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogin.java
index 198d398..2482041 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogin.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogin.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public class FluxLogin extends org.apache.turbine.modules.actions.LoginUser {
@Override
public void doPerform(PipelineData pipelineData) throws FulcrumSecurityException {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData)pipelineData;
String username = data.getParameters().getString(FluxLogin.CGI_USERNAME, "");
if (StringUtils.isEmpty(username)) {
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogout.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogout.java
index 60972d0..a254d72 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogout.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/FluxLogout.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ import org.apache.turbine.util.RunData;
* specified in the resources file
*
*/
-public class FluxLogout extends Action {
+public class FluxLogout implements Action {
/** Injected service instance */
@TurbineService
@@ -59,10 +59,9 @@ public class FluxLogout extends Action {
* @exception FulcrumSecurityException
* a problem occurred in the security service.
*/
- @Override
- public void doPerform(PipelineData pipelineData) throws FulcrumSecurityException {
-
- RunData data = getRunData(pipelineData);
+ public void doPerform(PipelineData pipelineData) throws FulcrumSecurityException
+ {
+ RunData data = (RunData) pipelineData;
// Session validator did not run, so RunData is not populated
User user = data.getUserFromSession();
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/SecureAction.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/SecureAction.java
index 8020f35..3a73b30 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/SecureAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/SecureAction.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -64,9 +64,8 @@ public class SecureAction extends VelocitySecureAction {
@Override
protected boolean isAuthorized(PipelineData pipelineData) throws Exception {
- RunData data = getRunData(pipelineData);
-
boolean isAuthorized = false;
+ RunData data = (RunData) pipelineData;
/*
* Grab the Flux Admin role listed in the Flux.properties file that is included
@@ -109,8 +108,10 @@ public class SecureAction extends VelocitySecureAction {
* @exception Exception,
* a generic exception.
*/
- public void doPerform(PipelineData data, Context context) throws Exception {
- User user = getRunData(data).getUser();
+ public void doPerform(PipelineData pipelineData, Context context) throws Exception
+ {
+ RunData data = (RunData) pipelineData;
+ User user = data.getUser();
context.put("user", user);
}
}
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/group/FluxGroupAction.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/group/FluxGroupAction.java
index deeb355..24dc6c0 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/group/FluxGroupAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/group/FluxGroupAction.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions.group;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -61,7 +61,7 @@ public class FluxGroupAction extends FluxAction {
* a generic exception.
*/
public void doInsert(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
String name = data.getParameters().getString(GROUP_ID);
if (!StringUtils.isEmpty(name)) {
@@ -101,7 +101,7 @@ public class FluxGroupAction extends FluxAction {
* a generic exception.
*/
public void doUpdate(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
String groupName = data.getParameters().getString("oldName");
if (!StringUtils.isEmpty(groupName)) {
Group group = security.getGroupByName(groupName);
@@ -135,7 +135,7 @@ public class FluxGroupAction extends FluxAction {
*/
public void doDelete(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
try {
Group group = security.getGroupByName(data.getParameters().getString(GROUP_ID));
@@ -164,7 +164,7 @@ public class FluxGroupAction extends FluxAction {
* a generic exception.
*/
public void doPerform(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
log.info("Running do perform!");
data.setMessage("Can't find the requested action!");
}
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/permission/FluxPermissionAction.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/permission/FluxPermissionAction.java
index c92c914..bb9385d 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/permission/FluxPermissionAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/permission/FluxPermissionAction.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions.permission;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ public class FluxPermissionAction extends FluxAction {
*/
public void doInsert(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
String name = data.getParameters().getString(PERM_ID);
if (!StringUtils.isEmpty(name)) {
// create the permission
@@ -93,7 +93,7 @@ public class FluxPermissionAction extends FluxAction {
* a generic exception.
*/
public void doUpdate(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
String old_name = data.getParameters().getString("oldName");
String name = data.getParameters().getString(PERM_ID);
@@ -130,7 +130,7 @@ public class FluxPermissionAction extends FluxAction {
* a generic exception.
*/
public void doDelete(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
try {
String permName = data.getParameters().getString(PERM_ID);
@@ -168,7 +168,7 @@ public class FluxPermissionAction extends FluxAction {
* a generic exception.
*/
public void doPerform(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
log.info("Running do perform!");
data.setMessage("Can't find the requested action!");
}
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/role/FluxRoleAction.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/role/FluxRoleAction.java
index 3e94e9e..0d4f657 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/role/FluxRoleAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/role/FluxRoleAction.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions.role;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ package ${package}.flux.modules.actions.role;
import java.util.Iterator;
import org.apache.commons.configuration2.Configuration;
-import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.fulcrum.security.entity.Permission;
@@ -29,6 +28,7 @@ import org.apache.fulcrum.security.torque.om.TurbineUserGroupRolePeer;
import org.apache.fulcrum.security.util.EntityExistsException;
import org.apache.fulcrum.security.util.PermissionSet;
import org.apache.fulcrum.security.util.UnknownEntityException;
+import org.apache.commons.lang3.StringUtils;
import org.apache.torque.criteria.Criteria;
import org.apache.turbine.annotation.TurbineConfiguration;
import org.apache.turbine.annotation.TurbineService;
@@ -39,6 +39,7 @@ import org.apache.velocity.context.Context;
import ${package}.flux.modules.actions.FluxAction;
+
/**
* Action to manager roles in Turbine.
*
@@ -57,7 +58,7 @@ public class FluxRoleAction extends FluxAction {
private Configuration conf;
public void doInsert(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
Role role = security.getRoleInstance();
data.getParameters().setProperties(role);
@@ -91,7 +92,7 @@ public class FluxRoleAction extends FluxAction {
* a generic exception.
*/
public void doUpdate(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
Role role = security.getRoleByName(data.getParameters().getString("oldName"));
String name = data.getParameters().getString(ROLE_ID);
if (role != null && !StringUtils.isEmpty(name)) {
@@ -117,7 +118,7 @@ public class FluxRoleAction extends FluxAction {
* a generic exception.
*/
public void doDelete(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
try {
// find the role
@@ -158,7 +159,7 @@ public class FluxRoleAction extends FluxAction {
*/
public void doPermissions(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
/*
* Grab the role we are trying to update. Always not null
*/
@@ -215,7 +216,7 @@ public class FluxRoleAction extends FluxAction {
*/
public void doPerform(PipelineData pipelineData, Context context) throws Exception {
log.info("Running do perform!");
- getRunData(pipelineData).setMessage("Can't find the requested action!");
+ ( (RunData) pipelineData).setMessage("Can't find the requested action!");
}
/**
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java
index d41db9a..074e2e2 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/actions/user/FluxUserAction.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.actions.user;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ public class FluxUserAction extends FluxAction {
* system.
*/
public void doInsert(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
/*
* Grab the username entered in the form.
@@ -110,7 +110,7 @@ public class FluxUserAction extends FluxAction {
* before allowing the user info to be update in the database.
*/
public void doUpdate(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
String username = data.getParameters().getString("username");
if (!StringUtils.isEmpty(username)) {
if (security.accountExists(username)) {
@@ -155,13 +155,18 @@ public class FluxUserAction extends FluxAction {
public void doDelete(PipelineData pipelineData, Context context) throws Exception {
try {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
String username = data.getParameters().getString("username");
if (!StringUtils.isEmpty(username)) {
if (security.accountExists(username)) {
// find the user object and remove using security mgr
User user = security.getUser(username);
+
+ // get the turbine user id
+ int id = (int) user.getId();
+
+ // remove the turbine user
security.removeUser(user);
} else {
@@ -178,7 +183,7 @@ public class FluxUserAction extends FluxAction {
* Update the roles that are to assigned to a user for a project.
*/
public void doRoles(PipelineData pipelineData, Context context) throws Exception {
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
try {
/*
@@ -255,7 +260,7 @@ public class FluxUserAction extends FluxAction {
*/
public void doPerform(PipelineData pipelineData, Context context) throws Exception {
log.info("Running do perform!");
- getRunData(pipelineData).setMessage("Can't find the requested action!");
+ ( (RunData) pipelineData).setMessage("Can't find the requested action!");
}
}
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxError.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxError.java
index dca782d..72123bf 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxError.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxError.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.screens;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxIndex.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxIndex.java
index 115252c..0836b25 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxIndex.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxIndex.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.screens;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -61,9 +61,8 @@ public class FluxIndex extends VelocitySecureScreen {
@Override
protected boolean isAuthorized(PipelineData pipelineData) throws Exception {
- RunData data = getRunData(pipelineData);
-
boolean isAuthorized = false;
+ RunData data = (RunData) pipelineData;
/*
* Grab the Flux Admin role listed in the Flux.properties file that is included
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxScreen.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxScreen.java
index 772eaeb..bf58332 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxScreen.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/FluxScreen.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.screens;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import org.apache.turbine.annotation.TurbineService;
import org.apache.turbine.modules.screens.VelocitySecureScreen;
import org.apache.turbine.pipeline.PipelineData;
import org.apache.turbine.services.security.SecurityService;
+import org.apache.turbine.util.RunData;
import org.apache.velocity.context.Context;
/**
@@ -65,9 +66,10 @@ public abstract class FluxScreen extends VelocitySecureScreen {
}
@Override
- protected boolean isAuthorized(PipelineData data) throws Exception {
+ protected boolean isAuthorized(PipelineData pipelineData) throws Exception {
boolean isAuthorized = false;
-
+ RunData data = (RunData) pipelineData;
+
/*
* Grab the Flux Admin role listed in the Flux.properties file that is included
* in the the standard TurbineResources.properties file.
@@ -75,18 +77,18 @@ public abstract class FluxScreen extends VelocitySecureScreen {
String fluxAdminRole = Turbine.getConfiguration().getString("flux.admin.role");
// Get the Turbine ACL implementation
- TurbineAccessControlList acl = getRunData(data).getACL();
+ TurbineAccessControlList acl = data.getACL();
if (acl == null) {
// commons configuration getProperty: prefix removed, the key for the value ..
// is an empty string, the result an object
- getRunData(data).setScreenTemplate((String) templateLogin.getProperty(""));
+ data.setScreenTemplate((String) templateLogin.getProperty(""));
isAuthorized = false;
} else if (acl.hasRole(fluxAdminRole)) {
isAuthorized = true;
} else {
- getRunData(data).setScreenTemplate((String) templateHomepage.getProperty(""));
- getRunData(data).setMessage("You do not have access to this part of the site.");
+ data.setScreenTemplate((String) templateHomepage.getProperty(""));
+ data.setMessage("You do not have access to this part of the site.");
isAuthorized = false;
}
return isAuthorized;
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/group/Default.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/group/Default.java
index 5360e93..beb2dcb 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/group/Default.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/group/Default.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.screens.group;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/permission/Default.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/permission/Default.java
index 4d27c70..7a2878b 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/permission/Default.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/permission/Default.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.screens.permission;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/role/Default.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/role/Default.java
index d4d8962..f22b6a5 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/role/Default.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/role/Default.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.screens.role;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/user/Default.java b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/user/Default.java
index 436ff17..eb711dc 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/user/Default.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/modules/screens/user/Default.java
@@ -1,7 +1,7 @@
package ${package}.flux.modules.screens.user;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java b/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
index ca7255b..46c4673 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
@@ -19,7 +19,6 @@ package ${package}.modules.actions;
* under the License.
*#
-
import org.apache.fulcrum.security.util.PasswordMismatchException;
import org.apache.turbine.annotation.TurbineService;
import org.apache.turbine.om.security.User;
@@ -32,64 +31,50 @@ import org.apache.velocity.context.Context;
* Change Password action.
*
*/
-public class ChangePasswordAction extends SecureAction
-
+public class ChangePasswordAction extends SecureAction
{
- /** Injected service instance */
- @TurbineService
- private SecurityService security;
+ /** Injected service instance */
+ @TurbineService
+ private SecurityService security;
+
+ /**
+ * Implement this to add information to the context.
+ *
+ * @param data Turbine information.
+ * @param context Context for web pages.
+ * @exception Exception, a generic exception.
+ */
+ @Override
+ public void doPerform(PipelineData pipelineData) throws Exception
+ {
+ RunData data = (RunData) pipelineData;
+ User user = data.getUser();
+ String oldPassword = data.getParameters().getString("oldpassword", "");
+ String newPassword = data.getParameters().getString("newpassword", "");
- /**
- * Implement this to add information to the context.
- *
- * @param data
- * Turbine information.
- * @param context
- * Context for web pages.
- * @exception Exception,
- * a generic exception.
- */
- @Override
- public void doPerform(PipelineData data)
- throws Exception
- {
+ try {
+ security.changePassword(user, oldPassword, newPassword);
+ data.setMessage("Password changed!");
+ } catch (PasswordMismatchException e) {
+ data.setMessage(e.getMessage());
+ data.setScreenTemplate("Password.vm");
+ }
- User user = getRunData(data).getUser();
-
- RunData rundata = getRunData(data);
- String oldPassword = rundata.getParameters().getString("oldpassword", "");
- String newPassword = rundata.getParameters().getString("newpassword", "");
-
- try {
- security.changePassword(user, oldPassword, newPassword);
- rundata.setMessage("Password changed!");
- }
- catch (PasswordMismatchException e)
- {
- rundata.setMessage(e.getMessage());
- rundata.setScreenTemplate("Password.vm");
- }
-
-
- }
-
- /**
- * Implement this to add information to the context.
- *
- * @param data
- * Turbine information.
- * @param context
- * Context for web pages.
- * @exception Exception,
- * a generic exception.
- */
- @Override
- public void doPerform(PipelineData data, Context context) throws Exception
- {
+ }
- context.put("success", "Password changed!!");
- }
+ /**
+ * Implement this to add information to the context.
+ *
+ * @param data Turbine information.
+ * @param context Context for web pages.
+ * @exception Exception, a generic exception.
+ */
+ @Override
+ public void doPerform(PipelineData data, Context context) throws Exception
+ {
+ context.put("success", "Password changed!!");
+ }
}
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUser.java b/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUser.java
index 52736d4..c700fc3 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUser.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUser.java
@@ -72,7 +72,7 @@ public class LoginUser
public void doPerform(PipelineData pipelineData)
throws FulcrumSecurityException
{
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
String username = data.getParameters().getString(LoginUser.CGI_USERNAME, "");
if (StringUtils.isEmpty(username))
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java b/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
index 85dda64..7106114 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
@@ -19,7 +19,6 @@ package ${package}.modules.actions;
* under the License.
*#
-
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
@@ -42,9 +41,9 @@ import org.apache.turbine.services.security.SecurityService;
import org.apache.turbine.util.RunData;
/**
- * This is where we authenticate the user logging into the system
- * against a user in the database. If the user exists in the database
- * that users last login time will be updated.
+ * This is where we authenticate the user logging into the system against a user
+ * in the database. If the user exists in the database that users last login
+ * time will be updated.
*
* @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
* @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
@@ -52,135 +51,117 @@ import org.apache.turbine.util.RunData;
* @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
* @version $Id$
*/
-public class LoginUserIntake
- extends org.apache.turbine.modules.actions.LoginUser
-{
-
- /** Logging */
- private static Log log = LogFactory.getLog(LoginUserIntake.class);
-
- /** Injected service instance */
- @TurbineService
- private SecurityService security;
-
- /** Injected configuration instance */
- @TurbineConfiguration
- private Configuration conf;
-
-
-
- /**
- * Checks for anonymous user, else calls parent method.
- *
- * @param pipelineData Turbine information.
- * @exception FulcrumSecurityException could not get instance of the
- * anonymous user
- */
- @Override
- public void doPerform(PipelineData pipelineData)
- throws FulcrumSecurityException
- {
- RunData data = getRunData(pipelineData);
-
- try
- {
- // Get intake group
- // context only available after ExecutePageValve, could not invoke (IntakeTool)context.get("intake") using pook service instead
- PoolService poolService = (PoolService)TurbineServices.getInstance().getService(PoolService.ROLE);
- IntakeTool intake = (IntakeTool) poolService.getInstance(IntakeTool.class);
-
- intake.init(data);
- Group group = intake.get("Login", IntakeTool.DEFAULT_KEY);
- String username = (String)group.get("Username").getValue();
- if (StringUtils.isEmpty(username))
- {
- return;
- }
-
- if (username.equals(security.getAnonymousUser().getName()))
- {
- data.setMessage("Anonymous user cannot login");
- reset(data);
- return;
- }
-
- if (username.equals(security.getAnonymousUser().getName()))
- {
- throw new Exception("Anonymous user cannot login");
- }
-
- String password = (String)group.get("Password").getValue();
- // Authenticate the user and get the object.
- User user = security.getAuthenticatedUser(username, password);
-
- // Store the user object.
- data.setUser(user);
-
- // Mark the user as being logged in.
- user.setHasLoggedIn(Boolean.TRUE);
-
- // Set the last_login date in the database.
- user.updateLastLogin();
-
- // This only happens if the user is valid; otherwise, we
- // will get a valueBound in the User object when we don't
- // want to because the username is not set yet. Save the
- // User object into the session.
- data.save();
-
- /*
- * If the setPage("template.vm") method has not
- * been used in the template to authenticate the
- * user (usually Login.vm), then the user will
- * be forwarded to the template that is specified
- * by the "template.home" property as listed in
- * TR.props for the webapp.
- */
-
- }
- catch (Exception e)
- {
- if (e instanceof DataBackendException || e instanceof IntakeException)
- {
- log.error(e);
- }
-
- // Set Error Message and clean out the user.
- data.setMessage(conf.getString(TurbineConstants.LOGIN_ERROR, ""));
- User anonymousUser = security.getAnonymousUser();
- data.setUser(anonymousUser);
-
- String loginTemplate = conf.getString(
- TurbineConstants.TEMPLATE_LOGIN);
-
- if (StringUtils.isNotEmpty(loginTemplate))
- {
- // We're running in a templating solution
- data.setScreenTemplate(loginTemplate);
- }
- else
- {
- data.setScreen(conf.getString(TurbineConstants.SCREEN_LOGIN));
- }
- }
- }
-
- private void reset(RunData data) throws UnknownEntityException {
- User anonymousUser = security.getAnonymousUser();
- data.setUser(anonymousUser);
-
- if (StringUtils.isNotEmpty(conf.getString(TurbineConstants.TEMPLATE_LOGIN,"")))
- {
- // We're running in a templating solution
- data.setScreenTemplate(
- conf.getString(TurbineConstants.TEMPLATE_LOGIN));
- }
- else
- {
- data.setScreen(
- conf.getString(TurbineConstants.SCREEN_LOGIN));
- }
- }
+public class LoginUserIntake extends org.apache.turbine.modules.actions.LoginUser {
+
+ /** Logging */
+ private static Log log = LogFactory.getLog(LoginUserIntake.class);
+
+ /** Injected service instance */
+ @TurbineService
+ private SecurityService security;
+
+ /** Injected configuration instance */
+ @TurbineConfiguration
+ private Configuration conf;
+
+ /**
+ * Checks for anonymous user, else calls parent method.
+ *
+ * @param pipelineData Turbine information.
+ * @exception FulcrumSecurityException could not get instance of the anonymous
+ * user
+ */
+ @Override
+ public void doPerform(PipelineData pipelineData) throws FulcrumSecurityException
+ {
+ RunData data = (RunData) pipelineData;
+
+ try
+ {
+ // Get intake group
+ // context only available after ExecutePageValve, could not invoke
+ // (IntakeTool)context.get("intake") using pook service instead
+ PoolService poolService = (PoolService) TurbineServices.getInstance().getService(PoolService.ROLE);
+ IntakeTool intake = (IntakeTool) poolService.getInstance(IntakeTool.class);
+
+ intake.init(data);
+ Group group = intake.get("Login", IntakeTool.DEFAULT_KEY);
+ String username = (String) group.get("Username").getValue();
+ if (StringUtils.isEmpty(username))
+ {
+ return;
+ }
+
+ if (username.equals(security.getAnonymousUser().getName()))
+ {
+ data.setMessage("Anonymous user cannot login");
+ reset(data);
+ return;
+ }
+
+ if (username.equals(security.getAnonymousUser().getName()))
+ {
+ throw new Exception("Anonymous user cannot login");
+ }
+
+ String password = (String) group.get("Password").getValue();
+
+ // Authenticate the user and get the object.
+ User user = security.getAuthenticatedUser(username, password);
+
+ // Store the user object.
+ data.setUser(user);
+
+ // Mark the user as being logged in.
+ user.setHasLoggedIn(Boolean.TRUE);
+
+ // Set the last_login date in the database.
+ user.updateLastLogin();
+
+ // This only happens if the user is valid; otherwise, we
+ // will get a valueBound in the User object when we don't
+ // want to because the username is not set yet. Save the
+ // User object into the session.
+ data.save();
+
+ /*
+ * If the setPage("template.vm") method has not been used in the template to
+ * authenticate the user (usually Login.vm), then the user will be forwarded to
+ * the template that is specified by the "template.home" property as listed in
+ * TR.props for the webapp.
+ */
+
+ } catch (Exception e) {
+ if (e instanceof DataBackendException || e instanceof IntakeException) {
+ log.error(e);
+ }
+
+ // Set Error Message and clean out the user.
+ data.setMessage(conf.getString(TurbineConstants.LOGIN_ERROR, ""));
+ User anonymousUser = security.getAnonymousUser();
+ data.setUser(anonymousUser);
+
+ String loginTemplate = conf.getString(TurbineConstants.TEMPLATE_LOGIN);
+
+ if (StringUtils.isNotEmpty(loginTemplate)) {
+ // We're running in a templating solution
+ data.setScreenTemplate(loginTemplate);
+ } else {
+ data.setScreen(conf.getString(TurbineConstants.SCREEN_LOGIN));
+ }
+ }
+ }
+
+ private void reset(RunData data) throws UnknownEntityException {
+ User anonymousUser = security.getAnonymousUser();
+ data.setUser(anonymousUser);
+
+ if (StringUtils.isNotEmpty(conf.getString(TurbineConstants.TEMPLATE_LOGIN, ""))) {
+ // We're running in a templating solution
+ data.setScreenTemplate(conf.getString(TurbineConstants.TEMPLATE_LOGIN));
+ } else {
+ data.setScreen(conf.getString(TurbineConstants.SCREEN_LOGIN));
+ }
+ }
}
-
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/actions/LogoutUser.java b/src/main/resources/archetype-resources/src/main/java/modules/actions/LogoutUser.java
index 50a9d98..5f696c9 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/actions/LogoutUser.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/actions/LogoutUser.java
@@ -39,8 +39,7 @@ import org.apache.turbine.util.RunData;
* @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
* @version $Id: LogoutUser.java 1706239 2015-10-01 13:18:35Z tv $
*/
-public class LogoutUser
- extends Action
+public class LogoutUser implements Action
{
/** Injected service instance */
@TurbineService
@@ -72,7 +71,7 @@ public class LogoutUser
public void doPerform(PipelineData pipelineData)
throws FulcrumSecurityException
{
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
// Session validator did not run, so RunData is not populated
User user = data.getUserFromSession();
@@ -88,7 +87,7 @@ public class LogoutUser
security.saveUser(user);
}
- data.setMessage(conf.getString(TurbineConstants.LOGOUT_MESSAGE));
+ ((RunData) data).setMessage(conf.getString(TurbineConstants.LOGOUT_MESSAGE));
// This will cause the acl to be removed from the session in
// the Turbine servlet code.
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java b/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
index c25fae5..85757e0 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
@@ -1,23 +1,20 @@
package ${package}.modules.actions;
-#*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*#
+/*
+ * Copyright 2001-2019 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License")
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
import org.apache.fulcrum.localization.LocalizationService;
import org.apache.fulcrum.security.model.turbine.TurbineAccessControlList;
@@ -34,65 +31,60 @@ import org.apache.velocity.context.Context;
* Always performs a Security Check that you've defined before executing the
* doPerform().
*/
-public class SecureAction extends VelocitySecureAction
-{
-
- @TurbineService
- private LocalizationService localizationService;
- /**
- * This currently only checks to make sure that user is allowed to view the
- * storage area. If you create an action that requires more security then
- * override this method.
- *
- * @param data
- * Turbine information.
- * @return True if the user is authorized to access the screen.
- * @exception Exception,
- * a generic exception.
- */
- @Override
- protected boolean isAuthorized(PipelineData data) throws Exception
- {
- boolean isAuthorized = false;
-
- // Who is our current user?
- User user = getRunData(data).getUser();
-
- // Get the Turbine ACL implementation
- TurbineAccessControlList acl = getRunData(data).getACL();
-
- if (acl == null || ! ( acl.hasRole("turbineuser") || acl.hasRole("turbineadmin") ) )
- {
- String msg = localizationService.getString(localizationService.getDefaultBundleName(),
- localizationService.getLocale( ((RunData) data).getRequest()), "no_permission");
-
- getRunData(data).setMessage(msg);
-
- log.debug( "call not permitted for template: " + getRunData(data).getScreenTemplate() + " and action " + getRunData(data).getAction() );
- getRunData(data).setScreenTemplate( "Login.vm" );
- isAuthorized = false;
- }
- else if ( acl.hasRole("turbineuser") || acl.hasRole("turbineadmin") )
- {
- isAuthorized = true;
- }
-
- return isAuthorized;
- }
+public class SecureAction extends VelocitySecureAction {
+
+ @TurbineService
+ private LocalizationService localizationService;
+
+ /**
+ * This currently only checks to make sure that user is allowed to view the
+ * storage area. If you create an action that requires more security then
+ * override this method.
+ *
+ * @param data Turbine information.
+ * @return True if the user is authorized to access the screen.
+ * @exception Exception, a generic exception.
+ */
+ @Override
+ protected boolean isAuthorized(PipelineData pipelineData) throws Exception
+ {
+ boolean isAuthorized = false;
+ RunData data = (RunData) pipelineData;
+
+ // Who is our current user?
+ User user = data.getUser();
+
+ // Get the Turbine ACL implementation
+ TurbineAccessControlList acl = data.getACL();
+
+ if (acl == null || !(acl.hasRole("turbineuser") || acl.hasRole("turbineadmin"))) {
+ String msg = localizationService.getString(localizationService.getDefaultBundleName(),
+ localizationService.getLocale(((RunData) data).getRequest()), "no_permission");
+
+ data.setMessage(msg);
+
+ log.debug(
+ "call not permitted for template: " + data.getScreenTemplate() + " and action " + data.getAction());
+ data.setScreenTemplate("Login.vm");
+ isAuthorized = false;
+ } else if (acl.hasRole("turbineuser") || acl.hasRole("turbineadmin")) {
+ isAuthorized = true;
+ }
+
+ return isAuthorized;
+ }
- /**
- * Implement this to add information to the context.
- *
- * @param data
- * Turbine information.
- * @param context
- * Context for web pages.
- * @exception Exception,
- * a generic exception.
- */
- public void doPerform(PipelineData data, Context context) throws Exception
- {
- User user = getRunData(data).getUser();
- context.put("user",user);
+ /**
+ * Implement this to add information to the context.
+ *
+ * @param data Turbine information.
+ * @param context Context for web pages.
+ * @exception Exception, a generic exception.
+ */
+ public void doPerform(PipelineData pipelineData, Context context) throws Exception
+ {
+ RunData data = (RunData) pipelineData;
+ User user = data.getUser();
+ context.put("user", user);
}
}
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/actions/ShowRecords.java b/src/main/resources/archetype-resources/src/main/java/modules/actions/ShowRecords.java
index 0ec8a8f..bb0cc47 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/actions/ShowRecords.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/actions/ShowRecords.java
@@ -39,7 +39,7 @@ public class ShowRecords extends SecureAction
super.doPerform( pipelineData, context );
List<Author> authors = AuthorPeer.doSelect( new Criteria() );//all
context.put( "authors", authors );
- RunData data = getRunData(pipelineData);
+ RunData data = (RunData) pipelineData;
data.setScreenTemplate(Character.toLowerCase(getClass().getSimpleName().charAt(0)) +
getClass().getSimpleName().substring(1) + ".vm"
);
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/screens/Index.java b/src/main/resources/archetype-resources/src/main/java/modules/screens/Index.java
index de2a756..b7af8c5 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/screens/Index.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/screens/Index.java
@@ -58,7 +58,7 @@ public class Index extends VelocitySecureScreen
* return always <code>true</code>true, to show this screen as default
*/
@Override
- protected boolean isAuthorized(PipelineData data) throws Exception
+ protected boolean isAuthorized(PipelineData pipelineData) throws Exception
{
// use data.getACL()
return true;
diff --git a/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java b/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java
index f4ca0f2..0a77890 100644
--- a/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java
+++ b/src/main/resources/archetype-resources/src/main/java/modules/screens/SecureScreen.java
@@ -1,4 +1,5 @@
package ${package}.modules.screens;
+
#*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,7 +19,6 @@ package ${package}.modules.screens;
* under the License.
*#
-
import org.apache.fulcrum.security.model.turbine.TurbineAccessControlList;
import org.apache.turbine.Turbine;
import org.apache.turbine.TurbineConstants;
@@ -28,66 +28,58 @@ import org.apache.turbine.modules.screens.VelocitySecureScreen;
import org.apache.turbine.om.security.User;
import org.apache.turbine.pipeline.PipelineData;
import org.apache.turbine.services.security.SecurityService;
+import org.apache.turbine.util.RunData;
import org.apache.velocity.context.Context;
import org.apache.commons.configuration2.Configuration;
/**
* This class provides a sample implementation for creating a secured screen
*/
-public class SecureScreen extends VelocitySecureScreen
-{
- @TurbineService
- protected SecurityService securityService;
-
- @TurbineConfiguration( TurbineConstants.TEMPLATE_LOGIN )
- private Configuration templateLogin;
-
- @TurbineConfiguration( TurbineConstants.TEMPLATE_HOMEPAGE )
- private Configuration templateHomepage;
-
- @Override
- protected boolean isAuthorized(PipelineData data) throws Exception
- {
- boolean isAuthorized = false;
-
- // Who is our current user?
- User user = getRunData(data).getUser();
-
- // Get the Turbine ACL implementation
- TurbineAccessControlList acl = getRunData(data).getACL();
-
- if (acl == null)
- {
- // commons configuration getProperty: prefix removed, the key for the value .. is an empty string, the result an object
- getRunData(data).setScreenTemplate( (String) templateLogin.getProperty("") );
- isAuthorized = false;
- }
- else if (acl.hasRole("turbineuser") || acl.hasRole("turbineadmin"))
- {
- isAuthorized = true;
- }
- else
- {
- getRunData(data).setScreenTemplate( (String) templateHomepage.getProperty("") );
- getRunData(data).setMessage("You do not have access to this part of the site.");
- isAuthorized = false;
- }
- return isAuthorized;
- }
+public class SecureScreen extends VelocitySecureScreen {
+ @TurbineService
+ protected SecurityService securityService;
+
+ @TurbineConfiguration(TurbineConstants.TEMPLATE_LOGIN)
+ private Configuration templateLogin;
+
+ @TurbineConfiguration(TurbineConstants.TEMPLATE_HOMEPAGE)
+ private Configuration templateHomepage;
+
+ @Override
+ protected boolean isAuthorized(PipelineData pipelineData) throws Exception {
+ boolean isAuthorized = false;
+ RunData data = (RunData) pipelineData;
+
+ // Who is our current user?
+ User user = data.getUser();
+
+ // Get the Turbine ACL implementation
+ TurbineAccessControlList acl = data.getACL();
+
+ if (acl == null) {
+ // commons configuration getProperty: prefix removed, the key for the value ..
+ // is an empty string, the result an object
+ data.setScreenTemplate((String) templateLogin.getProperty(""));
+ isAuthorized = false;
+ } else if (acl.hasRole("turbineuser") || acl.hasRole("turbineadmin")) {
+ isAuthorized = true;
+ } else {
+ data.setScreenTemplate((String) templateHomepage.getProperty(""));
+ data.setMessage("You do not have access to this part of the site.");
+ isAuthorized = false;
+ }
+ return isAuthorized;
+ }
+
+ /**
+ * Implement this to add information to the context.
+ *
+ * @param data Turbine information.
+ * @param context Context for web pages.
+ * @exception Exception, a generic exception.
+ */
+ @Override
+ protected void doBuildTemplate(PipelineData data, Context context) throws Exception {
- /**
- * Implement this to add information to the context.
- *
- * @param data
- * Turbine information.
- * @param context
- * Context for web pages.
- * @exception Exception,
- * a generic exception.
- */
- @Override
- protected void doBuildTemplate(PipelineData data, Context context) throws Exception
- {
-
- }
+ }
}
diff --git a/src/main/resources/archetype-resources/src/main/java/wrapper/TurbineUserWrapper.java b/src/main/resources/archetype-resources/src/main/java/wrapper/TurbineUserWrapper.java
index 44088e4..f430de4 100644
--- a/src/main/resources/archetype-resources/src/main/java/wrapper/TurbineUserWrapper.java
+++ b/src/main/resources/archetype-resources/src/main/java/wrapper/TurbineUserWrapper.java
@@ -1,7 +1,7 @@
package ${package}.wrapper;
/*
- * Copyright 2001-2017 The Apache Software Foundation.
+ * Copyright 2001-2019 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.