Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * {@code IAuthenticationStrategy} that allows developers to automatically log in without entering a user name and
- * password. To enable this functionality the application you must put the following in the Application.init method:
- * <pre>
- * getSecuritySettings().setAuthenticationStrategy(new DeveloperAutologinAuthenticationStrategy());
- * </pre>
- * Once set as the application's IAuthenticationStrategy you must set the following system properties before starting
- * the application and the application must be running in DEVELOPMENT mode.
- * <pre>
- * -Duser=devuser
- * -Dpassword=devpassword
- * </pre>
- */
- public class DeveloperAutologinAuthenticationStrategy extends DefaultAuthenticationStrategy
- {
- private static final Logger log = LoggerFactory.getLogger(DeveloperAutologinAuthenticationStrategy.class);
- public DeveloperAutologinAuthenticationStrategy()
- {
- super("LoggedIn");
- }
- @Override
- public String[] load()
- {
- String[] result = super.load();
- if(result == null && Application.get().usesDevelopmentConfig())
- {
- String devUser = System.getProperty("user");
- String devPassword = System.getProperty("password");
- if(StringUtils.isNotBlank(devUser) && StringUtils.isNotBlank(devPassword))
- {
- log.info("Automatically logging in development user " + devUser);
- return new String[]{devUser, devPassword};
- }
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement