You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2017/07/14 15:39:39 UTC
svn commit: r1801972 - in
/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main:
java/modules/actions/ webapp/templates/screens/
Author: gk
Date: Fri Jul 14 15:39:38 2017
New Revision: 1801972
URL: http://svn.apache.org/viewvc?rev=1801972&view=rev
Log:
- add json call from template
- tabs to spaces in java
Modified:
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm
Modified: turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java
URL: http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java?rev=1801972&r1=1801971&r2=1801972&view=diff
==============================================================================
--- turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java (original)
+++ turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/ChangePasswordAction.java Fri Jul 14 15:39:38 2017
@@ -35,33 +35,33 @@ import org.apache.velocity.context.Conte
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 @@ public class ChangePasswordAction extend
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!!");
+ }
}
Modified: turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java
URL: http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java?rev=1801972&r1=1801971&r2=1801972&view=diff
==============================================================================
--- turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java (original)
+++ turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/LoginUserIntake.java Fri Jul 14 15:39:38 2017
@@ -165,24 +165,22 @@ public class LoginUserIntake
}
}
-
-
- 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));
- }
- }
+ 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));
+ }
+ }
}
Modified: turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java
URL: http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java?rev=1801972&r1=1801971&r2=1801972&view=diff
==============================================================================
--- turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java (original)
+++ turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/java/modules/actions/SecureAction.java Fri Jul 14 15:39:38 2017
@@ -33,53 +33,54 @@ import org.apache.velocity.context.Conte
*/
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;
-
- // 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") ) )
- {
- 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;
- }
-
- /**
- * 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
- {
-
+ /**
+ * 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") ) )
+ {
+ 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;
+ }
+
+ /**
+ * 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);
}
}
Modified: turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm
URL: http://svn.apache.org/viewvc/turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm?rev=1801972&r1=1801971&r2=1801972&view=diff
==============================================================================
--- turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm (original)
+++ turbine/maven/archetypes/trunk/turbine-webapp-4.0/src/main/resources/archetype-resources/src/main/webapp/templates/screens/TestSecure.vm Fri Jul 14 15:39:38 2017
@@ -7,4 +7,8 @@
<p>
Role: $related.getUserrole()
+
+ #if ($user)
+ $related.getJson($user,"org.apache.turbine.om.security.User", null, true,"lastLogin")
+ #end
</p>