- add json call from template
- tabs to spaces in java
git-svn-id: https://svn.apache.org/repos/asf/turbine/maven/archetypes@1801972 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
index c8f4d1b..ca7255b 100644
--- a/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
+++ b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
@@ -35,33 +35,33 @@
public class ChangePasswordAction extends SecureAction
{
-
+
/** 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.
- */
+
+
+ /**
+ * 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
{
- User user = getRunData(data).getUser();
-
+ 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!");
@@ -71,25 +71,25 @@
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
- {
+ }
+
+ /**
+ * 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!!");
- }
+ context.put("success", "Password changed!!");
+ }
}
diff --git a/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
index 4c739a3..4dca1f0 100644
--- a/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
+++ b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
@@ -165,24 +165,22 @@
}
}
+ private void reset(RunData data) throws UnknownEntityException {
+ User anonymousUser = security.getAnonymousUser();
+ data.setUser(anonymousUser);
-
- 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));
- }
- }
+ 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/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
index f612181..f0b5e8a 100644
--- a/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
+++ b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
@@ -33,53 +33,54 @@
*/
public class SecureAction extends VelocitySecureAction
{
- /**
- * 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;
+ /**
+ * 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();
+ // Who is our current user?
+ User user = getRunData(data).getUser();
- // Get the Turbine ACL implementation
- TurbineAccessControlList acl = getRunData(data).getACL();
+ // Get the Turbine ACL implementation
+ TurbineAccessControlList acl = getRunData(data).getACL();
- if (acl == null || ! ( acl.hasRole("turbineuser") || acl.hasRole("turbineadmin") ) )
- {
- getRunData(data).setMessage("You do not have permission to access this action");
- isAuthorized = false;
- }
- else if ( acl.hasRole("turbineuser") || acl.hasRole("turbineadmin") )
- {
- isAuthorized = true;
- }
+ if (acl == null || ! ( acl.hasRole("turbineuser") || acl.hasRole("turbineadmin") ) )
+ {
+ getRunData(data).setMessage("You do not have permission to access this action");
+ isAuthorized = false;
+ }
+ else if ( acl.hasRole("turbineuser") || acl.hasRole("turbineadmin") )
+ {
+ isAuthorized = true;
+ }
- return isAuthorized;
- }
+ 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
- {
-
+ /**
+ * 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);
}
}
diff --git a/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm
index a8af923..d05bc79 100644
--- a/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm
+++ b/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm
@@ -7,4 +7,8 @@
<p>
Role: $related.getUserrole()
+
+ #if ($user)
+ $related.getJson($user,"org.apache.turbine.om.security.User", null, true,"lastLogin")
+ #end
</p>