diff --git a/.gitignore b/.gitignore index 7a60d67c..2a134e32 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ github-buttons test-env.sh repo .idea +/.project diff --git a/samples/java/hibernate/Procfile b/samples/java/hibernate/Procfile new file mode 100644 index 00000000..6d7d3779 --- /dev/null +++ b/samples/java/hibernate/Procfile @@ -0,0 +1 @@ +web: target/start -Dhttp.port=${PORT} -Dplay.version=2.3.6 -DapplyEvolutions.default=true -DapplyDownEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=$DATABASE_URL ${JAVA_OPTS} diff --git a/samples/java/hibernate/README.md b/samples/java/hibernate/README.md new file mode 100644 index 00000000..6e6f0b4c --- /dev/null +++ b/samples/java/hibernate/README.md @@ -0,0 +1,28 @@ +# Play Authenticate sample Java application for JPA/Hibernate + +Authentication providers that require further configuration parameters +are commented out in `conf/play.plugins`. Please review the configuration +in `conf/play-authenticate/mine.conf` and reenable them if you want to +use them. + +Example of play authentication using Hibernate and MySql + +Play version: 2.4.2 +play authenticate: 0.7.0-SNAPSHOT +MySQL + +This implementation does not use a managed entity manager, the developer is responsable +for closing db connections unless using @Transactional in controllers. There are some compatibility issues using this +implementation with @Transactional, deadbolt and the hibernate dao objects. So its best advised to avoid using @Transactional. + +So every time you use + +EntityManager em = JPA.em(JPAConstants.DB); + +You need to call + +em.close(); in the same function before all return statements/exceptions or you could have a connection leak. + +Hibernate has been setup to use MySql, you'll need to adjust the application.conf to match your database. Hibernate will create all +the tables automatically for you when you first run the app, but you need to create the schema/database using phphMyAdmin etc. +There is a MySql workbench project file that has the cascading setup if needed (schema.mwb). \ No newline at end of file diff --git a/samples/java/hibernate/app/Global.java b/samples/java/hibernate/app/Global.java new file mode 100644 index 00000000..3cb2d4e9 --- /dev/null +++ b/samples/java/hibernate/app/Global.java @@ -0,0 +1,94 @@ +import java.util.Arrays; + +import javax.persistence.EntityManager; + +import models.SecurityRole; + +import com.feth.play.module.pa.PlayAuthenticate; +import com.feth.play.module.pa.PlayAuthenticate.Resolver; +import com.feth.play.module.pa.exceptions.AccessDeniedException; +import com.feth.play.module.pa.exceptions.AuthException; + +import constants.JpaConstants; +import controllers.routes; +import dao.SecurityRoleHome; +import play.Application; +import play.GlobalSettings; +import play.db.jpa.JPA; +import play.mvc.Call; + +public class Global extends GlobalSettings { + + @Override + public void onStart(Application app) { + PlayAuthenticate.setResolver(new Resolver() { + + @Override + public Call login() { + // Your login page + return routes.Application.login(); + } + + @Override + public Call afterAuth() { + // The user will be redirected to this page after authentication + // if no original URL was saved + return routes.Application.index(); + } + + @Override + public Call afterLogout() { + return routes.Application.index(); + } + + @Override + public Call auth(String provider) { + // You can provide your own authentication implementation, + // however the default should be sufficient for most cases + return com.feth.play.module.pa.controllers.routes.AuthenticateDI.authenticate(provider); + } + + @Override + public Call askMerge() { + return routes.Account.askMerge(); + } + + @Override + public Call askLink() { + return routes.Account.askLink(); + } + + @Override + public Call onException(AuthException e) { + if (e instanceof AccessDeniedException) { + return routes.Signup + .oAuthDenied(((AccessDeniedException) e) + .getProviderKey()); + } + + // more custom problem handling here... + return super.onException(e); + } + }); + + initialData(); + } + + private void initialData() { + + EntityManager em = JPA.em(JpaConstants.DB); + + SecurityRoleHome dao = new SecurityRoleHome(); + + if (!dao.hasInitialData(em)) { + for (String roleName : Arrays + .asList(controllers.Application.USER_ROLE)) { + SecurityRole role = new SecurityRole(); + role.setRoleName(roleName); + dao.persist(role, em); + } + } + + em.close(); + } +} \ No newline at end of file diff --git a/samples/java/hibernate/app/constants/JpaConstants.java b/samples/java/hibernate/app/constants/JpaConstants.java new file mode 100644 index 00000000..ad0f373d --- /dev/null +++ b/samples/java/hibernate/app/constants/JpaConstants.java @@ -0,0 +1,8 @@ +package constants; + +public final class JpaConstants { + public static final String DB = "default"; + + private JpaConstants(){ + } +} diff --git a/samples/java/hibernate/app/controllers/Account.java b/samples/java/hibernate/app/controllers/Account.java new file mode 100644 index 00000000..4dc2fcb5 --- /dev/null +++ b/samples/java/hibernate/app/controllers/Account.java @@ -0,0 +1,228 @@ +package controllers; + +import javax.persistence.EntityManager; + +import models.User; +import be.objectify.deadbolt.java.actions.Restrict; +import be.objectify.deadbolt.java.actions.Group; +import be.objectify.deadbolt.java.actions.SubjectPresent; + +import com.feth.play.module.pa.PlayAuthenticate; +import com.feth.play.module.pa.user.AuthUser; + +import constants.JpaConstants; +import dao.UserHome; +import play.data.Form; +import play.data.format.Formats.NonEmpty; +import play.data.validation.Constraints.MinLength; +import play.data.validation.Constraints.Required; +import play.db.jpa.JPA; +import play.i18n.Messages; +import play.mvc.Controller; +import play.mvc.Result; +import providers.MyUsernamePasswordAuthProvider; +import providers.MyUsernamePasswordAuthUser; +import views.html.account.*; +import static play.data.Form.form; + +public class Account extends Controller { + + public static class Accept { + + @Required + @NonEmpty + public Boolean accept; + + public Boolean getAccept() { + return accept; + } + + public void setAccept(Boolean accept) { + this.accept = accept; + } + + } + + public static class PasswordChange { + @MinLength(5) + @Required + public String password; + + @MinLength(5) + @Required + public String repeatPassword; + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getRepeatPassword() { + return repeatPassword; + } + + public void setRepeatPassword(String repeatPassword) { + this.repeatPassword = repeatPassword; + } + + public String validate() { + if (password == null || !password.equals(repeatPassword)) { + return Messages + .get("playauthenticate.change_password.error.passwords_not_same"); + } + return null; + } + } + + private static final Form ACCEPT_FORM = form(Accept.class); + private static final Form PASSWORD_CHANGE_FORM = form(Account.PasswordChange.class); + + @SubjectPresent + public Result link() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + return ok(link.render()); + } + + @Restrict(@Group(Application.USER_ROLE)) + public Result verifyEmail() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + User user = Application.getLocalUser(session()); + if (user.getEmailValidated()) { + // E-Mail has been validated already + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.verify_email.error.already_validated")); + } else if (user.getEmail() != null && !user.getEmail().trim().isEmpty()) { + flash(Application.FLASH_MESSAGE_KEY, Messages.get( + "playauthenticate.verify_email.message.instructions_sent", + user.getEmail())); + MyUsernamePasswordAuthProvider.getProvider() + .sendVerifyEmailMailingAfterSignup(user, ctx()); + } else { + flash(Application.FLASH_MESSAGE_KEY, Messages.get( + "playauthenticate.verify_email.error.set_email_first", + user.getEmail())); + } + return redirect(routes.Application.profile()); + } + + @Restrict(@Group(Application.USER_ROLE)) + public Result changePassword() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + User u = Application.getLocalUser(session()); + + if (!u.getEmailValidated()) { + return ok(unverified.render()); + } else { + return ok(password_change.render(PASSWORD_CHANGE_FORM)); + } + } + + @Restrict(@Group(Application.USER_ROLE)) + public Result doChangePassword() { + EntityManager em = JPA.em(JpaConstants.DB); + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + Form filledForm = PASSWORD_CHANGE_FORM + .bindFromRequest(); + if (filledForm.hasErrors()) { + // User did not select whether to link or not link + em.close(); + return badRequest(password_change.render(filledForm)); + } else { + User user = Application.getLocalUser(session()); + String newPassword = filledForm.get().password; + + UserHome userDao = new UserHome(); + + userDao.changePassword(user, new MyUsernamePasswordAuthUser(newPassword), true, em); + em.close(); + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.change_password.success")); + return redirect(routes.Application.profile()); + } + } + + @SubjectPresent + public Result askLink() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + AuthUser u = PlayAuthenticate.getLinkUser(session()); + if (u == null) { + // account to link could not be found, silently redirect to login + return redirect(routes.Application.index()); + } + return ok(ask_link.render(ACCEPT_FORM, u)); + } + + @SubjectPresent + public Result doLink() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + AuthUser u = PlayAuthenticate.getLinkUser(session()); + if (u == null) { + // account to link could not be found, silently redirect to login + return redirect(routes.Application.index()); + } + + Form filledForm = ACCEPT_FORM.bindFromRequest(); + if (filledForm.hasErrors()) { + // User did not select whether to link or not link + return badRequest(ask_link.render(filledForm, u)); + } else { + // User made a choice :) + boolean link = filledForm.get().accept; + if (link) { + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.accounts.link.success")); + } + return PlayAuthenticate.link(ctx(), link); + } + } + + @SubjectPresent + public Result askMerge() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + // this is the currently logged in user + AuthUser aUser = PlayAuthenticate.getUser(session()); + + // this is the user that was selected for a login + AuthUser bUser = PlayAuthenticate.getMergeUser(session()); + if (bUser == null) { + // user to merge with could not be found, silently redirect to login + return redirect(routes.Application.index()); + } + + // You could also get the local user object here via + // User.findByAuthUserIdentity(newUser) + return ok(ask_merge.render(ACCEPT_FORM, aUser, bUser)); + } + + @SubjectPresent + public Result doMerge() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + // this is the currently logged in user + AuthUser aUser = PlayAuthenticate.getUser(session()); + + // this is the user that was selected for a login + AuthUser bUser = PlayAuthenticate.getMergeUser(session()); + if (bUser == null) { + // user to merge with could not be found, silently redirect to login + return redirect(routes.Application.index()); + } + + Form filledForm = ACCEPT_FORM.bindFromRequest(); + if (filledForm.hasErrors()) { + // User did not select whether to merge or not merge + return badRequest(ask_merge.render(filledForm, aUser, bUser)); + } else { + // User made a choice :) + boolean merge = filledForm.get().accept; + if (merge) { + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.accounts.merge.success")); + } + return PlayAuthenticate.merge(ctx(), merge); + } + } + +} diff --git a/samples/java/hibernate/app/controllers/Application.java b/samples/java/hibernate/app/controllers/Application.java new file mode 100644 index 00000000..0bfa9035 --- /dev/null +++ b/samples/java/hibernate/app/controllers/Application.java @@ -0,0 +1,117 @@ +package controllers; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.persistence.EntityManager; + +import models.User; +import play.Routes; +import play.data.Form; +import play.db.jpa.JPA; +import play.mvc.*; +import play.mvc.Http.Session; +import providers.MyUsernamePasswordAuthProvider; +import providers.MyUsernamePasswordAuthProvider.MyLogin; +import providers.MyUsernamePasswordAuthProvider.MySignup; +import views.html.*; +import be.objectify.deadbolt.java.actions.Group; +import be.objectify.deadbolt.java.actions.Restrict; + +import com.feth.play.module.pa.PlayAuthenticate; +import com.feth.play.module.pa.providers.password.UsernamePasswordAuthProvider; +import com.feth.play.module.pa.user.AuthUser; + +import constants.JpaConstants; +import dao.UserHome; + +public class Application extends Controller { + + public static final String FLASH_MESSAGE_KEY = "message"; + public static final String FLASH_ERROR_KEY = "error"; + public static final String USER_ROLE = "user"; + + public Result index() { + return ok(index.render()); + } + + public static User getLocalUser(Session session) { + EntityManager em = JPA.em(JpaConstants.DB); + + AuthUser currentAuthUser = PlayAuthenticate.getUser(session); + + UserHome userDao = new UserHome(); + + User localUser = userDao.findByAuthUserIdentity(currentAuthUser, em); + + em.close(); + return localUser; + } + + @Restrict(@Group(Application.USER_ROLE)) + public Result restricted() { + User localUser = getLocalUser(session()); + return ok(restricted.render(localUser)); + } + + @Restrict(@Group(Application.USER_ROLE)) + public Result profile() { + + EntityManager em = JPA.em(JpaConstants.DB); + + User localUser = getLocalUser(session()); + + UserHome userDao = new UserHome(); + localUser = userDao.findById(localUser.getId(), em); + + em.close(); + return ok(profile.render(localUser)); + } + + public Result login() { + return ok(login.render(MyUsernamePasswordAuthProvider.LOGIN_FORM)); + } + + public Result doLogin() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + Form filledForm = MyUsernamePasswordAuthProvider.LOGIN_FORM.bindFromRequest(); + if (filledForm.hasErrors()) { + // User did not fill everything properly + return badRequest(login.render(filledForm)); + } else { + // Everything was filled + return UsernamePasswordAuthProvider.handleLogin(ctx()); + } + } + + public Result signup() { + return ok(signup.render(MyUsernamePasswordAuthProvider.SIGNUP_FORM)); + } + + public Result jsRoutes() { + return ok( + Routes.javascriptRouter("jsRoutes", + controllers.routes.javascript.Signup.forgotPassword())) + .as("text/javascript"); + } + + public Result doSignup() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + Form filledForm = MyUsernamePasswordAuthProvider.SIGNUP_FORM + .bindFromRequest(); + if (filledForm.hasErrors()) { + // User did not fill everything properly + return badRequest(signup.render(filledForm)); + } else { + // Everything was filled + // do something with your part of the form before handling the user + // signup + return UsernamePasswordAuthProvider.handleSignup(ctx()); + } + } + + public static String formatTimestamp(long t) { + return new SimpleDateFormat("yyyy-dd-MM HH:mm:ss").format(new Date(t)); + } + +} \ No newline at end of file diff --git a/samples/java/hibernate/app/controllers/Signup.java b/samples/java/hibernate/app/controllers/Signup.java new file mode 100644 index 00000000..c2861237 --- /dev/null +++ b/samples/java/hibernate/app/controllers/Signup.java @@ -0,0 +1,249 @@ +package controllers; + +import javax.persistence.EntityManager; + +import models.TokenAction; +import models.User; +import play.data.Form; +import play.db.jpa.JPA; +import play.i18n.Messages; +import play.mvc.Controller; +import play.mvc.Result; +import providers.MyLoginUsernamePasswordAuthUser; +import providers.MyUsernamePasswordAuthProvider; +import providers.MyUsernamePasswordAuthProvider.MyIdentity; +import providers.MyUsernamePasswordAuthUser; +import views.html.account.signup.*; + +import com.feth.play.module.pa.PlayAuthenticate; + +import constants.JpaConstants; +import dao.TokenActionHome; +import dao.UserHome; +import static play.data.Form.form; + +public class Signup extends Controller { + + public static class PasswordReset extends Account.PasswordChange { + + public PasswordReset() { + } + + public PasswordReset(String token) { + this.token = token; + } + + public String token; + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + } + + private static final Form PASSWORD_RESET_FORM = form(PasswordReset.class); + + public Result unverified() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + return ok(unverified.render()); + } + + private static final Form FORGOT_PASSWORD_FORM = form(MyIdentity.class); + + public Result forgotPassword(String email) { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + Form form = FORGOT_PASSWORD_FORM; + if (email != null && !email.trim().isEmpty()) { + form = FORGOT_PASSWORD_FORM.fill(new MyIdentity(email)); + } + return ok(password_forgot.render(form)); + } + + public Result doForgotPassword() { + EntityManager em = JPA.em(JpaConstants.DB); + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + Form filledForm = FORGOT_PASSWORD_FORM.bindFromRequest(); + if (filledForm.hasErrors()) { + // User did not fill in his/her email + em.close(); + return badRequest(password_forgot.render(filledForm)); + } else { + // The email address given *BY AN UNKNWON PERSON* to the form - we + // should find out if we actually have a user with this email + // address and whether password login is enabled for him/her. Also + // only send if the email address of the user has been verified. + String email = filledForm.get().email; + + // We don't want to expose whether a given email address is signed + // up, so just say an email has been sent, even though it might not + // be true - that's protecting our user privacy. + flash(Application.FLASH_MESSAGE_KEY, + Messages.get( + "playauthenticate.reset_password.message.instructions_sent", + email)); + + UserHome userDao = new UserHome(); + + User user = userDao.findByEmail(email, em); + if (user != null) { + // yep, we have a user with this email that is active - we do + // not know if the user owning that account has requested this + // reset, though. + MyUsernamePasswordAuthProvider provider = MyUsernamePasswordAuthProvider.getProvider(); + // User exists + if (user.getEmailValidated()) { + provider.sendPasswordResetMailing(user, ctx()); + // In case you actually want to let (the unknown person) + // know whether a user was found/an email was sent, use, + // change the flash message + } else { + // We need to change the message here, otherwise the user + // does not understand whats going on - we should not verify + // with the password reset, as a "bad" user could then sign + // up with a fake email via OAuth and get it verified by an + // a unsuspecting user that clicks the link. + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.reset_password.message.email_not_verified")); + + // You might want to re-send the verification email here... + provider.sendVerifyEmailMailingAfterSignup(user, ctx()); + } + } + + em.close(); + return redirect(routes.Application.index()); + } + } + + /** + * Returns a token object if valid, null if not + * + * @param token + * @param type + * @return + */ + private TokenAction tokenIsValid(String token, String type) { + EntityManager em = JPA.em(JpaConstants.DB); + + TokenAction ret = null; + TokenActionHome tokenDao = new TokenActionHome(); + if (token != null && !token.trim().isEmpty()) { + TokenAction ta = tokenDao.findByToken(token, type, em); + if (ta != null && ta.isValid()) { + ret = ta; + } + } + + em.close(); + return ret; + } + + public Result resetPassword(String token) { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + TokenAction ta = tokenIsValid(token, "PASSWORD_RESET"); + if (ta == null) { + return badRequest(no_token_or_invalid.render()); + } + + return ok(password_reset.render(PASSWORD_RESET_FORM + .fill(new PasswordReset(token)))); + } + + public Result doResetPassword() { + + EntityManager em = JPA.em(JpaConstants.DB); + + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + Form filledForm = PASSWORD_RESET_FORM + .bindFromRequest(); + if (filledForm.hasErrors()) { + em.close(); + return badRequest(password_reset.render(filledForm)); + } else { + String token = filledForm.get().token; + String newPassword = filledForm.get().password; + + TokenAction ta = tokenIsValid(token, "PASSWORD_RESET"); + if (ta == null) { + em.close(); + return badRequest(no_token_or_invalid.render()); + } + + TokenActionHome tokenDao = new TokenActionHome(); + + ta = tokenDao.findById(ta.getId(), em); + + String email = ta.getUser().getEmail(); + try { + // Pass true for the second parameter if you want to + // automatically create a password and the exception never to + // happen + UserHome userDao = new UserHome(); + + userDao.resetPassword(ta.getUser(), new MyUsernamePasswordAuthUser(newPassword), + false, em); + } catch (RuntimeException re) { + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.reset_password.message.no_password_account")); + } + boolean login = MyUsernamePasswordAuthProvider.getProvider() + .isLoginAfterPasswordReset(); + + em.close(); + if (login) { + // automatically log in + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.reset_password.message.success.auto_login")); + + return PlayAuthenticate.loginAndRedirect(ctx(), + new MyLoginUsernamePasswordAuthUser(email)); + } else { + // send the user to the login page + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.reset_password.message.success.manual_login")); + } + return redirect(routes.Application.login()); + } + } + + public Result oAuthDenied(String getProviderKey) { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + return ok(oAuthDenied.render(getProviderKey)); + } + + public Result exists() { + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + return ok(exists.render()); + } + + public Result verify(String token) { + + EntityManager em = JPA.em(JpaConstants.DB); + com.feth.play.module.pa.controllers.Authenticate.noCache(response()); + TokenAction ta = tokenIsValid(token, "EMAIL_VERIFICATION"); + if (ta == null) { + em.close(); + return badRequest(no_token_or_invalid.render()); + } + TokenActionHome tokenDao = new TokenActionHome(); + + ta = tokenDao.findById(ta.getId(), em); + + String email = ta.getUser().getEmail(); + + UserHome userDao = new UserHome(); + userDao.verify(ta.getUser(), em); + flash(Application.FLASH_MESSAGE_KEY, + Messages.get("playauthenticate.verify_email.success", email)); + + em.close(); + if (Application.getLocalUser(session()) != null) { + return redirect(routes.Application.index()); + } else { + return redirect(routes.Application.login()); + } + } +} diff --git a/samples/java/hibernate/app/dao/LinkedAccountHome.java b/samples/java/hibernate/app/dao/LinkedAccountHome.java new file mode 100644 index 00000000..b4c661c0 --- /dev/null +++ b/samples/java/hibernate/app/dao/LinkedAccountHome.java @@ -0,0 +1,125 @@ +package dao; + +// Generated Jul 4, 2015 5:57:00 PM by Hibernate Tools 4.3.1 + +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import models.LinkedAccount; +import models.SecurityRole; +import models.User; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.feth.play.module.pa.user.AuthUser; + +/** + * Home object for domain model class LinkedAccount. + * @see models.LinkedAccount + * @author Hibernate Tools + */ +public class LinkedAccountHome { + + private static final Log log = LogFactory.getLog(LinkedAccountHome.class); + + public void persist(LinkedAccount transientInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.persist(transientInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public void remove(LinkedAccount persistentInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.remove(persistentInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public LinkedAccount merge(LinkedAccount detachedInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + LinkedAccount result = entityManager.merge(detachedInstance); + + tx.commit(); + + return result; + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public LinkedAccount findById(Integer id, EntityManager entityManager) { + log.debug("getting LinkedAccount instance with id: " + id); + try { + LinkedAccount instance = entityManager.find(LinkedAccount.class, id); + log.debug("get successful"); + return instance; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public LinkedAccount findByProviderKey(User user, String key, EntityManager entityManager) { + + try { + Query query = entityManager.createQuery("SELECT l FROM LinkedAccount l WHERE lower(l.providerKey) = :pKey AND l.user = :user"); + query.setParameter("pKey", key.toLowerCase()); + query.setParameter("user", user); + + LinkedAccount linkedAccount = (LinkedAccount) query.getSingleResult(); + + return linkedAccount; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public LinkedAccount create(User userAccount, String providerKey, String providerUserId, EntityManager entityManager) { + LinkedAccount ret = new LinkedAccount(); + ret.setUser(userAccount); + ret.setProviderKey(providerKey); + ret.setProviderUserId(providerUserId); + + return this.merge(ret, entityManager); + } + + public void update(LinkedAccount linkedAccount, AuthUser authUser, EntityManager entityManager) { + + linkedAccount.setProviderKey(authUser.getProvider()); + linkedAccount.setProviderUserId(authUser.getId()); + + this.merge(linkedAccount, entityManager); + } +} diff --git a/samples/java/hibernate/app/dao/SecurityRoleHome.java b/samples/java/hibernate/app/dao/SecurityRoleHome.java new file mode 100644 index 00000000..41d00cdc --- /dev/null +++ b/samples/java/hibernate/app/dao/SecurityRoleHome.java @@ -0,0 +1,126 @@ +package dao; + +// Generated Jul 4, 2015 5:57:00 PM by Hibernate Tools 4.3.1 + +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import models.SecurityRole; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import play.db.jpa.JPA; + +/** + * Home object for domain model class SecurityRole. + * @see models.SecurityRole + * @author Hibernate Tools + */ +public class SecurityRoleHome { + + private static final Log log = LogFactory.getLog(SecurityRoleHome.class); + + public void persist(SecurityRole transientInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.persist(transientInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public void remove(SecurityRole persistentInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.remove(persistentInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public SecurityRole merge(SecurityRole detachedInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + SecurityRole result = entityManager.merge(detachedInstance); + + tx.commit(); + + return result; + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public SecurityRole findById(Integer id, EntityManager entityManager) { + log.debug("getting SecurityRole instance with id: " + id); + try { + SecurityRole instance = entityManager.find(SecurityRole.class, id); + log.debug("get successful"); + return instance; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public SecurityRole findByRoleName(String name, EntityManager entityManager) { + try { + Query query = entityManager.createQuery("SELECT r FROM SecurityRole r WHERE r.roleName = :name"); + query.setParameter("name", name); + + SecurityRole instance = (SecurityRole) query.getSingleResult(); + log.debug("get successful"); + return instance; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public Boolean hasInitialData(EntityManager entityManager) { + //log.debug("getting SecurityRole instance with id: " + id); + try { + Query query = entityManager.createQuery("SELECT COUNT(*) FROM SecurityRole"); + + Long count = (Long) query.getSingleResult(); + + if(count.intValue() == 0) + { + return false; + } + else + { + return true; + } + + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } +} diff --git a/samples/java/hibernate/app/dao/TokenActionHome.java b/samples/java/hibernate/app/dao/TokenActionHome.java new file mode 100644 index 00000000..14477987 --- /dev/null +++ b/samples/java/hibernate/app/dao/TokenActionHome.java @@ -0,0 +1,152 @@ +package dao; + +// Generated Jul 4, 2015 5:57:00 PM by Hibernate Tools 4.3.1 + +import java.util.Date; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; +import javax.persistence.NoResultException; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import models.SecurityRole; +import models.TokenAction; +import models.User; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Home object for domain model class TokenAction. + * @see models.TokenAction + * @author Hibernate Tools + */ +public class TokenActionHome { + + private static final Log log = LogFactory.getLog(TokenActionHome.class); + + private final static long VERIFICATION_TIME = 7 * 24 * 3600; + + public void persist(TokenAction transientInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.persist(transientInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public void remove(TokenAction persistentInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.remove(persistentInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public TokenAction merge(TokenAction detachedInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + TokenAction result = entityManager.merge(detachedInstance); + + tx.commit(); + + return result; + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public TokenAction findById(Integer id, EntityManager entityManager) { + log.debug("getting TokenAction instance with id: " + id); + try { + TokenAction instance = entityManager.find(TokenAction.class, id); + log.debug("get successful"); + return instance; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public TokenAction create(String type, String token, User targetUser, EntityManager entityManager) { + + UserHome userDao = new UserHome(); + + User user = userDao.findById(targetUser.getId(), entityManager); + + TokenAction ua = new TokenAction(); + ua.setUser(user); + ua.setToken(token); + ua.setType(type); + Date created = new Date(); + ua.setCreatedOn(created); + ua.setExpiresOn(new Date(created.getTime() + VERIFICATION_TIME * 1000)); + + this.persist(ua, entityManager); + return ua; + } + + public TokenAction findByToken(String token, String type, EntityManager entityManager) { + try { + Query query = entityManager.createQuery("SELECT t FROM TokenAction t WHERE lower(t.token) = :token AND lower(t.type) = :type"); + query.setParameter("token", token.toLowerCase()); + query.setParameter("type", type.toLowerCase()); + + TokenAction instance = (TokenAction) query.getSingleResult(); + log.debug("get successful"); + return instance; + }catch (NoResultException e){ + return null; + } + catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public void deleteByUser(User u, String type, EntityManager entityManager) { + + try { + Query query = entityManager.createQuery("SELECT t FROM TokenAction t JOIN t.user u WHERE u = :user AND lower(t.type) = :type"); + query.setParameter("user", u); + query.setParameter("type", type.toLowerCase()); + + List tokens = (List) query.getResultList(); + + for(TokenAction token: tokens) + { + this.remove(token, entityManager); + } + + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } +} diff --git a/samples/java/hibernate/app/dao/UserHome.java b/samples/java/hibernate/app/dao/UserHome.java new file mode 100644 index 00000000..7ec2ab6f --- /dev/null +++ b/samples/java/hibernate/app/dao/UserHome.java @@ -0,0 +1,346 @@ +package dao; + +// Generated Jul 4, 2015 5:57:00 PM by Hibernate Tools 4.3.1 + +import java.util.Date; +import java.util.List; +import java.util.Set; + +import javax.persistence.EntityManager; +import javax.persistence.EntityTransaction; +import javax.persistence.NoResultException; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import models.LinkedAccount; +import models.SecurityRole; +import models.User; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import providers.MyUsernamePasswordAuthUser; + +import com.feth.play.module.pa.providers.password.UsernamePasswordAuthUser; +import com.feth.play.module.pa.user.AuthUser; +import com.feth.play.module.pa.user.AuthUserIdentity; +import com.feth.play.module.pa.user.EmailIdentity; +import com.feth.play.module.pa.user.FirstLastNameIdentity; +import com.feth.play.module.pa.user.NameIdentity; + +import controllers.Application; + +/** + * Home object for domain model class User. + * @see models.User + * @author Hibernate Tools + */ +public class UserHome { + + private static final Log log = LogFactory.getLog(UserHome.class); + + public void persist(User transientInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.persist(transientInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public void remove(User persistentInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + entityManager.remove(persistentInstance); + + tx.commit(); + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public User merge(User detachedInstance, EntityManager entityManager) { + + EntityTransaction tx = null; + try { + tx = entityManager.getTransaction(); + tx.begin(); + + User result = entityManager.merge(detachedInstance); + + tx.commit(); + + return result; + } + catch (RuntimeException e) { + if ( tx != null && tx.isActive() ) tx.rollback(); + throw e; // or display error message + } + } + + public User findById(Integer id, EntityManager entityManager) { + + try { + Query query = entityManager.createQuery("SELECT u FROM User u LEFT JOIN FETCH u.linkedAccounts WHERE u.id = :id"); + query.setParameter("id", id); + + User user = (User) query.getSingleResult(); + + return user; + } catch (NoResultException nr) { + return null; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + + /*log.debug("getting User instance with id: " + id); + try { + User instance = entityManager.find(User.class, id); + log.debug("get successful"); + return instance; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + }*/ + } + + public LinkedAccount getAccountByProvider(User user, String providerKey, EntityManager entityManager) { + LinkedAccountHome dao = new LinkedAccountHome(); + + return dao.findByProviderKey(user, providerKey, entityManager); + } + + public void changePassword(User user, MyUsernamePasswordAuthUser authUser, boolean create, EntityManager entityManager) { + LinkedAccount a = this.getAccountByProvider(user, authUser.getProvider(), entityManager); + + LinkedAccountHome dao = new LinkedAccountHome(); + + if (a == null) { + if (create) { + a = dao.create(user, authUser.getProvider(), authUser.getId(), entityManager); + a.setUser(user); + } else { + throw new RuntimeException("Account not enabled for password usage"); + } + } + + a.setProviderUserId(authUser.getHashedPassword()); + + dao.merge(a, entityManager); + } + + public void resetPassword(User user, MyUsernamePasswordAuthUser authUser, boolean create, EntityManager entityManager) { + // You might want to wrap this into a transaction + this.changePassword(user, authUser, create, entityManager); + + TokenActionHome tokenDao = new TokenActionHome(); + + tokenDao.deleteByUser(user, "PASSWORD_RESET", entityManager); + } + + public boolean existsByAuthUserIdentity( AuthUserIdentity identity, EntityManager entityManager) { + User exp = null; + if (identity instanceof UsernamePasswordAuthUser) { + exp = findByUsernamePasswordIdentity((UsernamePasswordAuthUser) identity, entityManager); + } else { + exp = getAuthUserFind(identity, entityManager); + } + + if(exp == null) + { + return false; + } + else + { + return true; + } + //return exp.findRowCount() > 0; + } + + public User findByEmail(String email, EntityManager entityManager) { + + try { + Query query = entityManager.createQuery("SELECT DISTINCT u FROM User u WHERE lower(u.email) = :email AND u.active = true"); + query.setParameter("email", email.toLowerCase()); + + User user = (User) query.getSingleResult(); + + return user; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public User findByUsernamePasswordIdentity(UsernamePasswordAuthUser identity, EntityManager entityManager) { + + try { + Query query = entityManager.createQuery("SELECT DISTINCT u FROM LinkedAccount l JOIN l.user u LEFT JOIN FETCH u.securityRoles LEFT JOIN FETCH u.userPermissions WHERE lower(l.providerKey) = :pKey AND lower(u.email) = :email AND u.active = true"); + query.setParameter("pKey", identity.getProvider().toLowerCase()); + query.setParameter("email", identity.getEmail().toLowerCase()); + + User user = (User) query.getSingleResult(); + + return user; + } catch (NoResultException nr) { + return null; + } catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + private User getAuthUserFind(AuthUserIdentity identity, EntityManager entityManager) { + + try { + Query query = entityManager.createQuery("SELECT DISTINCT u FROM LinkedAccount l JOIN l.user u LEFT JOIN FETCH u.securityRoles LEFT JOIN FETCH u.userPermissions WHERE lower(l.providerKey) = :pKey AND lower(l.providerUserId) = :userId AND u.active = true"); + query.setParameter("pKey", identity.getProvider().toLowerCase()); + query.setParameter("userId", identity.getId().toLowerCase()); + + User user = (User) query.getSingleResult(); + + return user; + }catch (NoResultException e) { + return null; + } + catch (RuntimeException re) { + log.error("get failed", re); + throw re; + } + } + + public User findByAuthUserIdentity(AuthUserIdentity identity, EntityManager entityManager) { + if (identity == null) { + return null; + } + if (identity instanceof UsernamePasswordAuthUser) { + return findByUsernamePasswordIdentity((UsernamePasswordAuthUser) identity, entityManager); + } else { + return getAuthUserFind(identity, entityManager); + } + } + + public User create(AuthUser authUser, EntityManager entityManager) { + return this.createByRole(authUser, controllers.Application.USER_ROLE, entityManager); + } + + public User createByRole(AuthUser authUser, String roleName, EntityManager entityManager) { + User user = new User(); + + SecurityRoleHome roleDao = new SecurityRoleHome(); + + SecurityRole role = roleDao.findByRoleName(roleName, entityManager); + + Set roles = user.getSecurityRoles(); + roles.add(role); + + user.setSecurityRoles(roles); + + user.setActive(true); + user.setLastLogin(new Date()); + + if (authUser instanceof EmailIdentity) { + EmailIdentity identity = (EmailIdentity) authUser; + // Remember, even when getting them from FB & Co., emails should be + // verified within the application as a security breach there might + // break your security as well! + user.setEmail(identity.getEmail()); + user.setEmailValidated(false); + } + + if (authUser instanceof NameIdentity) { + NameIdentity identity = (NameIdentity) authUser; + String name = identity.getName(); + if (name != null) { + user.setName(name); + } + } + + if (authUser instanceof FirstLastNameIdentity) { + FirstLastNameIdentity identity = (FirstLastNameIdentity) authUser; + String firstName = identity.getFirstName(); + String lastName = identity.getLastName(); + if (firstName != null) { + user.setFirstName(firstName); + } + if (lastName != null) { + user.setLastName(lastName); + } + } + + user = this.merge(user, entityManager); + + LinkedAccountHome accountsDao = new LinkedAccountHome(); + + accountsDao.create(user, authUser.getProvider(), authUser.getId(), entityManager); + + return user; + } + + public void verify(User unverified, EntityManager entityManager) { + // You might want to wrap this into a transaction + unverified.setEmailValidated(true); + this.merge(unverified, entityManager); + + TokenActionHome tokenDao = new TokenActionHome(); + + tokenDao.deleteByUser(unverified, "EMAIL_VERIFICATION", entityManager); + } + + public void merge(User currentUser, User otherUser, EntityManager entityManager) { + + Set currentUserAccounts = currentUser.getLinkedAccounts(); + + LinkedAccountHome linkedAccountDao = new LinkedAccountHome(); + + for (LinkedAccount acc : otherUser.getLinkedAccounts()) { + currentUserAccounts.add(linkedAccountDao.create(currentUser, acc.getProviderKey(), acc.getProviderUserId(), entityManager)); + } + + // do all other merging stuff here - like resources, etc. + currentUser.setLinkedAccounts(currentUserAccounts); + + // deactivate the merged user that got added to this one + otherUser.setActive(false); + + this.merge(otherUser, entityManager); + this.merge(currentUser, entityManager); + } + + public void merge(AuthUser oldUser, AuthUser newUser, EntityManager entityManager) { + + User oldUserDb = this.findByAuthUserIdentity(oldUser, entityManager); + User newUserDb = this.findByAuthUserIdentity(newUser, entityManager); + + this.merge(oldUserDb, newUserDb, entityManager); + } + + public void addLinkedAccount(AuthUser oldUser, AuthUser newUser, EntityManager entityManager) { + User u = this.findByAuthUserIdentity(oldUser, entityManager); + + LinkedAccountHome linkedAccountsDao = new LinkedAccountHome(); + + Set linkedAccounts = u.getLinkedAccounts(); + + linkedAccounts.add(linkedAccountsDao.create(u, newUser.getProvider(), newUser.getId(), entityManager)); + + u.setLinkedAccounts(linkedAccounts); + + this.merge(u, entityManager); + } +} diff --git a/samples/java/hibernate/app/models/LinkedAccount.java b/samples/java/hibernate/app/models/LinkedAccount.java new file mode 100644 index 00000000..1fd99eae --- /dev/null +++ b/samples/java/hibernate/app/models/LinkedAccount.java @@ -0,0 +1,75 @@ +package models; + +// Generated Jul 4, 2015 5:56:59 PM by Hibernate Tools 4.3.1 + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import static javax.persistence.GenerationType.IDENTITY; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +/** + * LinkedAccount generated by hbm2java + */ +@Entity +@Table(name = "linked_account") +public class LinkedAccount implements java.io.Serializable { + + private Integer id; + private User user; + private String providerUserId; + private String providerKey; + + public LinkedAccount() { + } + + public LinkedAccount(User user, String providerUserId, String providerKey) { + this.user = user; + this.providerUserId = providerUserId; + this.providerKey = providerKey; + } + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "id", unique = true, nullable = false) + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "users_id") + public User getUser() { + return this.user; + } + + public void setUser(User user) { + this.user = user; + } + + @Column(name = "provider_user_id") + public String getProviderUserId() { + return this.providerUserId; + } + + public void setProviderUserId(String providerUserId) { + this.providerUserId = providerUserId; + } + + @Column(name = "provider_key") + public String getProviderKey() { + return this.providerKey; + } + + public void setProviderKey(String providerKey) { + this.providerKey = providerKey; + } + +} diff --git a/samples/java/hibernate/app/models/SecurityRole.java b/samples/java/hibernate/app/models/SecurityRole.java new file mode 100644 index 00000000..63960832 --- /dev/null +++ b/samples/java/hibernate/app/models/SecurityRole.java @@ -0,0 +1,80 @@ +package models; + +// Generated Jul 4, 2015 5:56:59 PM by Hibernate Tools 4.3.1 + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; + +import static javax.persistence.GenerationType.IDENTITY; + +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + +import be.objectify.deadbolt.core.models.Role; + +/** + * SecurityRole generated by hbm2java + */ +@Entity +@Table(name = "security_role") +public class SecurityRole implements java.io.Serializable, Role { + + private Integer id; + private String roleName; + private Set users = new HashSet(0); + + public SecurityRole() { + } + + public SecurityRole(String roleName, Set users) { + this.roleName = roleName; + this.users = users; + } + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "id", unique = true, nullable = false) + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Column(name = "role_name") + public String getRoleName() { + return this.roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "user_has_security_role", joinColumns = { @JoinColumn(name = "security_role_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }) + public Set getUsers() { + return this.users; + } + + public void setUsers(Set users) { + this.users = users; + } + + @Override + @Transient + public String getName() { + // TODO Auto-generated method stub + return this.getRoleName(); + } + +} diff --git a/samples/java/hibernate/app/models/TokenAction.java b/samples/java/hibernate/app/models/TokenAction.java new file mode 100644 index 00000000..1371bf8d --- /dev/null +++ b/samples/java/hibernate/app/models/TokenAction.java @@ -0,0 +1,118 @@ +package models; + +// Generated Jul 4, 2015 5:56:59 PM by Hibernate Tools 4.3.1 + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; + +import static javax.persistence.GenerationType.IDENTITY; + +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import javax.persistence.UniqueConstraint; + +/** + * TokenAction generated by hbm2java + */ +@Entity +@Table(name = "token_action", uniqueConstraints = @UniqueConstraint(columnNames = "token")) +public class TokenAction implements java.io.Serializable { + + private Integer id; + private User user; + private String token; + private String type; + private Date createdOn; + private Date expiresOn; + + public TokenAction() { + } + + public TokenAction(Date createdOn, Date expiresOn) { + this.createdOn = createdOn; + this.expiresOn = expiresOn; + } + + public TokenAction(User user, String token, String type, Date createdOn, + Date expiresOn) { + this.user = user; + this.token = token; + this.type = type; + this.createdOn = createdOn; + this.expiresOn = expiresOn; + } + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "id", unique = true, nullable = false) + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "target_user_id") + public User getUser() { + return this.user; + } + + public void setUser(User user) { + this.user = user; + } + + @Column(name = "token", unique = true) + public String getToken() { + return this.token; + } + + public void setToken(String token) { + this.token = token; + } + + @Column(name = "type", columnDefinition="enum('EMAIL_VERIFICATION','PASSWORD_RESET')") + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_on", nullable = false, length = 19) + public Date getCreatedOn() { + return this.createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "expires_on", nullable = false, length = 19) + public Date getExpiresOn() { + return this.expiresOn; + } + + public void setExpiresOn(Date expiresOn) { + this.expiresOn = expiresOn; + } + + @Transient + public boolean isValid() { + return this.expiresOn.after(new Date()); + } + +} diff --git a/samples/java/hibernate/app/models/User.java b/samples/java/hibernate/app/models/User.java new file mode 100644 index 00000000..edce3a8f --- /dev/null +++ b/samples/java/hibernate/app/models/User.java @@ -0,0 +1,237 @@ +package models; + +// Generated Jul 4, 2015 5:56:59 PM by Hibernate Tools 4.3.1 + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; + +import static javax.persistence.GenerationType.IDENTITY; + +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import be.objectify.deadbolt.core.models.Permission; +import be.objectify.deadbolt.core.models.Role; +import be.objectify.deadbolt.core.models.Subject; + +/** + * User generated by hbm2java + */ +@Entity +@Table(name = "user") +public class User implements java.io.Serializable, Subject { + + private Integer id; + private String email; + private String name; + private String firstName; + private String lastName; + private Date lastLogin; + private Boolean active; + private Boolean emailValidated; + private Date createdOn; + private Date updatedOn; + private Set securityRoles = new HashSet(0); + private Set linkedAccounts = new HashSet(0); + private Set tokenActions = new HashSet(0); + private Set userPermissions = new HashSet(0); + + public User() { + } + + public User(String email, String name, + String firstName, String lastName, Date lastLogin, Boolean active, Boolean emailValidated, + Date createdOn, Date updatedOn, Set securityRoles, + Set linkedAccounts, Set tokenActions, + Set userPermissions) { + this.email = email; + this.name = name; + this.firstName = firstName; + this.lastName = lastName; + this.lastLogin = lastLogin; + this.active = active; + this.emailValidated = emailValidated; + this.createdOn = createdOn; + this.updatedOn = updatedOn; + this.securityRoles = securityRoles; + this.linkedAccounts = linkedAccounts; + this.tokenActions = tokenActions; + this.userPermissions = userPermissions; + } + + @Id + @GeneratedValue(strategy = IDENTITY) + @Column(name = "id", unique = true, nullable = false) + public Integer getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + @Column(name = "email") + public String getEmail() { + return this.email; + } + + public void setEmail(String email) { + this.email = email; + } + + @Column(name = "name") + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + @Column(name = "first_name") + public String getFirstName() { + return this.firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + @Column(name = "last_name") + public String getLastName() { + return this.lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "last_login", length = 19) + public Date getLastLogin() { + return this.lastLogin; + } + + public void setLastLogin(Date lastLogin) { + this.lastLogin = lastLogin; + } + + @Column(name = "active") + public Boolean getActive() { + return this.active; + } + + public void setActive(Boolean active) { + this.active = active; + } + + @Column(name = "email_validated") + public Boolean getEmailValidated() { + return this.emailValidated; + } + + public void setEmailValidated(Boolean emailValidated) { + this.emailValidated = emailValidated; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_on", length = 19) + public Date getCreatedOn() { + return this.createdOn; + } + + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "updated_on", length = 19) + public Date getUpdatedOn() { + return this.updatedOn; + } + + public void setUpdatedOn(Date updatedOn) { + this.updatedOn = updatedOn; + } + + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "user_has_security_role", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "security_role_id", nullable = false, updatable = false) }) + public Set getSecurityRoles() { + return this.securityRoles; + } + + public void setSecurityRoles(Set securityRoles) { + this.securityRoles = securityRoles; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "user") + public Set getLinkedAccounts() { + return this.linkedAccounts; + } + + public void setLinkedAccounts(Set linkedAccounts) { + this.linkedAccounts = linkedAccounts; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "user") + public Set getTokenActions() { + return this.tokenActions; + } + + public void setTokenActions(Set tokenActions) { + this.tokenActions = tokenActions; + } + + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "user_has_user_permission", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "user_permission_id", nullable = false, updatable = false) }) + public Set getUserPermissions() { + return this.userPermissions; + } + + public void setUserPermissions(Set userPermissions) { + this.userPermissions = userPermissions; + } + + @Transient + public Set getProviders() { + Set providerKeys = new HashSet(this.linkedAccounts.size()); + for (LinkedAccount acc : this.getLinkedAccounts()) { + providerKeys.add(acc.getProviderKey()); + } + return providerKeys; + } + + @Override + @Transient + public String getIdentifier() { + return Integer.toString(this.id); + } + + @Override + @Transient + public List getPermissions() { + return new ArrayList(this.getUserPermissions()); + } + + @Override + @Transient + public List getRoles() { + return new ArrayList(this.getSecurityRoles()); + } +} diff --git a/samples/java/hibernate/app/models/UserPermission.java b/samples/java/hibernate/app/models/UserPermission.java new file mode 100644 index 00000000..8e24c9c9 --- /dev/null +++ b/samples/java/hibernate/app/models/UserPermission.java @@ -0,0 +1,72 @@ +package models; + +// Generated Jul 4, 2015 5:56:59 PM by Hibernate Tools 4.3.1 + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.Table; + +import be.objectify.deadbolt.core.models.Permission; + +/** + * UserPermission generated by hbm2java + */ +@Entity +@Table(name = "user_permission") +public class UserPermission implements java.io.Serializable, Permission { + + private int id; + private String value; + private Set users = new HashSet(0); + + public UserPermission() { + } + + public UserPermission(int id) { + this.id = id; + } + + public UserPermission(int id, String value, Set users) { + this.id = id; + this.value = value; + this.users = users; + } + + @Id + @Column(name = "id", unique = true, nullable = false) + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + @Column(name = "value") + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "user_has_user_permission", joinColumns = { @JoinColumn(name = "user_permission_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }) + public Set getUsers() { + return this.users; + } + + public void setUsers(Set users) { + this.users = users; + } + +} diff --git a/samples/java/hibernate/app/providers/MyLoginUsernamePasswordAuthUser.java b/samples/java/hibernate/app/providers/MyLoginUsernamePasswordAuthUser.java new file mode 100644 index 00000000..1594c46c --- /dev/null +++ b/samples/java/hibernate/app/providers/MyLoginUsernamePasswordAuthUser.java @@ -0,0 +1,39 @@ +package providers; + +import com.feth.play.module.pa.providers.password.DefaultUsernamePasswordAuthUser; + +public class MyLoginUsernamePasswordAuthUser extends + DefaultUsernamePasswordAuthUser { + + /** + * + */ + private static final long serialVersionUID = 1L; + /** + * The session timeout in seconds + * Defaults to two weeks + */ + final static long SESSION_TIMEOUT = 24 * 14 * 3600; + private long expiration; + + /** + * For logging the user in automatically + * + * @param email + */ + public MyLoginUsernamePasswordAuthUser(String email) { + this(null, email); + } + + public MyLoginUsernamePasswordAuthUser(String clearPassword, String email) { + super(clearPassword, email); + + expiration = System.currentTimeMillis() + 1000 * SESSION_TIMEOUT; + } + + @Override + public long expires() { + return expiration; + } + +} diff --git a/samples/java/hibernate/app/providers/MyStupidBasicAuthProvider.java b/samples/java/hibernate/app/providers/MyStupidBasicAuthProvider.java new file mode 100644 index 00000000..04a63620 --- /dev/null +++ b/samples/java/hibernate/app/providers/MyStupidBasicAuthProvider.java @@ -0,0 +1,65 @@ +/* + * Copyright © 2014 Florian Hars, nMIT Solutions GmbH + * + * 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. + */ +package providers; + +import play.Application; +import play.twirl.api.Content; +import play.mvc.Http.Context; +import views.html.login; + +import com.feth.play.module.pa.providers.wwwauth.basic.BasicAuthProvider; +import com.feth.play.module.pa.user.AuthUser; +import com.google.inject.Inject; + +/** A really simple basic auth provider that accepts one hard coded user */ +public class MyStupidBasicAuthProvider extends BasicAuthProvider { + + @Inject + public MyStupidBasicAuthProvider(Application app) { + super(app); + } + + @Override + protected AuthUser authenticateUser(String username, String password) { + if (username.equals("example") && password.equals("secret")) { + return new AuthUser() { + private static final long serialVersionUID = 1L; + + @Override + public String getId() { + return "example"; + } + + @Override + public String getProvider() { + return "basic"; + } + }; + } + return null; + } + + @Override + public String getKey() { + return "basic"; + } + + /** Diplay the normal login form if HTTP authentication fails */ + @Override + protected Content unauthorized(Context context) { + return login.render(MyUsernamePasswordAuthProvider.LOGIN_FORM); + } +} diff --git a/samples/java/hibernate/app/providers/MyUsernamePasswordAuthProvider.java b/samples/java/hibernate/app/providers/MyUsernamePasswordAuthProvider.java new file mode 100644 index 00000000..55325006 --- /dev/null +++ b/samples/java/hibernate/app/providers/MyUsernamePasswordAuthProvider.java @@ -0,0 +1,423 @@ +package providers; + +import com.feth.play.module.mail.Mailer.Mail.Body; +import com.feth.play.module.pa.PlayAuthenticate; +import com.feth.play.module.pa.providers.password.UsernamePasswordAuthProvider; +import com.feth.play.module.pa.providers.password.UsernamePasswordAuthUser; +import com.google.inject.Inject; + +import constants.JpaConstants; +import controllers.routes; +import dao.TokenActionHome; +import dao.UserHome; +import models.LinkedAccount; +import models.TokenAction; +import models.User; +import play.Application; +import play.Logger; +import play.data.Form; +import play.data.validation.Constraints.Email; +import play.data.validation.Constraints.MinLength; +import play.data.validation.Constraints.Required; +import play.db.jpa.JPA; +import play.i18n.Lang; +import play.i18n.Messages; +import play.mvc.Call; +import play.mvc.Http.Context; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import javax.persistence.EntityManager; + +import static play.data.Form.form; + +public class MyUsernamePasswordAuthProvider + extends + UsernamePasswordAuthProvider { + + private static final String SETTING_KEY_VERIFICATION_LINK_SECURE = SETTING_KEY_MAIL + + "." + "verificationLink.secure"; + private static final String SETTING_KEY_PASSWORD_RESET_LINK_SECURE = SETTING_KEY_MAIL + + "." + "passwordResetLink.secure"; + private static final String SETTING_KEY_LINK_LOGIN_AFTER_PASSWORD_RESET = "loginAfterPasswordReset"; + + private static final String EMAIL_TEMPLATE_FALLBACK_LANGUAGE = "en"; + + @Override + protected List neededSettingKeys() { + List needed = new ArrayList( + super.neededSettingKeys()); + needed.add(SETTING_KEY_VERIFICATION_LINK_SECURE); + needed.add(SETTING_KEY_PASSWORD_RESET_LINK_SECURE); + needed.add(SETTING_KEY_LINK_LOGIN_AFTER_PASSWORD_RESET); + return needed; + } + + public static MyUsernamePasswordAuthProvider getProvider() { + return (MyUsernamePasswordAuthProvider) PlayAuthenticate + .getProvider(UsernamePasswordAuthProvider.PROVIDER_KEY); + } + + public static class MyIdentity { + + public MyIdentity() { + } + + public MyIdentity(String email) { + this.email = email; + } + + @Required + @Email + public String email; + + } + + public static class MyLogin extends MyIdentity + implements + com.feth.play.module.pa.providers.password.UsernamePasswordAuthProvider.UsernamePassword { + + @Required + @MinLength(5) + public String password; + + @Override + public String getEmail() { + return email; + } + + @Override + public String getPassword() { + return password; + } + } + + public static class MySignup extends MyLogin { + + @Required + @MinLength(5) + public String repeatPassword; + + @Required + public String name; + + public String validate() { + if (password == null || !password.equals(repeatPassword)) { + return Messages + .get("playauthenticate.password.signup.error.passwords_not_same"); + } + return null; + } + } + + public static final Form SIGNUP_FORM = form(MySignup.class); + public static final Form LOGIN_FORM = form(MyLogin.class); + + @Inject + public MyUsernamePasswordAuthProvider(Application app) { + super(app); + } + + protected Form getSignupForm() { + return SIGNUP_FORM; + } + + protected Form getLoginForm() { + return LOGIN_FORM; + } + + @Override + protected com.feth.play.module.pa.providers.password.UsernamePasswordAuthProvider.SignupResult signupUser(MyUsernamePasswordAuthUser user) { + + EntityManager em = JPA.em(JpaConstants.DB); + + UserHome userDao = new UserHome(); + + User u = userDao.findByUsernamePasswordIdentity(user, em); + if (u != null) { + if (u.getEmailValidated()) { + // This user exists, has its email validated and is active + em.close(); + return SignupResult.USER_EXISTS; + } else { + // this user exists, is active but has not yet validated its + // email + em.close(); + return SignupResult.USER_EXISTS_UNVERIFIED; + } + } + // The user either does not exist or is inactive - create a new one + @SuppressWarnings("unused") + User newUser = userDao.create(user, em); + // Usually the email should be verified before allowing login, however + // if you return + // return SignupResult.USER_CREATED; + // then the user gets logged in directly + + em.close(); + return SignupResult.USER_CREATED_UNVERIFIED; + } + + @Override + protected com.feth.play.module.pa.providers.password.UsernamePasswordAuthProvider.LoginResult loginUser(MyLoginUsernamePasswordAuthUser authUser) { + + EntityManager em = JPA.em(JpaConstants.DB); + + UserHome userDao = new UserHome(); + + User u = userDao.findByUsernamePasswordIdentity(authUser, em); + if (u == null) { + em.close(); + return LoginResult.NOT_FOUND; + } else { + if (!u.getEmailValidated()) { + em.close(); + return LoginResult.USER_UNVERIFIED; + } else { + for (LinkedAccount acc : u.getLinkedAccounts()) { + if (getKey().equals(acc.getProviderKey())) { + if (authUser.checkPassword(acc.getProviderUserId(), + authUser.getPassword())) { + // Password was correct + em.close(); + return LoginResult.USER_LOGGED_IN; + } else { + // if you don't return here, + // you would allow the user to have + // multiple passwords defined + // usually we don't want this + em.close(); + return LoginResult.WRONG_PASSWORD; + } + } + } + em.close(); + return LoginResult.WRONG_PASSWORD; + } + } + } + + @Override + protected Call userExists(UsernamePasswordAuthUser authUser) { + return routes.Signup.exists(); + } + + @Override + protected Call userUnverified(UsernamePasswordAuthUser authUser) { + return routes.Signup.unverified(); + } + + @Override + protected MyUsernamePasswordAuthUser buildSignupAuthUser(MySignup signup, Context ctx) { + return new MyUsernamePasswordAuthUser(signup); + } + + @Override + protected MyLoginUsernamePasswordAuthUser buildLoginAuthUser(MyLogin login, Context ctx) { + return new MyLoginUsernamePasswordAuthUser(login.getPassword(), + login.getEmail()); + } + + + @Override + protected MyLoginUsernamePasswordAuthUser transformAuthUser(MyUsernamePasswordAuthUser authUser, Context context) { + return new MyLoginUsernamePasswordAuthUser(authUser.getEmail()); + } + + @Override + protected String getVerifyEmailMailingSubject(MyUsernamePasswordAuthUser user, Context ctx) { + return Messages.get("playauthenticate.password.verify_signup.subject"); + } + + @Override + protected String onLoginUserNotFound(Context context) { + context.flash() + .put(controllers.Application.FLASH_ERROR_KEY, + Messages.get("playauthenticate.password.login.unknown_user_or_pw")); + return super.onLoginUserNotFound(context); + } + + @Override + protected Body getVerifyEmailMailingBody(String token,MyUsernamePasswordAuthUser user, Context ctx) { + + boolean isSecure = getConfiguration().getBoolean( + SETTING_KEY_VERIFICATION_LINK_SECURE); + String url = routes.Signup.verify(token).absoluteURL( + ctx.request(), isSecure); + + Lang lang = Lang.preferred(ctx.request().acceptLanguages()); + String langCode = lang.code(); + + String html = getEmailTemplate( + "views.html.account.signup.email.verify_email", langCode, url, + token, user.getName(), user.getEmail()); + String text = getEmailTemplate( + "views.txt.account.signup.email.verify_email", langCode, url, + token, user.getName(), user.getEmail()); + + return new Body(text, html); + } + + private static String generateToken() { + return UUID.randomUUID().toString(); + } + + @Override + protected String generateVerificationRecord(MyUsernamePasswordAuthUser user) { + EntityManager em = JPA.em(JpaConstants.DB); + + UserHome userDao = new UserHome(); + + String verf = generateVerificationRecord(userDao.findByAuthUserIdentity(user, em)); + + em.close(); + return verf; + } + + protected String generateVerificationRecord(User user) { + EntityManager em = JPA.em(JpaConstants.DB); + + String token = generateToken(); + // Do database actions, etc. + TokenActionHome tokenDao = new TokenActionHome(); + + tokenDao.create("EMAIL_VERIFICATION", token, user, em); + + em.close(); + return token; + } + + protected String generatePasswordResetRecord(User u) { + EntityManager em = JPA.em(JpaConstants.DB); + + String token = generateToken(); + + TokenActionHome tokenDao = new TokenActionHome(); + + tokenDao.create("PASSWORD_RESET", token, u, em); + + em.close(); + return token; + } + + protected String getPasswordResetMailingSubject(User user, Context ctx) { + return Messages.get("playauthenticate.password.reset_email.subject"); + } + + protected Body getPasswordResetMailingBody(String token, User user, Context ctx) { + + boolean isSecure = getConfiguration().getBoolean( + SETTING_KEY_PASSWORD_RESET_LINK_SECURE); + String url = routes.Signup.resetPassword(token).absoluteURL( + ctx.request(), isSecure); + + Lang lang = Lang.preferred(ctx.request().acceptLanguages()); + String langCode = lang.code(); + + String html = getEmailTemplate( + "views.html.account.email.password_reset", langCode, url, + token, user.getName(), user.getEmail()); + String text = getEmailTemplate( + "views.txt.account.email.password_reset", langCode, url, token, + user.getName(), user.getEmail()); + + return new Body(text, html); + } + + public void sendPasswordResetMailing(User user, Context ctx) { + String token = generatePasswordResetRecord(user); + String subject = getPasswordResetMailingSubject(user, ctx); + Body body = getPasswordResetMailingBody(token, user, ctx); + sendMail(subject, body, getEmailName(user)); + } + + public boolean isLoginAfterPasswordReset() { + return getConfiguration().getBoolean( + SETTING_KEY_LINK_LOGIN_AFTER_PASSWORD_RESET); + } + + protected String getVerifyEmailMailingSubjectAfterSignup(User user, + Context ctx) { + return Messages.get("playauthenticate.password.verify_email.subject"); + } + + protected String getEmailTemplate(String template, + String langCode, String url, String token, + String name, String email) { + Class cls = null; + String ret = null; + try { + cls = Class.forName(template + "_" + langCode); + } catch (ClassNotFoundException e) { + Logger.warn("Template: '" + + template + + "_" + + langCode + + "' was not found! Trying to use English fallback template instead."); + } + if (cls == null) { + try { + cls = Class.forName(template + "_" + + EMAIL_TEMPLATE_FALLBACK_LANGUAGE); + } catch (ClassNotFoundException e) { + Logger.error("Fallback template: '" + template + "_" + + EMAIL_TEMPLATE_FALLBACK_LANGUAGE + + "' was not found either!"); + } + } + if (cls != null) { + Method htmlRender = null; + try { + htmlRender = cls.getMethod("render", String.class, + String.class, String.class, String.class); + ret = htmlRender.invoke(null, url, token, name, email) + .toString(); + + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + } + return ret; + } + + protected Body getVerifyEmailMailingBodyAfterSignup(String token, + User user, Context ctx) { + + boolean isSecure = getConfiguration().getBoolean( + SETTING_KEY_VERIFICATION_LINK_SECURE); + String url = routes.Signup.verify(token).absoluteURL( + ctx.request(), isSecure); + + Lang lang = Lang.preferred(ctx.request().acceptLanguages()); + String langCode = lang.code(); + + String html = getEmailTemplate( + "views.html.account.email.verify_email", langCode, url, token, + user.getName(), user.getEmail()); + String text = getEmailTemplate( + "views.txt.account.email.verify_email", langCode, url, token, + user.getName(), user.getEmail()); + + return new Body(text, html); + } + + public void sendVerifyEmailMailingAfterSignup(User user, Context ctx) { + + String subject = getVerifyEmailMailingSubjectAfterSignup(user, ctx); + String token = generateVerificationRecord(user); + Body body = getVerifyEmailMailingBodyAfterSignup(token, user, ctx); + sendMail(subject, body, getEmailName(user)); + } + + private String getEmailName(User user) { + return getEmailName(user.getEmail(), user.getName()); + } +} diff --git a/samples/java/hibernate/app/providers/MyUsernamePasswordAuthUser.java b/samples/java/hibernate/app/providers/MyUsernamePasswordAuthUser.java new file mode 100644 index 00000000..cb340e89 --- /dev/null +++ b/samples/java/hibernate/app/providers/MyUsernamePasswordAuthUser.java @@ -0,0 +1,35 @@ +package providers; + +import providers.MyUsernamePasswordAuthProvider.MySignup; + +import com.feth.play.module.pa.providers.password.UsernamePasswordAuthUser; +import com.feth.play.module.pa.user.NameIdentity; + +public class MyUsernamePasswordAuthUser extends UsernamePasswordAuthUser + implements NameIdentity { + + /** + * + */ + private static final long serialVersionUID = 1L; + private final String name; + + public MyUsernamePasswordAuthUser(MySignup signup) { + super(signup.password, signup.email); + this.name = signup.name; + } + + /** + * Used for password reset only - do not use this to signup a user! + * @param password + */ + public MyUsernamePasswordAuthUser(String password) { + super(password, null); + name = null; + } + + @Override + public String getName() { + return name; + } +} diff --git a/samples/java/hibernate/app/security/MyCustomDeadboltHook.java b/samples/java/hibernate/app/security/MyCustomDeadboltHook.java new file mode 100644 index 00000000..ad8f1742 --- /dev/null +++ b/samples/java/hibernate/app/security/MyCustomDeadboltHook.java @@ -0,0 +1,19 @@ +package security; + +import javax.inject.Singleton; + +import play.api.Configuration; +import play.api.Environment; +import play.api.inject.Binding; +import play.api.inject.Module; +import scala.collection.Seq; +import be.objectify.deadbolt.java.cache.HandlerCache; + +public class MyCustomDeadboltHook extends Module { + + @Override + public Seq> bindings(Environment environment, Configuration configuration) { + return seq(bind(HandlerCache.class).to(MyHandlerCache.class).in(Singleton.class)); + } + +} \ No newline at end of file diff --git a/samples/java/hibernate/app/security/MyDeadboltHandler.java b/samples/java/hibernate/app/security/MyDeadboltHandler.java new file mode 100644 index 00000000..9261300c --- /dev/null +++ b/samples/java/hibernate/app/security/MyDeadboltHandler.java @@ -0,0 +1,86 @@ +package security; + +import java.util.Optional; + +import javax.persistence.EntityManager; + +import models.User; +import play.db.jpa.JPA; +import play.libs.F; +import play.libs.F.Promise; +import play.mvc.Http; +import play.mvc.Result; +import be.objectify.deadbolt.java.AbstractDeadboltHandler; +import be.objectify.deadbolt.java.DynamicResourceHandler; +import be.objectify.deadbolt.core.models.Subject; + +import com.feth.play.module.pa.PlayAuthenticate; +import com.feth.play.module.pa.user.AuthUserIdentity; + +import constants.JpaConstants; +import dao.UserHome; + +public class MyDeadboltHandler extends AbstractDeadboltHandler { + + @Override + public Promise> beforeAuthCheck(Http.Context context) { + if (PlayAuthenticate.isLoggedIn(context.session())) { + // user is logged in + return F.Promise.pure(Optional.empty()); + } else { + // user is not logged in + + // call this if you want to redirect your visitor to the page that + // was requested before sending him to the login page + // if you don't call this, the user will get redirected to the page + // defined by your resolver + String originalUrl = PlayAuthenticate + .storeOriginalUrl(context); + + context.flash().put("error", + "You need to log in first, to view '" + originalUrl + "'"); + return F.Promise.promise(new F.Function0>() + { + @Override + public Optional apply() throws Throwable + { + return Optional.ofNullable(redirect(PlayAuthenticate.getResolver().login())); + } + }); + } + } + + @Override + public Promise> getSubject(Http.Context context) { + EntityManager em = JPA.em(JpaConstants.DB); + + AuthUserIdentity u = PlayAuthenticate.getUser(context); + + UserHome userDao = new UserHome(); + User user = userDao.findByAuthUserIdentity(u, em); + + em.close(); + // Caching might be a good idea here + return F.Promise.pure(Optional.ofNullable((Subject)user)); + } + + @Override + public Promise> getDynamicResourceHandler(Http.Context context) { + return Promise.pure(Optional.empty()); + } + + @Override + public F.Promise onAuthFailure(Http.Context context, String content) { + // if the user has a cookie with a valid user and the local user has + // been deactivated/deleted in between, it is possible that this gets + // shown. You might want to consider to sign the user out in this case. + return F.Promise.promise(new F.Function0() + { + @Override + public Result apply() throws Throwable + { + return forbidden("Forbidden"); + } + }); + } +} diff --git a/samples/java/hibernate/app/security/MyHandlerCache.java b/samples/java/hibernate/app/security/MyHandlerCache.java new file mode 100644 index 00000000..abd0719d --- /dev/null +++ b/samples/java/hibernate/app/security/MyHandlerCache.java @@ -0,0 +1,22 @@ +package security; + +import javax.inject.Singleton; + +import be.objectify.deadbolt.java.DeadboltHandler; +import be.objectify.deadbolt.java.cache.HandlerCache; + +@Singleton +public class MyHandlerCache implements HandlerCache { + + private final DeadboltHandler defaultHandler = new MyDeadboltHandler(); + + @Override + public DeadboltHandler apply(String key) { + return this.defaultHandler; + } + + @Override + public DeadboltHandler get() { + return this.defaultHandler; + } +} \ No newline at end of file diff --git a/samples/java/hibernate/app/service/HibernateUserServicePlugin.java b/samples/java/hibernate/app/service/HibernateUserServicePlugin.java new file mode 100644 index 00000000..6465415e --- /dev/null +++ b/samples/java/hibernate/app/service/HibernateUserServicePlugin.java @@ -0,0 +1,105 @@ +package service; + +import java.util.Date; + +import javax.persistence.EntityManager; + +import models.User; +import play.Application; +import play.db.jpa.JPA; + +import com.feth.play.module.pa.user.AuthUser; +import com.feth.play.module.pa.user.AuthUserIdentity; +import com.feth.play.module.pa.service.UserServicePlugin; +import com.google.inject.Inject; + +import constants.JpaConstants; +import dao.UserHome; + +public class HibernateUserServicePlugin extends UserServicePlugin { + + @Inject + public HibernateUserServicePlugin(Application app) { + super(app); + } + + @Override + public Object save(AuthUser authUser) { + + EntityManager em = JPA.em(JpaConstants.DB); + + UserHome userDao = new UserHome(); + + boolean isLinked = userDao.existsByAuthUserIdentity(authUser, em); + if (!isLinked) { + Integer userId = userDao.create(authUser, em).getId(); + + em.close(); + return userId; + } else { + // we have this user already, so return null + em.close(); + return null; + } + } + + @Override + public Object getLocalIdentity(AuthUserIdentity identity) { + EntityManager em = JPA.em(JpaConstants.DB); + + // For production: Caching might be a good idea here... + // ...and dont forget to sync the cache when users get deactivated/deleted + UserHome userDao = new UserHome(); + + User u = userDao.findByAuthUserIdentity(identity, em); + em.close(); + if(u != null) { + return u.getId(); + } else { + return null; + } + } + + @Override + public AuthUser merge(AuthUser newUser, AuthUser oldUser) { + + EntityManager em = JPA.em(JpaConstants.DB); + + UserHome userDao = new UserHome(); + if (!oldUser.equals(newUser)) { + userDao.merge(oldUser, newUser, em); + } + + em.close(); + return oldUser; + } + + @Override + public AuthUser link(AuthUser oldUser, AuthUser newUser) { + + EntityManager em = JPA.em(JpaConstants.DB); + + UserHome userDao = new UserHome(); + + userDao.addLinkedAccount(oldUser, newUser, em); + + em.close(); + return newUser; + } + + @Override + public AuthUser update(AuthUser knownUser) { + EntityManager em = JPA.em(JpaConstants.DB); + + // User logged in again, bump last login date + UserHome userDao = new UserHome(); + + User u = userDao.findByAuthUserIdentity(knownUser, em); + u.setLastLogin(new Date()); + userDao.merge(u, em); + + em.close(); + return knownUser; + } + +} diff --git a/samples/java/hibernate/app/views/_emailPartial.scala.html b/samples/java/hibernate/app/views/_emailPartial.scala.html new file mode 100644 index 00000000..94d3f37d --- /dev/null +++ b/samples/java/hibernate/app/views/_emailPartial.scala.html @@ -0,0 +1,10 @@ +@(f: Form[_], constraints: Boolean = false) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + +@inputText( + f("email"), + '_showConstraints -> constraints, + '_label -> Messages("playauthenticate.login.email.placeholder") +) diff --git a/samples/java/hibernate/app/views/_passwordPartial.scala.html b/samples/java/hibernate/app/views/_passwordPartial.scala.html new file mode 100644 index 00000000..14de81cd --- /dev/null +++ b/samples/java/hibernate/app/views/_passwordPartial.scala.html @@ -0,0 +1,16 @@ +@(f: Form[_]) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + + @inputPassword( + f("password"), + '_label -> Messages("playauthenticate.login.password.placeholder") + ) + + @inputPassword( + f("repeatPassword"), + '_label -> Messages("playauthenticate.login.password.repeat"), + '_showConstraints -> false, + '_error -> f.error("password") + ) diff --git a/samples/java/hibernate/app/views/_providerIcon.scala.html b/samples/java/hibernate/app/views/_providerIcon.scala.html new file mode 100644 index 00000000..f2875976 --- /dev/null +++ b/samples/java/hibernate/app/views/_providerIcon.scala.html @@ -0,0 +1,2 @@ +@(providerKey: String) +@providerKey icon \ No newline at end of file diff --git a/samples/java/hibernate/app/views/_providerPartial.scala.html b/samples/java/hibernate/app/views/_providerPartial.scala.html new file mode 100644 index 00000000..c36559eb --- /dev/null +++ b/samples/java/hibernate/app/views/_providerPartial.scala.html @@ -0,0 +1,24 @@ +@(skipCurrent: Boolean = true) + +@import com.feth.play.module.pa.views.html._ + + + \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/ask_link.scala.html b/samples/java/hibernate/app/views/account/ask_link.scala.html new file mode 100644 index 00000000..316f07ef --- /dev/null +++ b/samples/java/hibernate/app/views/account/ask_link.scala.html @@ -0,0 +1,35 @@ +@(acceptForm: Form[Account.Accept], newAccount: com.feth.play.module.pa.user.AuthUser) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + +@label = { + @_providerIcon(newAccount.getProvider()) @Messages("playauthenticate.link.account.question",newAccount) +} + +@main(Messages("playauthenticate.link.account.title")) { + +

@Messages("playauthenticate.link.account.title")

+

+ @form(routes.Account.doLink, 'class -> "form-horizontal", 'role -> "form") { + + @if(acceptForm.hasGlobalErrors) { +

+ @acceptForm.globalError.message +

+ } + + @inputRadioGroup( + acceptForm("accept"), + options = Seq( + "true"-> Messages("playauthenticate.link.account.true"), + "false"->Messages("playauthenticate.link.account.false") + ), + '_label -> label, + '_showConstraints -> false + ) + + + } +

+} diff --git a/samples/java/hibernate/app/views/account/ask_merge.scala.html b/samples/java/hibernate/app/views/account/ask_merge.scala.html new file mode 100644 index 00000000..5e6970ac --- /dev/null +++ b/samples/java/hibernate/app/views/account/ask_merge.scala.html @@ -0,0 +1,35 @@ +@(acceptForm: Form[Account.Accept], aUser: com.feth.play.module.pa.user.AuthUser, bUser: com.feth.play.module.pa.user.AuthUser) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + +@label = { + @Messages("playauthenticate.merge.accounts.question",aUser,bUser) +} + +@main(Messages("playauthenticate.merge.accounts.title")) { + +

@Messages("playauthenticate.merge.accounts.title")

+

+ @form(routes.Account.doMerge, 'class -> "form-horizontal", 'role -> "form") { + + @if(acceptForm.hasGlobalErrors) { +

+ @acceptForm.globalError.message +

+ } + + @inputRadioGroup( + acceptForm("accept"), + options = Seq( + "true"-> Messages("playauthenticate.merge.accounts.true"), + "false"->Messages("playauthenticate.merge.accounts.false") + ), + '_label -> label, + '_showConstraints -> false + ) + + + } +

+} diff --git a/samples/java/hibernate/app/views/account/email/password_reset_de.scala.html b/samples/java/hibernate/app/views/account/email/password_reset_de.scala.html new file mode 100644 index 00000000..34a3e7d8 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_de.scala.html @@ -0,0 +1,15 @@ +@(url: String, token: String, name: String, email: String) +Hey @name, +
+
+

+ du oder jemand anderes hat die Möglichkeit zum Zurücksetzen deines Passwortes genutzt.
+ Falls dies nicht du selbst oder deine Absicht war, kannst du diese E-Mail einfach ignorieren.
+

+

+ Falls du dein Passwort zurücksetzen möchtest, musst du nur diesem Link folgen. +

+

+ Grüße,
+ Das PlayAuthenticate-Team +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/password_reset_de.scala.txt b/samples/java/hibernate/app/views/account/email/password_reset_de.scala.txt new file mode 100644 index 00000000..bb4612b1 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_de.scala.txt @@ -0,0 +1,12 @@ +@(url: String, token: String, name: String, email: String)Hey @name, + + +du oder jemand anderes hat die Möglichkeit zum Zurücksetzen deines Passwortes genutzt. +Falls dies nicht du selbst oder deine Absicht war, kannst du diese E-Mail einfach ignorieren. + +Falls du dein Passwort zurücksetzen möchtest, musst du nur diesem Link folgen: + +@url + +Grüße, +Das PlayAuthenticate-Team \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/password_reset_en.scala.html b/samples/java/hibernate/app/views/account/email/password_reset_en.scala.html new file mode 100644 index 00000000..d0a5a0e4 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_en.scala.html @@ -0,0 +1,15 @@ +@(url: String, token: String, name: String, email: String) +Howdy @name, +
+
+

+ You or someone else requested a password reset for your account.
+ If that was not you or your intention, just relax and ignore this email.
+

+

+ If you wish to reset your password, all you need to do is follow this link to reset your password. +

+

+ Cheers,
+ The PlayAuthenticate Team +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/password_reset_en.scala.txt b/samples/java/hibernate/app/views/account/email/password_reset_en.scala.txt new file mode 100644 index 00000000..c5f9677c --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_en.scala.txt @@ -0,0 +1,11 @@ +@(url: String, token: String, name: String, email: String)Howdy @name, + + +You or someone else requested a password reset for your account. +If this was not you or your intention, just relax and ignore this email. + +If you wish to reset your password, all you need to do is follow this link to reset your password: +@url + +Cheers, +The PlayAuthenticate Team \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/password_reset_es.scala.html b/samples/java/hibernate/app/views/account/email/password_reset_es.scala.html new file mode 100644 index 00000000..d98750e6 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_es.scala.html @@ -0,0 +1,16 @@ +@(url: String, token: String, name: String, email: String) +Hola @name, +
+
+

+Alguien ha solicitado restablecer la contraseña de su cuenta.
+Si no ha sido Usted o si no ha sido esta su intención, relájese e ignore este email.
+

+

+Si lo que quiere es cambiar su contraseña, lo único que necesita hacer es seguir este enlace para restablecer su contraseña. +

+ +

+Atentamente,
+El equipo de PlayAuthenticate +

diff --git a/samples/java/hibernate/app/views/account/email/password_reset_es.scala.txt b/samples/java/hibernate/app/views/account/email/password_reset_es.scala.txt new file mode 100644 index 00000000..a33039b6 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_es.scala.txt @@ -0,0 +1,11 @@ +@(url: String, token: String, name: String, email: String)Hola @name, + + +Alguien ha solicitado restablecer la contraseña de su cuenta. +Si no ha sido Usted o si no ha sido esta su intención, relájese e ignore este email. + +Si lo que quiere es cambiar su contraseña, lo único que necesita hacer es seguir el siguiente enlace: +@url + +Atentamente, +El equipo de PlayAuthenticate diff --git a/samples/java/hibernate/app/views/account/email/password_reset_pl.scala.html b/samples/java/hibernate/app/views/account/email/password_reset_pl.scala.html new file mode 100644 index 00000000..653ae59e --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_pl.scala.html @@ -0,0 +1,15 @@ +@(url: String, token: String, name: String, email: String) +Cześć @name, +
+
+

+ Poproszono o zmianę hasła dla Twojego konta.
+ Jeśli to nie Ty, zrelaksuj się i zignoruj tę wiadomość.
+

+

+ Jeśli jednak naprawdę chcesz zmienić hasło skorzystaj z tego linku aby to zrobić. +

+

+ Pozdrawiamy,
+ Ekipa PlayAuthenticate +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/password_reset_pl.scala.txt b/samples/java/hibernate/app/views/account/email/password_reset_pl.scala.txt new file mode 100644 index 00000000..5c032da0 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_pl.scala.txt @@ -0,0 +1,11 @@ +@(url: String, token: String, name: String, email: String)Cześć @name, + + +Poproszono o zmianę hasła dla Twojego konta. +Jeśli to nie Ty, zrelaksuj się i zignoruj tę wiadomość. + +Jeśli jednak naprawdę chcesz zmienić hasło skorzystaj z tego linku aby to zrobić: +@url + +Pozdrawiamy, +Ekipa PlayAuthenticate \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/password_reset_pt.scala.html b/samples/java/hibernate/app/views/account/email/password_reset_pt.scala.html new file mode 100644 index 00000000..6c2ad758 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_pt.scala.html @@ -0,0 +1,15 @@ +@(url: String, token: String, name: String, email: String) +Olá @name, +
+
+

+ Você ou alguém pediu uma nova palavra passe para a sua conta.
+ Se não foi você ou não foi sua intenção, pode ignorar esta mensagem.
+

+

+ Se deseja uma nova palavra passe, terá somente que seguir este endereço para criar uma nova palavra passe. +

+

+ Obrigado,
+ A equipa do PlayAuthenticate +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/password_reset_pt.scala.txt b/samples/java/hibernate/app/views/account/email/password_reset_pt.scala.txt new file mode 100644 index 00000000..16829e65 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/password_reset_pt.scala.txt @@ -0,0 +1,11 @@ +@(url: String, token: String, name: String, email: String)Olá @name, + + +Você ou alguém pediu uma nova palavra passe para a sua conta. +Se não foi você ou não foi sua intenção, pode ignorar esta mensagem. + +Se deseja uma nova palavra passe, terá somente que seguir este endereço para criar uma nova palavra passe: +@url + +Obrigado, +A equipa do PlayAuthenticate \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_de.scala.html b/samples/java/hibernate/app/views/account/email/verify_email_de.scala.html new file mode 100644 index 00000000..d8c89b19 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_de.scala.html @@ -0,0 +1,12 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Hey @name, +
+
+

+ um deine E-Mail-Adresse zu bestätigen, folge einfach diesem Link. +

+
+

+ Grüße,
+ Das PlayAuthenticate-Team +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_de.scala.txt b/samples/java/hibernate/app/views/account/email/verify_email_de.scala.txt new file mode 100644 index 00000000..11831840 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_de.scala.txt @@ -0,0 +1,9 @@ +@(verificationUrl: String, token: String, name: String, email: String)Hey @name, + + +um deine E-Mail-Adresse zu bestätigen, folge einfach diesem Link: + +@verificationUrl + +Grüße, +Das PlayAuthenticate-Team \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_en.scala.html b/samples/java/hibernate/app/views/account/email/verify_email_en.scala.html new file mode 100644 index 00000000..6d7edba1 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_en.scala.html @@ -0,0 +1,12 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Howdy @name, +
+
+

+ To verify your e-mail address, now follow this link. +

+
+

+ Cheers,
+ The PlayAuthenticate Team +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_en.scala.txt b/samples/java/hibernate/app/views/account/email/verify_email_en.scala.txt new file mode 100644 index 00000000..26eae219 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_en.scala.txt @@ -0,0 +1,8 @@ +@(verificationUrl: String, token: String, name: String, email: String)Howdy @name, + + +To verify your e-mail address, follow this link now: +@verificationUrl + +Cheers, +The PlayAuthenticate Team \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_es.scala.html b/samples/java/hibernate/app/views/account/email/verify_email_es.scala.html new file mode 100644 index 00000000..e4042d83 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_es.scala.html @@ -0,0 +1,12 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Hola @name, +
+
+

+ Para validar su email siga el siguiente enlace. +

+
+

+ Le saluda,
+ El equipo de PlayAuthenticate +

diff --git a/samples/java/hibernate/app/views/account/email/verify_email_es.scala.txt b/samples/java/hibernate/app/views/account/email/verify_email_es.scala.txt new file mode 100644 index 00000000..04793af6 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_es.scala.txt @@ -0,0 +1,8 @@ +@(verificationUrl: String, token: String, name: String, email: String)Hola @name, + + +Para validar su email siga el siguiente enlace: +@verificationUrl + +Le saluda, +El equipo de PlayAuthenticate. diff --git a/samples/java/hibernate/app/views/account/email/verify_email_pl.scala.html b/samples/java/hibernate/app/views/account/email/verify_email_pl.scala.html new file mode 100644 index 00000000..da566b1b --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_pl.scala.html @@ -0,0 +1,12 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Cześć @name, +
+
+

+ Aby zweryfikować konto, użyj ten link. +

+
+

+ Pozdrawiamy,
+ Ekipa PlayAuthenticate +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_pl.scala.txt b/samples/java/hibernate/app/views/account/email/verify_email_pl.scala.txt new file mode 100644 index 00000000..5dcf9b00 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_pl.scala.txt @@ -0,0 +1,8 @@ +@(verificationUrl: String, token: String, name: String, email: String)Cześć @name, + + +Aby zweryfikować konto, użyj ten link +@verificationUrl + +Pozdrawiamy, +Ekipa PlayAuthenticate \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_pt.scala.html b/samples/java/hibernate/app/views/account/email/verify_email_pt.scala.html new file mode 100644 index 00000000..658a6be2 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_pt.scala.html @@ -0,0 +1,12 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Olá @name, +
+
+

+ Para verificar o seu endereço de email, siga esta ligação. +

+
+

+ Obrigado,
+ A equipa do PlayAuthenticate +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/email/verify_email_pt.scala.txt b/samples/java/hibernate/app/views/account/email/verify_email_pt.scala.txt new file mode 100644 index 00000000..ee1305f5 --- /dev/null +++ b/samples/java/hibernate/app/views/account/email/verify_email_pt.scala.txt @@ -0,0 +1,8 @@ +@(verificationUrl: String, token: String, name: String, email: String)Olá @name, + + +Para verificar o seu endereço de email, siga esta ligação agora: +@verificationUrl + +Obrigado, +A equipa do PlayAuthenticate \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/link.scala.html b/samples/java/hibernate/app/views/account/link.scala.html new file mode 100644 index 00000000..c14f97af --- /dev/null +++ b/samples/java/hibernate/app/views/account/link.scala.html @@ -0,0 +1,10 @@ + +@main(Messages("playauthenticate.link.account.title")) { + +

@Messages("playauthenticate.link.account.title")

+ +

+ @_providerPartial() +
+

+} diff --git a/samples/java/hibernate/app/views/account/password_change.scala.html b/samples/java/hibernate/app/views/account/password_change.scala.html new file mode 100644 index 00000000..e0bf3230 --- /dev/null +++ b/samples/java/hibernate/app/views/account/password_change.scala.html @@ -0,0 +1,23 @@ +@(changeForm: Form[controllers.Account.PasswordChange]) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + +@main(Messages("playauthenticate.change.password.title")) { + +

@Messages("playauthenticate.change.password.title")

+

+ @form(routes.Account.doChangePassword, 'class -> "form-inline", 'role -> "form") { + + @if(changeForm.hasGlobalErrors) { +

+ @changeForm.globalError.message +

+ } + + @_passwordPartial(changeForm) + + + } +

+} diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_de.scala.html b/samples/java/hibernate/app/views/account/signup/email/verify_email_de.scala.html new file mode 100644 index 00000000..67f7cfc0 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_de.scala.html @@ -0,0 +1,14 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Hey @name, +
+
+

+ Du hast dich kürzlich bei PlayAuthenticate registriert.
+
+ Folge diesem Link um dein Konto jetzt zu aktivieren. +

+
+

+ Grüße,
+ Das PlayAuthenticate-Team +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_de.scala.txt b/samples/java/hibernate/app/views/account/signup/email/verify_email_de.scala.txt new file mode 100644 index 00000000..fa24072f --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_de.scala.txt @@ -0,0 +1,11 @@ +@(verificationUrl: String, token: String, name: String, email: String)Hey @name, + + +Du hast dich kürzlich bei PlayAuthenticate registriert. + +Folge diesem Link um dein Konto jetzt zu aktivieren: + +@verificationUrl + +Grüße, +Das PlayAuthenticate-Team \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_en.scala.html b/samples/java/hibernate/app/views/account/signup/email/verify_email_en.scala.html new file mode 100644 index 00000000..86852648 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_en.scala.html @@ -0,0 +1,14 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Howdy @name, +
+
+

+ You recently signed up for PlayAuthenticate.
+
+ Follow this link to activate your account now. +

+
+

+ Cheers,
+ The PlayAuthenticate Team +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_en.scala.txt b/samples/java/hibernate/app/views/account/signup/email/verify_email_en.scala.txt new file mode 100644 index 00000000..22c989f6 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_en.scala.txt @@ -0,0 +1,10 @@ +@(verificationUrl: String, token: String, name: String, email: String)Howdy @name, + + +You recently signed up for PlayAuthenticate. + +To activate your account, follow this link now: +@verificationUrl + +Cheers, +The PlayAuthenticate Team \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_es.scala.html b/samples/java/hibernate/app/views/account/signup/email/verify_email_es.scala.html new file mode 100644 index 00000000..2fc83c1d --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_es.scala.html @@ -0,0 +1,14 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Hola @name, +
+
+

+ Se acaba de apuntar a PlayAuthenticate.
+
+ Siga el siguiente enlace para activar su cuenta. +

+
+

+ Saludos,
+ El equipo de PlayAuthenticate +

diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_es.scala.txt b/samples/java/hibernate/app/views/account/signup/email/verify_email_es.scala.txt new file mode 100644 index 00000000..d9eb4cb4 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_es.scala.txt @@ -0,0 +1,10 @@ +@(verificationUrl: String, token: String, name: String, email: String)Hola @name, + + +Se acaba de apuntar a PlayAuthenticate. + +Siga el siguiente enlace para activar su cuenta: +@verificationUrl + +Saludos, +El equipo de PlayAuthenticate. diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_pl.scala.html b/samples/java/hibernate/app/views/account/signup/email/verify_email_pl.scala.html new file mode 100644 index 00000000..270fae5c --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_pl.scala.html @@ -0,0 +1,14 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Cześć @name, +
+
+

+ Twoje konto w PlayAuthenticate zostało utworzone.
+
+ Użyj ten link, aby je aktywować natychmiast. +

+
+

+ Pozdrawiamy,
+ Ekipa PlayAuthenticate +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_pl.scala.txt b/samples/java/hibernate/app/views/account/signup/email/verify_email_pl.scala.txt new file mode 100644 index 00000000..dcafe321 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_pl.scala.txt @@ -0,0 +1,10 @@ +@(verificationUrl: String, token: String, name: String, email: String)Cześć @name, + + +Twoje konto w PlayAuthenticate zostało utworzone. + +Aby je aktywować, użyj ten link +@verificationUrl + +Pozdrawiamy, +Ekipa PlayAuthenticate \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_pt.scala.html b/samples/java/hibernate/app/views/account/signup/email/verify_email_pt.scala.html new file mode 100644 index 00000000..e961d7d1 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_pt.scala.html @@ -0,0 +1,14 @@ +@(verificationUrl: String, token: String, name: String, email: String) +Olá @name, +
+
+

+ Recentemente registou-se no PlayAuthenticate.
+
+ Siga esta ligação para activar a sua conta agora. +

+
+

+ Obrigado,
+ A equipa do PlayAuthenticate +

\ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/email/verify_email_pt.scala.txt b/samples/java/hibernate/app/views/account/signup/email/verify_email_pt.scala.txt new file mode 100644 index 00000000..58c2baec --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/email/verify_email_pt.scala.txt @@ -0,0 +1,10 @@ +@(verificationUrl: String, token: String, name: String, email: String)Olá @name, + + +Recentemente registou-se no PlayAuthenticate. + +Siga esta ligação para activar a sua conta agora: +@verificationUrl + +Obrigado, +A equipa do PlayAuthenticate \ No newline at end of file diff --git a/samples/java/hibernate/app/views/account/signup/exists.scala.html b/samples/java/hibernate/app/views/account/signup/exists.scala.html new file mode 100644 index 00000000..822f4d63 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/exists.scala.html @@ -0,0 +1,5 @@ + +@main(Messages("playauthenticate.user.exists.title")) { +

@Messages("playauthenticate.user.exists.title")

+

@Messages("playauthenticate.user.exists.message")

+} diff --git a/samples/java/hibernate/app/views/account/signup/no_token_or_invalid.scala.html b/samples/java/hibernate/app/views/account/signup/no_token_or_invalid.scala.html new file mode 100644 index 00000000..98b28d62 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/no_token_or_invalid.scala.html @@ -0,0 +1,5 @@ + +@main(Messages("playauthenticate.token.error.title")) { +

@Messages("playauthenticate.token.error.title")

+

@Messages("playauthenticate.token.error.message")

+} diff --git a/samples/java/hibernate/app/views/account/signup/oAuthDenied.scala.html b/samples/java/hibernate/app/views/account/signup/oAuthDenied.scala.html new file mode 100644 index 00000000..24510393 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/oAuthDenied.scala.html @@ -0,0 +1,11 @@ +@(providerKey: String) + +@main(Messages("playauthenticate.oauth.access.denied.title")) { + +

@Messages("playauthenticate.oauth.access.denied.title")

+

+ @Messages("playauthenticate.oauth.access.denied.explanation")
+

+

+ @Messages("playauthenticate.oauth.access.denied.alternative") @Messages("playauthenticate.oauth.access.denied.alternative.cta"). +} diff --git a/samples/java/hibernate/app/views/account/signup/password_forgot.scala.html b/samples/java/hibernate/app/views/account/signup/password_forgot.scala.html new file mode 100644 index 00000000..8aef3210 --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/password_forgot.scala.html @@ -0,0 +1,23 @@ +@(emailForm: Form[providers.MyUsernamePasswordAuthProvider.MyIdentity]) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + +@main(Messages("playauthenticate.password.forgot.title")) { + +

@Messages("playauthenticate.password.forgot.title")

+

+ @form(routes.Signup.doForgotPassword, 'class -> "form-inline", 'role -> "form") { + + @if(emailForm.hasGlobalErrors) { +

+ @emailForm.globalError.message +

+ } + + @_emailPartial(emailForm) + + + } +

+} diff --git a/samples/java/hibernate/app/views/account/signup/password_reset.scala.html b/samples/java/hibernate/app/views/account/signup/password_reset.scala.html new file mode 100644 index 00000000..a35ab65e --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/password_reset.scala.html @@ -0,0 +1,33 @@ +@(resetForm: Form[controllers.Signup.PasswordReset]) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + +@main(Messages("playauthenticate.password.reset.title")) { + +

@Messages("playauthenticate.password.reset.title")

+

+ @form(routes.Signup.doResetPassword, 'class -> "form-horizontal", 'role -> "form") { + + @if(resetForm.hasGlobalErrors) { + +

+ @resetForm.globalError.message +

+ } + + @input( + resetForm("token"), + '_label -> "", + '_showConstraints -> false + + ) { (id, name, value, args) => + + } + + @_passwordPartial(resetForm) + + + } +

+} diff --git a/samples/java/hibernate/app/views/account/signup/unverified.scala.html b/samples/java/hibernate/app/views/account/signup/unverified.scala.html new file mode 100644 index 00000000..54593c9f --- /dev/null +++ b/samples/java/hibernate/app/views/account/signup/unverified.scala.html @@ -0,0 +1,10 @@ +@main(Messages("playauthenticate.verify.email.title")) { + +

@Messages("playauthenticate.verify.email.title")

+

+ @Messages("playauthenticate.verify.email.requirement")
+ @Messages("playauthenticate.verify.email.cta") +
+ +

+} diff --git a/samples/java/hibernate/app/views/account/unverified.scala.html b/samples/java/hibernate/app/views/account/unverified.scala.html new file mode 100644 index 00000000..393bd956 --- /dev/null +++ b/samples/java/hibernate/app/views/account/unverified.scala.html @@ -0,0 +1,7 @@ +@main(Messages("playauthenticate.verify.account.title")) { + +

@Messages("playauthenticate.verify.account.title")

+

+ @Messages("playauthenticate.verify.account.before") @Messages("playauthenticate.verify.account.first").
+

+} diff --git a/samples/java/hibernate/app/views/index.scala.html b/samples/java/hibernate/app/views/index.scala.html new file mode 100644 index 00000000..6a00a1bb --- /dev/null +++ b/samples/java/hibernate/app/views/index.scala.html @@ -0,0 +1,27 @@ + +@main(Messages("playauthenticate.index.title")) { + +
+

@Messages("playauthenticate.index.intro")

+

@Messages("playauthenticate.index.intro_2")
@Messages("playauthenticate.index.intro_3")

+
+ + +
+
+

@Messages("playauthenticate.index.heading")

+

Cupcake ipsum dolor sit amet. Pastry pie powder biscuit bear claw. Jelly-o chocolate bar sweet roll sugar plum chocolate. Biscuit brownie chupa chups macaroon ice cream halvah sugar plum oat cake ice cream.

+

@Messages("playauthenticate.index.details") »

+
+
+

@Messages("playauthenticate.index.heading")

+

Applicake macaroon caramels gummi bears pastry. Cake liquorice carrot cake chocolate lollipop dessert. Halvah fruitcake marshmallow pie gummi bears pie marzipan.

+

@Messages("playauthenticate.index.details") »

+
+
+

@Messages("playauthenticate.index.heading")

+

Wafer halvah jujubes lollipop liquorice jelly-o pastry. Pie halvah toffee. Candy canes donut sugar plum. Chocolate cake powder tart liquorice cotton candy pudding sweet.

+

@Messages("playauthenticate.index.details") »

+
+
+ } diff --git a/samples/java/hibernate/app/views/login.scala.html b/samples/java/hibernate/app/views/login.scala.html new file mode 100644 index 00000000..d293456f --- /dev/null +++ b/samples/java/hibernate/app/views/login.scala.html @@ -0,0 +1,57 @@ +@(loginForm: Form[_]) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } +@import com.feth.play.module.pa.views.html._ + +@main(Messages("playauthenticate.login.title"),"login") { + +
+
+

@Messages("playauthenticate.login.title")

+
+
+ +
+ +
+ @* Display proprietary login form *@ + @helper.form(routes.Application.doLogin, 'class -> "form-horizontal", 'role -> "form") { + + @if(loginForm.hasGlobalErrors) { +

+ @loginForm.globalError.message +

+ } + + @_emailPartial(loginForm) + + @inputPassword( + loginForm("password"), + '_showConstraints -> false, + '_label -> Messages("playauthenticate.login.password.placeholder") + ) + + + + @Messages("playauthenticate.login.forgot.password") + + } +
+ +
+ @Messages("playauthenticate.login.oauth") + @* Display list of available providers *@ + @_providerPartial(skipCurrent=false) + @providerAvailable("basic") { available: Boolean => + @if(available) { +
+ @Messages("playauthenticate.login.basic") + } + } +
+ +
+ +} + diff --git a/samples/java/hibernate/app/views/main.scala.html b/samples/java/hibernate/app/views/main.scala.html new file mode 100644 index 00000000..30f56212 --- /dev/null +++ b/samples/java/hibernate/app/views/main.scala.html @@ -0,0 +1,105 @@ +@(title: String, nav: String = "")(content: Html) + +@import be.objectify.deadbolt.java.views.html._ +@import be.objectify.deadbolt.core.utils.TemplateUtils._ + + + + + @title + + + + + + + + + + + + + + + + + + + +
+ @if(flash.contains(Application.FLASH_ERROR_KEY)) { + + } + @if(flash.contains(Application.FLASH_MESSAGE_KEY)) { + + } + @content + +
+ + +
+ + + diff --git a/samples/java/hibernate/app/views/profile.scala.html b/samples/java/hibernate/app/views/profile.scala.html new file mode 100644 index 00000000..00bca786 --- /dev/null +++ b/samples/java/hibernate/app/views/profile.scala.html @@ -0,0 +1,51 @@ +@(localUser: models.User = null) + +@import com.feth.play.module.pa.views.html._ + +@main(Messages("playauthenticate.profile.title"),"profile") { + +

@Messages("playauthenticate.profile.title")

+

+ Your name is @localUser.getName and your email address is @if(!localUser.getEmail) {<unknown>.} else { + @localUser.getEmail. + + @if(!localUser.getEmailValidated && localUser.getEmail) { + (unverified - click to verify) + } else { + (verified) + } + } +
+ @if(localUser.getFirstName && localUser.getLastName) { + Your first name is @localUser.getFirstName and your last name is @localUser.getLastName +
+ } + @defining(localUser.getProviders()) { providers => + @if(providers.size() > 0) { + @if(providers.size() ==1) { + @Messages("playauthenticate.profile.providers_one") + } else { + @Messages("playauthenticate.profile.providers_many",providers.size().toString()) + } + @for(p <- providers) { + @_providerIcon(p) + } +
+ } + } + +
+ @currentAuth() { auth => + @Messages("playauthenticate.profile.logged") @_providerIcon(auth.getProvider())
+ @if(auth.expires() != -1){ + @Messages("playauthenticate.profile.session", auth.getId(), Application.formatTimestamp(auth.expires())) + } else { + @Messages("playauthenticate.profile.session_endless", auth.getId()) + } + } +
+

+

+} diff --git a/samples/java/hibernate/app/views/restricted.scala.html b/samples/java/hibernate/app/views/restricted.scala.html new file mode 100644 index 00000000..1a150b96 --- /dev/null +++ b/samples/java/hibernate/app/views/restricted.scala.html @@ -0,0 +1,9 @@ +@(localUser: models.User = null) + +@main(Messages("playauthenticate.navigation.restricted"), "restricted") { + +

@Messages("playauthenticate.navigation.restricted")

+

+ @Messages("playauthenticate.restricted.secrets") +

+} diff --git a/samples/java/hibernate/app/views/signup.scala.html b/samples/java/hibernate/app/views/signup.scala.html new file mode 100644 index 00000000..96c7b9a0 --- /dev/null +++ b/samples/java/hibernate/app/views/signup.scala.html @@ -0,0 +1,47 @@ +@(signupForm: Form[_]) + +@import helper._ +@implicitFieldConstructor = @{ FieldConstructor(twitterBootstrapBasic.f) } + +@main(Messages("playauthenticate.signup.title"),"signup") { + +
+
+

@Messages("playauthenticate.signup.title")

+
+
+ +
+ +
+ @* Display proprietary login form *@ + @helper.form(routes.Application.doSignup, 'class -> "form-horizontal", 'role -> "form") { + + @if(signupForm.hasGlobalErrors) { +

+ @signupForm.globalError.message +

+ } + + @inputText( + signupForm("name"), + '_label -> Messages("playauthenticate.signup.name") + ) + + @_emailPartial(signupForm) + + @_passwordPartial(signupForm) + + + } +
+ +
+ @Messages("playauthenticate.signup.oauth") + @* Display list of available providers *@ + @_providerPartial(skipCurrent=false) +
+ +
+ +} diff --git a/samples/java/hibernate/app/views/twitterBootstrapBasic.scala.html b/samples/java/hibernate/app/views/twitterBootstrapBasic.scala.html new file mode 100644 index 00000000..b45c2314 --- /dev/null +++ b/samples/java/hibernate/app/views/twitterBootstrapBasic.scala.html @@ -0,0 +1,17 @@ +@(elements: helper.FieldElements) +
+ +
+
+ @if(elements.input.toString().contains("class=")) { + @Html(elements.input.toString().replaceFirst("(class=[\"'])", "$1form-control ")) + } else { + @Html(elements.input.toString().replaceFirst("(<\\w+ )", "$1class=\"form-control\" ")) + } +
+
+@elements.infos.mkString(", ") +@if(elements.hasErrors) { +@elements.errors.mkString(", ") +} +
diff --git a/samples/java/hibernate/build.sbt b/samples/java/hibernate/build.sbt new file mode 100644 index 00000000..1b30c3d1 --- /dev/null +++ b/samples/java/hibernate/build.sbt @@ -0,0 +1,38 @@ +organization := "com.feth" + +name := "play-authenticate-hibernate" + +scalaVersion := "2.11.6" + +version := "1.0-SNAPSHOT" + +PlayKeys.externalizeResources := true + +val appDependencies = Seq( + javaJpa, + "be.objectify" %% "deadbolt-java" % "2.4.0", + // Comment the next line for local development of the Play Authentication core: + "com.feth" %% "play-authenticate" % "0.7.0-SNAPSHOT", + //"org.postgresql" % "postgresql" % "9.4-1201-jdbc41", + "org.hibernate" % "hibernate-entitymanager" % "4.3.10.Final", + "mysql" % "mysql-connector-java" % "5.1.36", + javaJdbc, + cache, + javaWs, + "org.webjars" % "bootstrap" % "3.2.0", + "org.easytesting" % "fest-assert" % "1.4" % "test" +) + +// add resolver for deadbolt and easymail snapshots +resolvers += Resolver.sonatypeRepo("snapshots") + +routesGenerator := InjectedRoutesGenerator + +// Uncomment the next line for local development of the Play Authenticate core: +//lazy val playAuthenticate = project.in(file("modules/play-authenticate")).enablePlugins(PlayJava) + +lazy val root = project.in(file(".")).enablePlugins(PlayJava).settings(libraryDependencies ++= appDependencies) + + /* Uncomment the next lines for local development of the Play Authenticate core: */ + //.dependsOn(playAuthenticate) + //.aggregate(playAuthenticate) diff --git a/samples/java/hibernate/conf/META-INF/persistence.xml b/samples/java/hibernate/conf/META-INF/persistence.xml new file mode 100644 index 00000000..4a6cbe16 --- /dev/null +++ b/samples/java/hibernate/conf/META-INF/persistence.xml @@ -0,0 +1,16 @@ + + + + org.hibernate.jpa.HibernatePersistenceProvider + DefaultDS + NONE + + + + + + + \ No newline at end of file diff --git a/samples/java/hibernate/conf/application.conf b/samples/java/hibernate/conf/application.conf new file mode 100644 index 00000000..2aecdbd2 --- /dev/null +++ b/samples/java/hibernate/conf/application.conf @@ -0,0 +1,74 @@ +# This is the main configuration file for the application. +# ~~~~~ + +# Modules management +# ~~~~~ +play { + modules { + enabled += "be.objectify.deadbolt.java.DeadboltModule" + enabled += "security.MyCustomDeadboltHook" + } +} + +# Secret key +# ~~~~~ +# The secret key is used to secure cryptographics functions. +# If you deploy your application to several instances be sure to use the same key! +play.crypto.secret="y]Z5;`T0=F3mAda1lW[r5jFWCw9stMiBnShjPU;59l7cwA9LX1abrprOgTP/VCDQ" + +# The application languages +# ~~~~~ +play.i18n.langs = [ "en", "de", "pl", "fr", "es", "ja" ] + +# Global object class +# ~~~~~ +# Define the Global object class for this application. +# Default to Global in the root package. +application.global=Global + +# Router +# ~~~~~ +# Define the Router object to use for this application. +# Default to Routes in the root package. +# application.routers=my.application.Routes + +# Database configuration +# ~~~~~ +# You can declare as many datasources as you want. +# By convention, the default datasource is named `default` +# +# db.default.driver=org.h2.Driver +# db.default.url="jdbc:h2:mem:play" +# db.default.user=sa +# db.default.password= + +db.default.driver=com.mysql.jdbc.Driver +db.default.url="jdbc:mysql://localhost:8889/playauthjpa" +db.default.username=root +db.default.password=root + +# +# You can expose this datasource via JNDI if needed (Useful for JPA) +db.default.jndiName=DefaultDS + +jpa.default=defaultPersistenceUnit + +# +# You can expose this datasource via JNDI if needed (Useful for JPA) +# db.default.jndiName=DefaultDS + +# Ebean configuration +# ~~~~~ +# You can declare as many Ebean servers as you want. +# By convention, the default server is named `default` +# +# ebean.default="models.*" + +# Deadbolt +include "play-authenticate/deadbolt.conf" + +# SMTP +include "play-authenticate/smtp.conf" + +# And play authenticate +include "play-authenticate/mine.conf" diff --git a/samples/java/hibernate/conf/messages.de b/samples/java/hibernate/conf/messages.de new file mode 100644 index 00000000..adf39467 --- /dev/null +++ b/samples/java/hibernate/conf/messages.de @@ -0,0 +1,150 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=Obligatorisch +constraint.min=Minimaler Wert: {0} +constraint.max=Maximaler Wert: {0} +constraint.minLength=Minimale Länge: {0} +constraint.maxLength=Maximale Länge: {0} +constraint.email=E-Mail + +# --- Formats +format.date=Datum (''{0}'') +format.numeric=Numerisch +format.real=Reelle Zahl + +# --- Errors +error.invalid=Wert is unzulässig +error.required=Dieses Feld ist obligatorisch +error.number=Numerischer Wert erwartet +error.real=Reelle Zahl erwartet +error.min=Muss größer oder gleich {0} sein +error.max=Muss kleiner oder gleich {0} sein +error.minLength=Die minimale Länge beträgt {0} +error.maxLength=Die maximale Länge beträgt {0} +error.email=Valide E-Mail-Adresse erforderlich +error.pattern=Muss dem Muster {0} genügen + +### --- play-authenticate START + +playauthenticate.accounts.link.success=Das Konto wurde erfolgreich verknüpft. +playauthenticate.accounts.merge.success=Die Konten wurden erfolgreich zusammengeführt. + +playauthenticate.verify_email.error.already_validated=Deine E-Mail-Adresse wurde bereits verifiziert. +playauthenticate.verify_email.error.set_email_first=Du musst zuerst eine E-Mail-Adresse definieren. +playauthenticate.verify_email.message.instructions_sent=Instruktionen zur Bestätigung deiner E-Mail-Adresse wurden an {0} gesendet. +playauthenticate.verify_email.success=E-Mail-Adresse ({0}) wurde erfolgreich verifiziert. + +playauthenticate.reset_password.message.instructions_sent=Instruktionen zum Zurücksetzen deines Passwortes wurden an {0} versandt. +playauthenticate.reset_password.message.email_not_verified=Deine E-Mail-Adresse wurde noch nicht verifiziert. Instruktionen um deine E-Mail-Adresse zu verifizieren wurden versendet. Versuche danach nochmals dein Passwort zurückzusetzen. +playauthenticate.reset_password.message.no_password_account=Dein Benutzer wurde für die Verwendung eines Passwort-basierten Zugangs noch nicht aktiviert. +playauthenticate.reset_password.message.success.auto_login=Dein Passwort wurde erfolgreich zurückgesetzt. +playauthenticate.reset_password.message.success.manual_login=Dein Passwort wurde erfolgreich zurückgesetzt. Bitte melde dich jetzt mit deinem neuen Passwort an. + +playauthenticate.change_password.error.passwords_not_same=Die Passwörter stimmen nicht überein. +playauthenticate.change_password.success=Das Passwort wurde erfolgreich geändert. + +playauthenticate.password.signup.error.passwords_not_same=Die Passwörter stimmen nicht überein. +playauthenticate.password.login.unknown_user_or_pw=Der Benutzer wurde nicht gefunden oder das Passwort stimmt nicht überein. + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: Vervollständige deine Anmeldung +playauthenticate.password.verify_email.subject=PlayAuthenticate: E-Mail-Adresse bestätigen +playauthenticate.password.reset_email.subject=PlayAuthenticate: Anleitung zum Passwortzurücksetzen + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=Deine E-Mail-Adresse +playauthenticate.login.password.placeholder=Wähle ein Passwort +playauthenticate.login.password.repeat=Wiederhole das gewählte Passwort +playauthenticate.login.title=Anmeldung +playauthenticate.login.password.placeholder=Passwort +playauthenticate.login.now=Jetzt anmelden +playauthenticate.login.forgot.password=Passwort vergessen? +playauthenticate.login.oauth=oder melde dich mit einem der folgenden Dienste an: +playauthenticate.login.basic=oder versuch es mit HTTP basic auth (als example/secret) + +playauthenticate.signup.title=Registrierung +playauthenticate.signup.name=Dein Name +playauthenticate.signup.now=Jetzt registrieren +playauthenticate.signup.oauth=oder registriere dich mit einem der folgenden Dienste: + +playauthenticate.verify.account.title=Verifikation der E-Mail-Adresse erforderlich +playauthenticate.verify.account.before=Bevor du ein Passwort vergeben kannst, +playauthenticate.verify.account.first=musst du zuerst deine E-Mail-Adresse verifizieren + +playauthenticate.change.password.title=Ändere dein Passwort hier +playauthenticate.change.password.cta=Mein Passwort ändern + +playauthenticate.merge.accounts.title=Konten zusammenführen +playauthenticate.merge.accounts.question=Möchtest du dein aktuelles Konto ({0}) mit diesem zusammenführen: {1}? +playauthenticate.merge.accounts.true=Ja, diese Konten zusammenführen +playauthenticate.merge.accounts.false=Nein, meine aktuelle Sizung beenden und mit dem neuen Benutzer anmelden +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=Konto verknüpfen +playauthenticate.link.account.question=Konto ({0}) mit deinem Benutzer verknüpfen? +playauthenticate.link.account.true=Ja, dieses Konto mit meinem Benutzer verknüpfen +playauthenticate.link.account.false=Nein, abmelden und einen neuen Benutzer mit diesem Konto erstellen +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=E-Mail-Adresse bestätigen +playauthenticate.verify.email.requirement=Du musst deine E-Mail-Adresse bestätigen, bevor du PlayAuthenticate nutzen kannst. +playauthenticate.verify.email.cta=Eine E-Mail wurde zur registrierten E-Mail-Adresse versandt. Bitte öffne sie und klicke auf den enthaltenen Link, um deinen Account zu aktivieren. + +playauthenticate.password.reset.title=Passwort zurücksetzen +playauthenticate.password.reset.cta=Passwort zurücksetzen + +playauthenticate.password.forgot.title=Passwort vergessen +playauthenticate.password.forgot.cta=Informationen zum Zurücksetzen versenden + +playauthenticate.oauth.access.denied.title=OAuth-Zugriff abgelehnt +playauthenticate.oauth.access.denied.explanation=Wenn du PlayAuthenticate mit OAuth nutzen möchtest, musst du die Verbindung akzeptieren. +playauthenticate.oauth.access.denied.alternative=Falls du dies lieber nicht tun möchtest, kannst du dich auch +playauthenticate.oauth.access.denied.alternative.cta=mit Benutzername und Passwort registrieren + +playauthenticate.token.error.title=Token-Fehler +playauthenticate.token.error.message=Der Token ist entweder abgelaufen oder existiert nicht. + +playauthenticate.user.exists.title=Benutzer vorhanden +playauthenticate.user.exists.message=Dieser Benutzer existiert bereits. + +# play-authenticate: Navigation +playauthenticate.navigation.profile=Profil +playauthenticate.navigation.link_more=Mehr Zugänge verknüpfen +playauthenticate.navigation.logout=Abmelden +playauthenticate.navigation.login=Anmelden +playauthenticate.navigation.home=Startseite +playauthenticate.navigation.restricted=Geschützte Seite +playauthenticate.navigation.signup=Registrieren + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=Du musst dich zuerst anmelden um ''{0}'' anzuzeigen + + +# play-authenticate: Profile +playauthenticate.profile.title=Benutzerprofil +playauthenticate.profile.mail=Dein Name lautet {0} und deine E-Mail-Adresse ist {1}! +playauthenticate.profile.unverified=unverifiziert - Klicke um zu bestätigen +playauthenticate.profile.verified=verifiziert +playauthenticate.profile.providers_many=Es sind {0} Konten mit deinem Benutzer verknüpft: +playauthenticate.profile.providers_one=Es ist ein Konto mit deinem Benutzer verknüpft: +playauthenticate.profile.logged=Du bist momentan eingeloggt mit: +playauthenticate.profile.session=Deine Benutzer-Identifikation ist {0} und deine Sitzung läuft {1} ab +playauthenticate.profile.session_endless=Deine Benutzer-Identifikation ist {0} und deine Sitzung läuft nie ab +playauthenticate.profile.password_change=Ändere/setze ein Passwort für deinen Benutzer + +# play-authenticate - sample: Index page +playauthenticate.index.title=Willkommen bei PlayAuthenticate +playauthenticate.index.intro=PlayAuthenticate Beispiel-Applikation +playauthenticate.index.intro_2=Dies ist eine Blaupause für eine einfache Applikation mit Authentifikation. +playauthenticate.index.intro_3=Schau dir die Navigation oben an, um einfache Beispielseiten inklusive der unterstützten Authentifikationsmethoden zu sehen. +playauthenticate.index.heading=Überschrift +playauthenticate.index.details=Details anzeigen + +# play-authenticate - sample: Restricted page +playauthenticate.restricted.secrets=Überall Geheimnisse! + + +### --- play-authenticate END \ No newline at end of file diff --git a/samples/java/hibernate/conf/messages.en b/samples/java/hibernate/conf/messages.en new file mode 100644 index 00000000..6008386b --- /dev/null +++ b/samples/java/hibernate/conf/messages.en @@ -0,0 +1,150 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=Required +constraint.min=Minimum value: {0} +constraint.max=Maximum value: {0} +constraint.minLength=Minimum length: {0} +constraint.maxLength=Maximum length: {0} +constraint.email=Email + +# --- Formats +format.date=Date (''{0}'') +format.numeric=Numeric +format.real=Real + +# --- Errors +error.invalid=Invalid value +error.required=This field is required +error.number=Numeric value expected +error.real=Real number value expected +error.min=Must be greater or equal to {0} +error.max=Must be less or equal to {0} +error.minLength=Minimum length is {0} +error.maxLength=Maximum length is {0} +error.email=Valid email required +error.pattern=Must satisfy {0} + +### --- play-authenticate START + +# play-authenticate: Initial translations + +playauthenticate.accounts.link.success=Account linked successfully +playauthenticate.accounts.merge.success=Accounts merged successfully + +playauthenticate.verify_email.error.already_validated=Your e-mail has already been validated. +playauthenticate.verify_email.error.set_email_first=You need to set an e-mail address first. +playauthenticate.verify_email.message.instructions_sent=Instructions on how to verify your e-mail address have been sent to {0}. +playauthenticate.verify_email.success=E-mail address ({0}) successfully verified. + +playauthenticate.reset_password.message.instructions_sent=Instructions on how to reset your password have been sent to {0}. +playauthenticate.reset_password.message.email_not_verified=Your account has not been verified, yet. An e-mail including instructions on how to verify it has been sent out. Retry resetting your password afterwards. +playauthenticate.reset_password.message.no_password_account=Your user has not yet been set up for password usage. +playauthenticate.reset_password.message.success.auto_login=Your password has been reset. +playauthenticate.reset_password.message.success.manual_login=Your password has been reset. Please now log in using your new password. + +playauthenticate.change_password.error.passwords_not_same=Passwords do not match. +playauthenticate.change_password.success=Password has been changed successfully. + +playauthenticate.password.signup.error.passwords_not_same=Passwords do not match. +playauthenticate.password.login.unknown_user_or_pw=Unknown user or password. + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: Complete your signup +playauthenticate.password.verify_email.subject=PlayAuthenticate: Confirm your e-mail address +playauthenticate.password.reset_email.subject=PlayAuthenticate: How to reset your password + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=Your e-mail address +playauthenticate.login.password.placeholder=Choose a password +playauthenticate.login.password.repeat=Repeat chosen password +playauthenticate.login.title=Login +playauthenticate.login.password.placeholder=Password +playauthenticate.login.now=Login now +playauthenticate.login.forgot.password=Forgot your password? +playauthenticate.login.oauth=or log in using one of the following providers: +playauthenticate.login.basic=or try HTTP basic auth (as example/secret) + +playauthenticate.signup.title=Signup +playauthenticate.signup.name=Your name +playauthenticate.signup.now=Sign up now +playauthenticate.signup.oauth=or sign up using one of the following providers: + +playauthenticate.verify.account.title=E-mail verification required +playauthenticate.verify.account.before=Before setting a password, you need to +playauthenticate.verify.account.first=first verify your e-mail address + +playauthenticate.change.password.title=Change your password here +playauthenticate.change.password.cta=Change my password + +playauthenticate.merge.accounts.title=Merge accounts +playauthenticate.merge.accounts.question=Do you want to merge your current account ({0}) with this account: {1}? +playauthenticate.merge.accounts.true=Yes, merge these two accounts +playauthenticate.merge.accounts.false=No, exit my current session and log in as a new user +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=Link account +playauthenticate.link.account.question=Link ({0}) with your user? +playauthenticate.link.account.true=Yes, link this account +playauthenticate.link.account.false=No, log out and create a new user with this account +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=Verify your e-mail +playauthenticate.verify.email.requirement=Before you can use PlayAuthenticate, you first need to verify your e-mail address. +playauthenticate.verify.email.cta=An e-mail has been sent to the registered address. Please follow the embedded link to activate your account. + +playauthenticate.password.reset.title=Reset password +playauthenticate.password.reset.cta=Reset my password + +playauthenticate.password.forgot.title=Forgot password +playauthenticate.password.forgot.cta=Send reset instructions + +playauthenticate.oauth.access.denied.title=OAuth access denied +playauthenticate.oauth.access.denied.explanation=If you want to use PlayAuthenticate with OAuth, you must accept the connection. +playauthenticate.oauth.access.denied.alternative=If you rather not like to do this, you can also +playauthenticate.oauth.access.denied.alternative.cta=sign up with a username and password instead + +playauthenticate.token.error.title=Token error +playauthenticate.token.error.message=The given token has either expired or does not exist. + +playauthenticate.user.exists.title=User exists +playauthenticate.user.exists.message=This user already exists. + +# play-authenticate: Navigation +playauthenticate.navigation.profile=Profile +playauthenticate.navigation.link_more=Link more providers +playauthenticate.navigation.logout=Sign out +playauthenticate.navigation.login=Log in +playauthenticate.navigation.home=Home +playauthenticate.navigation.restricted=Restricted page +playauthenticate.navigation.signup=Sign up + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=You need to log in first, to view ''{0}'' + +# play-authenticate: Profile +playauthenticate.profile.title=User profile +playauthenticate.profile.mail=Your name is {0} and your email address is {1}! +playauthenticate.profile.unverified=unverified - click to verify +playauthenticate.profile.verified=verified +playauthenticate.profile.providers_many=There are {0} providers linked with your account: +playauthenticate.profile.providers_one = There is one provider linked with your account: +playauthenticate.profile.logged=You are currently logged in with: +playauthenticate.profile.session=Your user ID is {0} and your session will expire on {1} +playauthenticate.profile.session_endless=Your user ID is {0} and your session will not expire, as it is endless +playauthenticate.profile.password_change=Change/set a password for your account + +# play-authenticate - sample: Index page +playauthenticate.index.title=Welcome to Play Authenticate +playauthenticate.index.intro=Play Authenticate sample app +playauthenticate.index.intro_2=This is a template for a simple application with authentication. +playauthenticate.index.intro_3=Check the main navigation above for simple page examples including supported authentication features. +playauthenticate.index.heading=Heading +playauthenticate.index.details=View details + +# play-authenticate - sample: Restricted page +playauthenticate.restricted.secrets=Secrets, everywhere! + +### --- play-authenticate END diff --git a/samples/java/hibernate/conf/messages.es b/samples/java/hibernate/conf/messages.es new file mode 100644 index 00000000..432b105c --- /dev/null +++ b/samples/java/hibernate/conf/messages.es @@ -0,0 +1,148 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=Obligatorio +constraint.min=Valor mínimo: {0} +constraint.max=Valor máximo: {0} +constraint.minLength=Longitud mínima: {0} +constraint.maxLength=Longitud máxima: {0} +constraint.email=Email + +# --- Formats +format.date=Date (''{0}'') +format.numeric=Numérico +format.real=Real + +# --- Errors +error.invalid=Valor incorrecto +error.required=Este campo es obligatorio +error.number=Se esperaba un valor numérico +error.real=Se esperaba un numero real +error.min=Debe ser mayor o igual que {0} +error.max=Debe ser menor o igual que {0} +error.minLength=La longitud mínima es de {0} +error.maxLength=La longitud máxima es de {0} +error.email=Se requiere un email válido +error.pattern=Debe satisfacer {0} + +### --- play-authenticate START + +# play-authenticate: Initial translations + +playauthenticate.accounts.link.success=Cuenta enlazada correctamente +playauthenticate.accounts.merge.success=Cuentas unificadas correctamente + +playauthenticate.verify_email.error.already_validated=Su email ya ha sido validado +playauthenticate.verify_email.error.set_email_first=Primero debe dar de alta un email. +playauthenticate.verify_email.message.instructions_sent=Las instrucciones para validar su cuenta han sido enviadas a {0}. +playauthenticate.verify_email.success=La dirección de email ({0}) ha sido verificada correctamente. + +playauthenticate.reset_password.message.instructions_sent=Las instrucciones para restablecer su contraseña han sido enviadas a {0}. +playauthenticate.reset_password.message.email_not_verified=Su cuenta aún no ha sido validada. Se ha enviado un email incluyedo instrucciones para su validación. Intente restablecer la contraseña una vez lo haya recibido. +playauthenticate.reset_password.message.no_password_account=Su usuario todavía no ha sido configurado para utilizar contraseña. +playauthenticate.reset_password.message.success.auto_login=Su contraseña ha sido restablecida. +playauthenticate.reset_password.message.success.manual_login=Su contraseña ha sido restablecida. Intente volver a entrar utilizando su nueva contraseña. + +playauthenticate.change_password.error.passwords_not_same=Las contraseñas no coinciden. +playauthenticate.change_password.success=La contraseña ha sido cambiada correctamente. + +playauthenticate.password.signup.error.passwords_not_same=Las contraseñas no coinciden. +playauthenticate.password.login.unknown_user_or_pw=Usuario o contraseña incorrectos. + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: Complete su registro +playauthenticate.password.verify_email.subject=PlayAuthenticate: Confirme su dirección de email +playauthenticate.password.reset_email.subject=PlayAuthenticate: Cómo restablecer su contraseña + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=Su dirección de email +playauthenticate.login.password.placeholder=Elija una contraseña +playauthenticate.login.password.repeat=Repita la contraseña elegida +playauthenticate.login.title=Entrar +playauthenticate.login.password.placeholder=Contraseña +playauthenticate.login.now=Entrar +playauthenticate.login.forgot.password=¿Olvidó su contraseña? +playauthenticate.login.oauth=entre usando su cuenta con alguno de los siguientes proveedores: + +playauthenticate.signup.title=Registrarse +playauthenticate.signup.name=Su nombre +playauthenticate.signup.now=Regístrese +playauthenticate.signup.oauth=regístrese usando su cuenta con alguno de los siguientes proveedores: + +playauthenticate.verify.account.title=Es necesario validar su email +playauthenticate.verify.account.before=Antes de configurar una contraseña +playauthenticate.verify.account.first=valide su email + +playauthenticate.change.password.title=Cambio de contraseña +playauthenticate.change.password.cta=Cambiar mi contraseña + +playauthenticate.merge.accounts.title=Unir cuentas +playauthenticate.merge.accounts.question=¿Desea unir su cuenta ({0}) con su otra cuenta: {1}? +playauthenticate.merge.accounts.true=Sí, ¡une estas dos cuentas! +playauthenticate.merge.accounts.false=No, quiero abandonar esta sesión y entrar como otro usuario. +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=Enlazar cuenta +playauthenticate.link.account.question=¿Enlazar ({0}) con su usuario? +playauthenticate.link.account.true=Sí, ¡enlaza esta cuenta! +playauthenticate.link.account.false=No, salir y crear un nuevo usuario con esta cuenta +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=Verifique su email +playauthenticate.verify.email.requirement=Antes de usar PlayAuthenticate, debe validar su email. +playauthenticate.verify.email.cta=Se le ha enviado un email a la dirección registrada. Por favor, siga el link de este email para activar su cuenta. +playauthenticate.password.reset.title=Restablecer contraseña +playauthenticate.password.reset.cta=Restablecer mi contraseña + +playauthenticate.password.forgot.title=Contraseña olvidada +playauthenticate.password.forgot.cta=Enviar instrucciones para restablecer la contraseña + +playauthenticate.oauth.access.denied.title=Acceso denegado por OAuth +playauthenticate.oauth.access.denied.explanation=Si quiere usar PlayAuthenticate con OAuth, debe aceptar la conexión. +playauthenticate.oauth.access.denied.alternative=Si prefiere no hacerlo, puede también +playauthenticate.oauth.access.denied.alternative.cta=registrarse con un usuario y una contraseña. + +playauthenticate.token.error.title=Error de token +playauthenticate.token.error.message=El token ha caducado o no existe. + +playauthenticate.user.exists.title=El usuario existe +playauthenticate.user.exists.message=Otro usario ya está dado de alta con este identificador. + +# play-authenticate: Navigation +playauthenticate.navigation.profile=Perfil +playauthenticate.navigation.link_more=Enlazar más proveedores +playauthenticate.navigation.logout=Salir +playauthenticate.navigation.login=Entrar +playauthenticate.navigation.home=Inicio +playauthenticate.navigation.restricted=Página restringida +playauthenticate.navigation.signup=Dárse de alta + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=Para ver ''{0}'', debe darse primero de alta. + +# play-authenticate: Profile +playauthenticate.profile.title=Perfil de usuario +playauthenticate.profile.mail=Su nombre es {0} y su dirección de mail es {1}! +playauthenticate.profile.unverified=sin validar - haga click para validar +playauthenticate.profile.verified=validada +playauthenticate.profile.providers_many=Hay {0} proveedores enlazados con su cuenta: +playauthenticate.profile.providers_one = Hay un proveedor enlazado con su cuenta: +playauthenticate.profile.logged=Ha entrado con: +playauthenticate.profile.session=Su ID de usuario es {0}. Su sesión expirará el {1}. +playauthenticate.profile.session_endless=Su ID de usuario es {0}. Su sesión no expirará nunca porque no tiene caducidad. +playauthenticate.profile.password_change=Cambie/establezca una contraseña para su cuenta + +# play-authenticate - sample: Index page +playauthenticate.index.title=Bienvenido Play Authenticate +playauthenticate.index.intro=Aplicación de ejemplo de Play Authenticate +playauthenticate.index.intro_2=Esto es una plantilla para una sencilla aplicación con autentificación y autorización +playauthenticate.index.intro_3=Mire la barra de navegación superior para ver ejemplos sencillos incluyendo las características soportadas de autentificación. +playauthenticate.index.heading=Cabecera +playauthenticate.index.details=Ver detalles + +# play-authenticate - sample: Restricted page +playauthenticate.restricted.secrets=¡Secretos y más secretos! + +### --- play-authenticate END diff --git a/samples/java/hibernate/conf/messages.fr b/samples/java/hibernate/conf/messages.fr new file mode 100644 index 00000000..78168aa1 --- /dev/null +++ b/samples/java/hibernate/conf/messages.fr @@ -0,0 +1,149 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=Obligatoire +constraint.min=Valeur minimale: {0} +constraint.max=Valeur maximale: {0} +constraint.minLength=Longueur minimale: {0} +constraint.maxLength=Longueur maximale: {0} +constraint.email=Email + +# --- Formats +format.date=Date (''{0}'') +format.numeric=Numérique +format.real=Réel + +# --- Errors +error.invalid=Valeur non autorisée +error.required=Champ obligatoire +error.number=Seul les valeurs numériques sont autorisées +error.real=Seul les valeurs réelles sont autorisées +error.min=Doit être plus grand ou égal à {0} +error.max=Doit être plus petit ou égal à 0} +error.minLength=Longueur minimale: {0} +error.maxLength=Longueur maximale: {0} +error.email=Un email valide est obligatoire +error.pattern=Doit satisfaire: {0} + +### --- play-authenticate START + +# play-authenticate: Initial translations + +playauthenticate.accounts.link.success=Comptes liés avec succès +playauthenticate.accounts.merge.success=Comptes unifiés avec succès + +playauthenticate.verify_email.error.already_validated=Votre email a déjà été validé. +playauthenticate.verify_email.error.set_email_first=Vous devez d'abord fournir un email. +playauthenticate.verify_email.message.instructions_sent=Les instructions pour valider votre email ont été envoyé à l'adresse {0}. +playauthenticate.verify_email.success=L'adresse E-mail ({0}) a été validée avec succès. + +playauthenticate.reset_password.message.instructions_sent=Les instructions pour changer votre mot de passe ont été envoyées à l'adresse: {0}. +playauthenticate.reset_password.message.email_not_verified=Votre email doit d'abord être vérifié, des instructions ont été envoyées. Réessayez ensuite. +playauthenticate.reset_password.message.no_password_account=Votre utilisateur n'est pas configuré pour utiliser un mot de passe. +playauthenticate.reset_password.message.success.auto_login=Votre mot de passe a été changé. +playauthenticate.reset_password.message.success.manual_login=Votre mot de passe a été changé. Veillez vous connecter avec votre nouveau mot de passe. + +playauthenticate.change_password.error.passwords_not_same=Les mots de passe ne correspondent pas. +playauthenticate.change_password.success=Mot de passe changé avec succès. + +playauthenticate.password.signup.error.passwords_not_same=Les mots de passe ne correspondent pas. +playauthenticate.password.login.unknown_user_or_pw=Utilisateur et mot de passe inconnus. + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: Finaliser votre enregistrement +playauthenticate.password.verify_email.subject=PlayAuthenticate: Confirmer votre email +playauthenticate.password.reset_email.subject=PlayAuthenticate: Comment changer votre mot de passe. + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=Votre adresse email +playauthenticate.login.password.placeholder=Choisir un mot de passe +playauthenticate.login.password.repeat=Réitérer votre mot de passe +playauthenticate.login.title=Login +playauthenticate.login.password.placeholder=Mot de passe +playauthenticate.login.now=Se connecter maintenant +playauthenticate.login.forgot.password=Mot de passe oublié? +playauthenticate.login.oauth=ou connectez-vous avec un de ces fournisseurs: + +playauthenticate.signup.title=Enregistrement +playauthenticate.signup.name=Votre nom +playauthenticate.signup.now=S'enregistrer maintenant +playauthenticate.signup.oauth=ou enregistrez-vous avec un de ces fournisseurs: + +playauthenticate.verify.account.title=Vérification par email obligatoire +playauthenticate.verify.account.before=Avant de spécifier un mot de passe, vous devez +playauthenticate.verify.account.first=d'abord vérifier votre email + +playauthenticate.change.password.title=Changer votre mot de passe ici +playauthenticate.change.password.cta=Changer votre mot de passe + +playauthenticate.merge.accounts.title=Unifier des comptes +playauthenticate.merge.accounts.question=Voulez-vous unifier le compte ({0}) avec le compte: {1}? +playauthenticate.merge.accounts.true=Oui, unifier les deux comptes +playauthenticate.merge.accounts.false=Non, quitter la session et se connecter avec un autre compte +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=Lier les comptes +playauthenticate.link.account.question=Lier ({0}) avec votre utilisateur? +playauthenticate.link.account.true=Oui, lier ce compte +playauthenticate.link.account.false=Non, quitter la session et créer un nouveau compte +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=Verifier votre e-mail +playauthenticate.verify.email.requirement=Avant d'utiliser PlayAuthenticate, vous devez d'abord vérifier votre email. +playauthenticate.verify.email.cta=Un email a été envoyé à votre adresse avec des instructions pour vous connecter. + +playauthenticate.password.reset.title=Changer votre mot de passe +playauthenticate.password.reset.cta=Changer votre mot de passe + +playauthenticate.password.forgot.title=Mot de passe oublié +playauthenticate.password.forgot.cta=Envoyer les instructions pour changer le mot de passe + +playauthenticate.oauth.access.denied.title=Accès OAuth refusé +playauthenticate.oauth.access.denied.explanation=Si vous voulez utiliser PlayAuthenticate avec OAuth, vous devez accepter la connexion. +playauthenticate.oauth.access.denied.alternative=Si vous ne préférez pas accepter la connexion, vous pouvez toujours +playauthenticate.oauth.access.denied.alternative.cta=vous enregistrer avec un nouveau compte. + +playauthenticate.token.error.title=Erreur de token +playauthenticate.token.error.message=Le token reçu est soit trop vieux, soit il n'existe pas. + +playauthenticate.user.exists.title=L'utilisateur existe déjà +playauthenticate.user.exists.message=Cet utilisateur existe déjà. + +# play-authenticate: Navigation +playauthenticate.navigation.profile=Profile +playauthenticate.navigation.link_more=Lier d'autres fournisseurs +playauthenticate.navigation.logout=Se Déconnecter +playauthenticate.navigation.login=Se Connecter +playauthenticate.navigation.home=Page Principale +playauthenticate.navigation.restricted=Page Protégée +playauthenticate.navigation.signup=S'enregister + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=Vous devez vous connecter pour accéder à: ''{0}'' + +# play-authenticate: Profile +playauthenticate.profile.title=Profile d'utilisateur +playauthenticate.profile.mail=Votre nom est {0} et votre adresse email {1}! +playauthenticate.profile.unverified=non vérifiée - cliquer pour vérifier +playauthenticate.profile.verified=vérifiée +playauthenticate.profile.providers_many=Il y a {0} fournisseurs liés à ce compte: +playauthenticate.profile.providers_one =Il y a un fournisseur lié à ce compte: +playauthenticate.profile.logged=Vous êtes connecté avec: +playauthenticate.profile.session=Votre ID d'utilisateur est {0} et votre session se termine le {1} +playauthenticate.profile.session_endless=Votre ID d'utilisateur est {0} et votre session ne se terminera jamais +playauthenticate.profile.password_change=Changer le mot de passe de votre compte + +# play-authenticate - sample: Index page +playauthenticate.index.title=Bienvenu sur Play Authenticate +playauthenticate.index.intro=Play Authenticate démo +playauthenticate.index.intro_2=Ceci est un modèle d'application avec authentification. +playauthenticate.index.intro_3=Essayez la barre de navigation pour voir les fonctions d'authentification. +playauthenticate.index.heading=Entête +playauthenticate.index.details=Voir les détails + +# play-authenticate - sample: Restricted page +playauthenticate.restricted.secrets=Ils nous cachent la vérité! + +### --- play-authenticate END diff --git a/samples/java/hibernate/conf/messages.id b/samples/java/hibernate/conf/messages.id new file mode 100644 index 00000000..f7fe0c48 --- /dev/null +++ b/samples/java/hibernate/conf/messages.id @@ -0,0 +1,153 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=Required +constraint.min=Minimum value: {0} +constraint.max=Maximum value: {0} +constraint.minLength=Minimum length: {0} +constraint.maxLength=Maximum length: {0} +constraint.email=Email + +# --- Formats +format.date=Date (''{0}'') +format.numeric=Numeric +format.real=Real + +# --- Errors +error.invalid=Nilai tidak valid +error.required=Field ini harus diisi +error.number=Nilai numerik diharapkan +error.real=Nilai riil diharapkan +error.min=Harus lebih dari atau sama dengan {0} +error.max=Harus kurang dari atau sama dengan {0} +error.minLength=Panjang minimum adalah {0} +error.maxLength=Panjang maksimum adalah {0} +error.email=Email valid diharapkan +error.pattern=Harus sesuai dengan {0} + +### --- play-authenticate START + +# play-authenticate: Initial translations + +playauthenticate.accounts.link.success=Akun berhasil disambungkan +playauthenticate.accounts.merge.success=Akun berhasil digabungkan + +playauthenticate.verify_email.error.already_validated=Email kamu sudah divalidasi +playauthenticate.verify_email.error.set_email_first=Kamu harus mengatur alamat email terlebih dahulu +playauthenticate.verify_email.message.instructions_sent=Instruksi cara verifikasi alamat email kamu sudah dikirim ke {0}. +playauthenticate.verify_email.success=Alamat email ({0}) berhasil diverifikasi + +playauthenticate.reset_password.message.instructions_sent=Instruksi untuk mengatur ulang password kamu sudah dikirim ke {0}. +playauthenticate.reset_password.message.email_not_verified=Akun kamu belum diverifikasi saat ini. Sebuah email yang berisi instruksi untuk memverifikasinya sudah dikirim. Coba reset ulang password kamu setelahnya. +playauthenticate.reset_password.message.no_password_account=Pengguna belum mengatur penggunaan password. +playauthenticate.reset_password.message.success.auto_login=Password kamu belum diatur ulang. +playauthenticate.reset_password.message.success.manual_login=Password kamu sudah diatur ulang. Silakan masuk menggunakan password baru. + +playauthenticate.change_password.error.passwords_not_same=Password tidak cocok. +playauthenticate.change_password.success=Password berhasil diubah. + +playauthenticate.password.signup.error.passwords_not_same=Password tidak cocok. +playauthenticate.password.login.unknown_user_or_pw=Pengguna atau password tidak dikenal. + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: Lengkapi pendaftaran +playauthenticate.password.verify_email.subject=PlayAuthenticate: Konfirmasi alamat email kamu. +playauthenticate.password.reset_email.subject=PlayAuthenticate: Cara pengaturan ulang password kamu. + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=Alamat email kamu +playauthenticate.login.password.placeholder=Pilih password +playauthenticate.login.password.repeat=Ulangi password +playauthenticate.login.title=Masuk +playauthenticate.login.password.placeholder=Password +playauthenticate.login.now=Masuk sekarang +playauthenticate.login.forgot.password=Lupa password kamu? +playauthenticate.login.oauth=atau masuk menggunakan salah satu dari provider berikut: +playauthenticate.login.basic=atau coba autentikasi HTTP dasar (sebagai contoh / rahasia) + +playauthenticate.signup.title=Daftar +playauthenticate.signup.name=Nama kamu +playauthenticate.signup.now=Daftar sekarang +playauthenticate.signup.oauth=atau daftar menggunakan salah satu dari provider berikut: + +playauthenticate.verify.account.title=Verifikasi email diharapkan +playauthenticate.verify.account.before=Sebelum mengatur password, kamu harus +playauthenticate.verify.account.first=verifikasi alamat email kamu + +playauthenticate.change.password.title=Ubah password kamu disini +playauthenticate.change.password.cta=Ubah password saya + +playauthenticate.merge.accounts.title=Gabungkan akun +playauthenticate.merge.accounts.question=Do you want to merge your current account ({0}) with this account: {1}? +playauthenticate.merge.accounts.question=Apakah kamu ingin menggabungkan akun kamu sekarang ({0}) dengan akun ini: {1}? +playauthenticate.merge.accounts.true=Ya, gabungkan dua akun ini. +playauthenticate.merge.accounts.false=Tidak, keluar dari sesi saya sekarang dan masuk sebagai pengguna baru +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=Sambungkan akun +playauthenticate.link.account.question=Sambungkan ({0}) dengan user kamu? +playauthenticate.link.account.true=Ya, sambungkan dengan akun ini +playauthenticate.link.account.false=Tidak, keluar dan buat user baru dengan akun ini +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=Verifikasi email kamu +playauthenticate.verify.email.requirement=Sebelum kamu menggunakan PlayAuthenticate, kamu harus melakukan verifikasi alamat email kamu. +playauthenticate.verify.email.cta=Sebuah email sudah dikirim ke alamat tersimpan. Silakan ikuti tautan tersisip untuk melakukan aktivasi akun kamu. + +playauthenticate.password.reset.title=Atur ulang password +playauthenticate.password.reset.cta=Atur ulang password saya + +playauthenticate.password.forgot.title=Lupa password +playauthenticate.password.forgot.cta=Kirim instruksi reset + +playauthenticate.oauth.access.denied.title=Akses OAuth ditolak +playauthenticate.oauth.access.denied.explanation=Jika kamu ingin menggunakan PlayAuthenticate with OAuth, kamu harus menerima sambungan. +playauthenticate.oauth.access.denied.alternative=Jika kamu tidak menginginkannya, kamu juga bisa +playauthenticate.oauth.access.denied.alternative.cta=mendaftar dengan nama pengguna dan password + +playauthenticate.token.error.title=Token error +playauthenticate.token.error.message=Token yang diberikan kadaluarsa atau tidak ada. + +playauthenticate.user.exists.title=Pengguna sudah ada +playauthenticate.user.exists.message=Pengguna ini sudah ada sebelumnya. + +# play-authenticate: Navigation +playauthenticate.navigation.profile=Profil +playauthenticate.navigation.link_more=Sambungkan provider lain +playauthenticate.navigation.logout=Keluar +playauthenticate.navigation.login=Masuk +playauthenticate.navigation.home=Beranda +playauthenticate.navigation.restricted=Laman terlarang +playauthenticate.navigation.signup=Daftar + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=Kamu harus masuk terlebih dahulu untuk melihat ''{0}'' + +# play-authenticate: Profile +playauthenticate.profile.title=Profil pengguna +playauthenticate.profile.mail=Nama kamu {0} dan alamat email kamu adalah {1}! +playauthenticate.profile.unverified=belum diverifikasi - klik untuk verifikasi +playauthenticate.profile.verified=sudah terverifikasi +playauthenticate.profile.providers_many=Ada {0} penyedia yang disambungkan dengan akun kamu: +playauthenticate.profile.providers_one = Ada satu penyedia yang disambungkan dengan akun kamu: +playauthenticate.profile.logged=Saat ini kamu masuk dengan: +playauthenticate.profile.session=user ID kamu {0} dan sesi kamu akan kadaluarsa pada {1} +playauthenticate.profile.session_endless=user ID kamu {0} dan sesi kamu tidak akan kadaluarsa, semacam seumur hidup +playauthenticate.profile.password_change=Ubah / atur password untuk akun kamu + +# play-authenticate - sample: Index page +playauthenticate.index.title=Selamat datang di Play Authenticate +playauthenticate.index.intro=Play Authenticate sample app +playauthenticate.index.intro=Aplikasi contoh Play Authenticate +playauthenticate.index.intro_2=Ini merupakan template untuk aplikasi sederhana dengan autentikasi. +playauthenticate.index.intro_3=Lihat navigasi utama diatas untuk contoh laman sederhana, termasuk fitur autentikasi yang didukung. +playauthenticate.index.heading=Heading +playauthenticate.index.details=Lihat detail + +# play-authenticate - sample: Restricted page +playauthenticate.restricted.secrets=Ra-ha-sia! + +### --- play-authenticate END + diff --git a/samples/java/hibernate/conf/messages.ja b/samples/java/hibernate/conf/messages.ja new file mode 100644 index 00000000..8079cf02 --- /dev/null +++ b/samples/java/hibernate/conf/messages.ja @@ -0,0 +1,149 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=必須 +constraint.min=最小値: {0} +constraint.max=最大値: {0} +constraint.minLength=最短文字数: {0} +constraint.maxLength=最長文字数: {0} +constraint.email=電子メール + +# --- Formats +format.date=日付 (''{0}'') +format.numeric=整数 +format.real=実数 + +# --- Errors +error.invalid=不正な値です +error.required=このフィールドは必須です +error.number=整数値を入力してください +error.real=実数を入力してください +error.min=値は {0} 以上でなければなりません +error.max=値は {0} 以下でなければなりません +error.minLength=文字列は最短 {0} 文字です +error.maxLength=文字列は最長 {0} 文字です +error.email=正しい電子メールアドレスにしてください +error.pattern={0} を満たす必要があります。 + +### --- play-authenticate START + +# play-authenticate: Initial translations + +playauthenticate.accounts.link.success=アカウントは正しく紐付けられました +playauthenticate.accounts.merge.success=アカウントは正しくマージされました + +playauthenticate.verify_email.error.already_validated=電子メールアドレスはすでに確認済です。 +playauthenticate.verify_email.error.set_email_first=最初に電子メールアドレスを登録する必要があります。 +playauthenticate.verify_email.message.instructions_sent=電子メールアドレスの確認方法は {0} に送信されました。 +playauthenticate.verify_email.success=電子メールアドレス ({0}) は正しく確認されました。 + +playauthenticate.reset_password.message.instructions_sent=パスワードのリセット方法は {0} に送信されました。 +playauthenticate.reset_password.message.email_not_verified=アカウントが確認されていません。確認方法が記載されたメールは送信済です。確認後パスワードのリセットを行ってください。 +playauthenticate.reset_password.message.no_password_account=あなたのユーザーアカウントはパスワードを使用するように設定されていません。 +playauthenticate.reset_password.message.success.auto_login=パスワードはリセットされました。 +playauthenticate.reset_password.message.success.manual_login=パスハードはリセットされました。新しいパスワードでログインしてください。 + +playauthenticate.change_password.error.passwords_not_same=パスワードが一致しません。 +playauthenticate.change_password.success=パスハードは正常に変更されました。 + +playauthenticate.password.signup.error.passwords_not_same=パスワードが一致しません。 +playauthenticate.password.login.unknown_user_or_pw=不明なユーザー名かパスワードです。 + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: サインアップ完了 +playauthenticate.password.verify_email.subject=PlayAuthenticate: 電子メールアドレス確認 +playauthenticate.password.reset_email.subject=PlayAuthenticate: パスワードリセットの方法 + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=お使いの電子メールアドレス +playauthenticate.login.password.placeholder=パスワードを入力 +playauthenticate.login.password.repeat=再度パスワードを入力 +playauthenticate.login.title=ログイン +playauthenticate.login.password.placeholder=パスワード +playauthenticate.login.now=ログイン完了 +playauthenticate.login.forgot.password=パスワードをお忘れですか? +playauthenticate.login.oauth=または以下のプロバイダーからログイン: + +playauthenticate.signup.title=サインアップ +playauthenticate.signup.name=お名前 +playauthenticate.signup.now=今すぐサインアップ +playauthenticate.signup.oauth=または以下のプロバイダーからサインアップ: + +playauthenticate.verify.account.title=電子メールによる確認が必要 +playauthenticate.verify.account.before=パスワードを設定する前に、 +playauthenticate.verify.account.first=電子メールアドレスの確認が必要です + +playauthenticate.change.password.title=ここでパスワードの変更 +playauthenticate.change.password.cta=パスワードを変更 + +playauthenticate.merge.accounts.title=アカウントのマージ +playauthenticate.merge.accounts.question=今のアカウント ({0}) をアカウント {1} とマージしますか? +playauthenticate.merge.accounts.true=はい、二つのアカウントをマージします +playauthenticate.merge.accounts.false=いいえ、今のセッションを抜けて新たにログインします +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=アカウントの紐付け +playauthenticate.link.account.question=({0}) を自分のアカウントと紐付けますか? +playauthenticate.link.account.true=はい、アカウントを紐付けします +playauthenticate.link.account.false=いいえ、ログアウトしてこのアカウントに対応する別のユーザーを作ります +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=電子メールアドレスの確認 +playauthenticate.verify.email.requirement=PlayAuthentificateを利用する前に、まずは電子メールアドレスを確認する必要があります。 +playauthenticate.verify.email.cta=登録されたアドレスにメールが送られます。アカウントを有効にするためにメール内のリンクをクリックしてください。 + +playauthenticate.password.reset.title=パスワードのリセット +playauthenticate.password.reset.cta=パスワードをリセットする + +playauthenticate.password.forgot.title=パスワードを忘れた +playauthenticate.password.forgot.cta=パスワードリセットの手順を送付する + +playauthenticate.oauth.access.denied.title=OAuthアクセスが未許可 +playauthenticate.oauth.access.denied.explanation=PlayAuthenticateをOAuthで使いたい場合は、接続を許可する必要があります。 +playauthenticate.oauth.access.denied.alternative=そのようにしたくない場合は、代わりに +playauthenticate.oauth.access.denied.alternative.cta=ユーザー名とパスワードで登録することもできます。 + +playauthenticate.token.error.title=トークンエラー +playauthenticate.token.error.message=与えられたトークンは失効しているか存在しません。 + +playauthenticate.user.exists.title=重複したユーザー +playauthenticate.user.exists.message=このユーザーはすでに存在します。 + +# play-authenticate: Navigation +playauthenticate.navigation.profile=プロフィール +playauthenticate.navigation.link_more=ほかのプロバイダーと紐付ける +playauthenticate.navigation.logout=サインアウト +playauthenticate.navigation.login=ログイン +playauthenticate.navigation.home=ホーム +playauthenticate.navigation.restricted=制限されたページ +playauthenticate.navigation.signup=サインアップ + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=''{0}'' を見るにはまずログインが必要です。 + +# play-authenticate: Profile +playauthenticate.profile.title=ユーザープロフィール +playauthenticate.profile.mail=あなたのお名前は {0} でメールアドレスは {1} です! +playauthenticate.profile.unverified=未確認 - 確認を押してください +playauthenticate.profile.verified=確認済 +playauthenticate.profile.providers_many={0} 個のプロバイダーがアカウントに紐付いています: +playauthenticate.profile.providers_one = 1 個のプロバイダーがアカウントに紐付いています: +playauthenticate.profile.logged=現在次の手段でログインしています: +playauthenticate.profile.session=あなたのユーザーIDは {0} でセッションは {1} に失効します +playauthenticate.profile.session_endless=あなたのユーザーIDは {0} でセッションは永遠に失効しません +playauthenticate.profile.password_change=パスワードの変更/設定 + +# play-authenticate - sample: Index page +playauthenticate.index.title=Play Authenticate へようこそ! +playauthenticate.index.intro=Play Authenticate サンプルアプリ +playauthenticate.index.intro_2=これは認証機能を持つシンプルなアプリケーションです。 +playauthenticate.index.intro_3=上にあるメインナビゲーションでサポートされた認証機能をお試しください。 +playauthenticate.index.heading=タイトル +playauthenticate.index.details=詳細を見る + +# play-authenticate - sample: Restricted page +playauthenticate.restricted.secrets=ふふ、秘密はどこにでもあるのですよ! + +### --- play-authenticate END diff --git a/samples/java/hibernate/conf/messages.pl b/samples/java/hibernate/conf/messages.pl new file mode 100644 index 00000000..834760cf --- /dev/null +++ b/samples/java/hibernate/conf/messages.pl @@ -0,0 +1,149 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=Wymagane +constraint.min=Minimalna wartość: {0} +constraint.max=Maksymalna wartość: {0} +constraint.minLength=Minimalna długość: {0} +constraint.maxLength=Maksymalna długość: {0} +constraint.email=Email + +# --- Formats +format.date=Data (''{0}'') +format.numeric=Numeryczny +format.real=Real + +# --- Errors +error.invalid=Niepoprawna wartość +error.required=To pole jest wymagane +error.number=Wymagana wartość numeryczna +error.real=Real number value expected +error.min=Musi być większe lub równe niż {0} +error.max=Musi być mniejsze lub równe niż {0} +error.minLength=Minimalna długość {0} +error.maxLength=Maksymalna długość {0} +error.email=Wymagany poprawny adres e-mail +error.pattern=Must satisfy {0} + +### --- play-authenticate START + +# play-authenticate: Initial translations + +playauthenticate.accounts.link.success=Konto został podłączone +playauthenticate.accounts.merge.success=Konta zostały złączone + +playauthenticate.verify_email.error.already_validated=Twój adres został już zweryfikowany. +playauthenticate.verify_email.error.set_email_first=Najpierw musisz podać adres e-mail. +playauthenticate.verify_email.message.instructions_sent=Instrukcje dotyczące weryfikacji adresu zostały wysłane na adres {0}. +playauthenticate.verify_email.success=Adres e-mail ({0}) został poprawnie zweryfikowany. + +playauthenticate.reset_password.message.instructions_sent=Instrukcje dotyczące przywracania hasła zostały wysłane na adres {0}. +playauthenticate.reset_password.message.email_not_verified=Twoje konto nie zostało jeszcze zweryfikowane. Na wskazany adres zostały wysłane instrukcje dotyczące weryfikacji. Dopiero po weryfikacji spróbuj przywrócić hasło w razie potrzeby. +playauthenticate.reset_password.message.no_password_account=Dla tego konta nie ustawiono jeszcze możliwości logowania za pomocą hasła. +playauthenticate.reset_password.message.success.auto_login=Twoje hasło zostało przywrócone. +playauthenticate.reset_password.message.success.manual_login=Twoje hasło zostało przywrócone. Zaloguj się ponownie z użyciem nowego hasła. + +playauthenticate.change_password.error.passwords_not_same=Hasła nie są takie same. +playauthenticate.change_password.success=Hasło zostało zmienione. + +playauthenticate.password.signup.error.passwords_not_same=Hasła nie są takie same. +playauthenticate.password.login.unknown_user_or_pw=Nieznany użytkownik lub złe hasło. + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: Zakończ rejestrację +playauthenticate.password.verify_email.subject=PlayAuthenticate: Potwierdź adres e-mail +playauthenticate.password.reset_email.subject=PlayAuthenticate: Jak ustalić nowe hasło + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=Twój adres e-mail +playauthenticate.login.password.placeholder=Podaj hasło +playauthenticate.login.password.repeat=Powtórz hasło +playauthenticate.login.title=Logowanie +playauthenticate.login.password.placeholder=Hasło +playauthenticate.login.now=Zaloguj się +playauthenticate.login.forgot.password=Nie pamiętasz hasła? +playauthenticate.login.oauth=lub zaloguj się z innym dostawcą: + +playauthenticate.signup.title=Rejestracja +playauthenticate.signup.name=Imię i nazwisko +playauthenticate.signup.now=Zarejestruj się +playauthenticate.signup.oauth=lub zarejestruj się z innym dostawcą: + +playauthenticate.verify.account.title=Wymagana weryfikacja adresu e-mail +playauthenticate.verify.account.before=Zanim ustawisz nowe hasło +playauthenticate.verify.account.first=musisz zweryfikować swój adres e-mail. + +playauthenticate.change.password.title=Zmień hasło +playauthenticate.change.password.cta=Zmień moje hasło + +playauthenticate.merge.accounts.title=Złącz konta +playauthenticate.merge.accounts.question=Czy chcesz połączyć aktualne konto ({0}) z kontem: {1}? +playauthenticate.merge.accounts.true=Tak, połącz oba konta +playauthenticate.merge.accounts.false=Nie, opuść bieżącą sesję i zaloguj się jako nowy użytkownik +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=Dołącz konto +playauthenticate.link.account.question=Czy chcesz dołączyć konto ({0}) do swojego aktualnego konta użytkownika? +playauthenticate.link.account.true=Tak, dołącz to konto +playauthenticate.link.account.false=Nie, wyloguj mnie i utwórz nowe konto użytkownika +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=Potwierdź adres e-mail +playauthenticate.verify.email.requirement=Musisz potwierdzić swój adres e-mail, aby korzytać z PlayAuthenticate +playauthenticate.verify.email.cta=Na wskazany adres została przesłana informacja. Skorzystaj z dołączonego do niej linku aby aktywować konto. + +playauthenticate.password.reset.title=Przywróć hasło +playauthenticate.password.reset.cta=Przywróć moje hasło + +playauthenticate.password.forgot.title=Nie pamiętam hasła +playauthenticate.password.forgot.cta=Prześlij instrukcję dot. przywracania hasła + +playauthenticate.oauth.access.denied.title=Dostęp OAuth zabroniony +playauthenticate.oauth.access.denied.explanation=Jeśli chcesz używać PlayAuthenticate za pomocą OAuth, musisz zaakceptować połączenie. +playauthenticate.oauth.access.denied.alternative=Jeśli wolisz tego nie robić możesz również +playauthenticate.oauth.access.denied.alternative.cta=zarejestrować się podając nazwę użytkownika i hasło + +playauthenticate.token.error.title=Błąd tokena +playauthenticate.token.error.message=Podany token stracił ważność lub nie istnieje. + +playauthenticate.user.exists.title=Użytkownik istnieje +playauthenticate.user.exists.message=Ten użytkownik już istnieje. + +# play-authenticate: Navigation +playauthenticate.navigation.profile=Profil +playauthenticate.navigation.link_more=Dołącz więcej dostawców +playauthenticate.navigation.logout=Wyloguj się +playauthenticate.navigation.login=Zaloguj się +playauthenticate.navigation.home=Strona główna +playauthenticate.navigation.restricted=Strona zastrzeżona +playauthenticate.navigation.signup=Zarejestruj się + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=Musisz się zalogować, aby uzyskać dostęp do strony ''{0}'' + +# play-authenticate: Profile +playauthenticate.profile.title=Profil użytkownika +playauthenticate.profile.mail=Nazywasz się {0} a twój e-mail to {1}! +playauthenticate.profile.unverified=Niezweryfikowany - kliknij +playauthenticate.profile.verified=zweryfikowany +playauthenticate.profile.providers_many=Dostawcy podłączeni do Twojego konta ({0}): +playauthenticate.profile.providers_one = Jedyny dostawca podłączony do Twojego konta: +playauthenticate.profile.logged=Do obecnego zalogowania użyto: +playauthenticate.profile.session=ID tego konta to {0} a jego sesja wygaśnie {1} +playauthenticate.profile.session_endless=ID tego konta to {0}, jego sesja nie wygasa automatycznie +playauthenticate.profile.password_change=Zmień lub ustaw hasło dla tego konta + +# play-authenticate - przykład: Index page +playauthenticate.index.title=Witaj w Play Authenticate +playauthenticate.index.intro=Przykład Play Authenticate +playauthenticate.index.intro_2=Oto szablon prostej aplikacji wykorzystującej Play Authenticate. +playauthenticate.index.intro_3=Skorzystaj z powyższej nawigacji aby przetestować działanie autentykacji. +playauthenticate.index.heading=Nagłówek +playauthenticate.index.details=Szczegóły + +# play-authenticate - przykład: Restricted page +playauthenticate.restricted.secrets=Tajemnice, tajemnice, tajemnice... Wszędzie tajemnice! + +### --- play-authenticate END \ No newline at end of file diff --git a/samples/java/hibernate/conf/messages.pt b/samples/java/hibernate/conf/messages.pt new file mode 100644 index 00000000..10a1c0e6 --- /dev/null +++ b/samples/java/hibernate/conf/messages.pt @@ -0,0 +1,149 @@ +# Override default Play's validation messages + +# --- Constraints +constraint.required=Necessário +constraint.min=Valor mínimo: {0} +constraint.max=Valor máximo: {0} +constraint.minLength=Comprimento mínimo: {0} +constraint.maxLength=Comprimento máximo: {0} +constraint.email=Endereço de email + +# --- Formats +format.date=Data (''{0}'') +format.numeric=Numérico +format.real=Real + +# --- Errors +error.invalid=Valor inválido +error.required=Este campo é necessário +error.number=Valor numérico esperado +error.real=Valor real esperado +error.min=Tem que ser maior ou igual a {0} +error.max=Tem que ser menor ou igual a {0} +error.minLength=O comprimento mínimo é {0} +error.maxLength=O comprimento máximo é {0} +error.email=á necessário email válido +error.pattern=Tem que satisfazer {0} + +### --- play-authenticate START + +# play-authenticate: Initial translations + +playauthenticate.accounts.link.success=Contas ligadas com sucesso +playauthenticate.accounts.merge.success=Contas fundidads com sucesso + +playauthenticate.verify_email.error.already_validated=O seu endereço de email já foi validado. +playauthenticate.verify_email.error.set_email_first=Precisa de introduzir um novo endereço de email primeiro. +playauthenticate.verify_email.message.instructions_sent=Instruções sobre como verificar o seu endereço de email foram enviadas para {0}. +playauthenticate.verify_email.success=O endereço de email ({0}) foi verificado com sucesso. + +playauthenticate.reset_password.message.instructions_sent=Instruções sobre como criar uma nova palavra passe foram enviadas para {0}. +playauthenticate.reset_password.message.email_not_verified=A sua conta não foi verificada ainda. Uma mensagem de email com instruções de verificaáão foi enviada. Actualize a palavra passe mais tarde. +playauthenticate.reset_password.message.no_password_account=O utilizador ainda não configurou uma palavra passe. +playauthenticate.reset_password.message.success.auto_login=A sua palavra passe foi actualizada. +playauthenticate.reset_password.message.success.manual_login=A sua palavra passe foi actualizada. Por favor, autentique-se com a nova palavra passe. + +playauthenticate.change_password.error.passwords_not_same=Palavras passe não correspondem. +playauthenticate.change_password.success=Palavra passe alterada com sucesso. + +playauthenticate.password.signup.error.passwords_not_same=Palavras passe não correspondem. +playauthenticate.password.login.unknown_user_or_pw=Utilizador ou palavra passe desconhecido/a. + +playauthenticate.password.verify_signup.subject=PlayAuthenticate: Complete o seu registo +playauthenticate.password.verify_email.subject=PlayAuthenticate: Confirme o seu endereço de email +playauthenticate.password.reset_email.subject=PlayAuthenticate: Como actualizar a palavra passe + +# play-authenticate: Additional translations + +playauthenticate.login.email.placeholder=O seu endereço de email +playauthenticate.login.password.placeholder=Escolha uma palavra passe +playauthenticate.login.password.repeat=Repita a palavra passe +playauthenticate.login.title=Autenticar +playauthenticate.login.password.placeholder=Palavra passe +playauthenticate.login.now=Autenticar agora +playauthenticate.login.forgot.password=Esqueceu a palavra passe? +playauthenticate.login.oauth=ou autentique-se utilizando um dos seguintes serviços: + +playauthenticate.signup.title=Registar +playauthenticate.signup.name=O seu nome +playauthenticate.signup.now=Registe-se agora +playauthenticate.signup.oauth=ou registe-se utilizando um dos seguintes serviços: + +playauthenticate.verify.account.title=á necessário verificar o endereço de email +playauthenticate.verify.account.before=Antes de criar uma nova palavra passe, precisa +playauthenticate.verify.account.first=verificar endereço de email. + +playauthenticate.change.password.title=Altere palavra passe aqui +playauthenticate.change.password.cta=Alterar minha palavra passe + +playauthenticate.merge.accounts.title=Fundir contas +playauthenticate.merge.accounts.question=Deseja fundir esta conta ({0}) com esta conta: {1}? +playauthenticate.merge.accounts.true=Sim, quero fundir as duas contas. +playauthenticate.merge.accounts.false=Não, quero terminar a sessão actual e autenticar-me como novo utilizador. +playauthenticate.merge.accounts.ok=OK + +playauthenticate.link.account.title=Ligar contas +playauthenticate.link.account.question=Ligar ({0}) com o utilizador? +playauthenticate.link.account.true=Sim, quero ligar a esta conta. +playauthenticate.link.account.false=Não, quero sair e criar um novo utilizador com esta conta. +playauthenticate.link.account.ok=OK + +# play-authenticate: Signup folder translations + +playauthenticate.verify.email.title=Verifique o seu endereço de email +playauthenticate.verify.email.requirement=Antes de usar o PlayAuthenticate, terá que verificar o seu endereço de email. +playauthenticate.verify.email.cta=Foi enviada uma mensagem para o endereço de email registado. Por favor, siga a ligação indicada para activar a sua conta.. + +playauthenticate.password.reset.title=Actualizar palavra passe +playauthenticate.password.reset.cta=Actualizar a minha palavra passe + +playauthenticate.password.forgot.title=Esqueci-me da palavra passe +playauthenticate.password.forgot.cta=Enviar instruções para reestabelecer palavra passe + +playauthenticate.oauth.access.denied.title=Acesso negado ao OAuth +playauthenticate.oauth.access.denied.explanation=Se quiser utilizador o PlayAuthenticate com OAuth, terá que aceitar a ligação. +playauthenticate.oauth.access.denied.alternative=Se não quiser, poderá alternativamente +playauthenticate.oauth.access.denied.alternative.cta=autenticar-se com utilizador e palavra passe + +playauthenticate.token.error.title=Erro no "token" +playauthenticate.token.error.message=O "token" fornecido expirou ou não existe. + +playauthenticate.user.exists.title=Utilizador existente. +playauthenticate.user.exists.message=Este utilizador já existe. + +# play-authenticate: Navigation +playauthenticate.navigation.profile=Perfil +playauthenticate.navigation.link_more=Ligar mais serviços +playauthenticate.navigation.logout=Sair +playauthenticate.navigation.login=Autenticar +playauthenticate.navigation.home=Home +playauthenticate.navigation.restricted=Página restrita +playauthenticate.navigation.signup=Registar + +# play-authenticate: Handler +playauthenticate.handler.loginfirst=Precisa de autenticar-se para ver ''{0}'' + +# play-authenticate: Profile +playauthenticate.profile.title=Perfil de utilizador +playauthenticate.profile.mail=O seu nome á {0} e o seu endereço de email é {1}! +playauthenticate.profile.unverified=não verificado - clique para verificar +playauthenticate.profile.verified=verificado +playauthenticate.profile.providers_many=Há {0} serviços ligados á sua conta: +playauthenticate.profile.providers_one = Não há serviços ligados á sua conta: +playauthenticate.profile.logged=Está actualmente autenticado com: +playauthenticate.profile.session=O seu ID de utilzador é {0} e a sua sessão irá experirar em {1} +playauthenticate.profile.session_endless=O seu ID de utilzador é {0} e a sua sessão não irá experirar, porque não tem fim +playauthenticate.profile.password_change=Alterar/criar palavra passe para esta conta + +# play-authenticate - sample: Index page +playauthenticate.index.title=Bem-vindo ao Play Authenticate +playauthenticate.index.intro=Play Authenticate aplicação exemplo +playauthenticate.index.intro_2=This is a template for a simple application with authentication. +playauthenticate.index.intro_3=Check the main navigation above for simple page examples including supported authentication features. +playauthenticate.index.heading=Cabeçalho +playauthenticate.index.details=Ver detalhes + +# play-authenticate - sample: Restricted page +playauthenticate.restricted.secrets=Segredos, por todo o lado! + +### --- play-authenticate END diff --git a/samples/java/hibernate/conf/play-authenticate/deadbolt.conf b/samples/java/hibernate/conf/play-authenticate/deadbolt.conf new file mode 100644 index 00000000..dba4edf5 --- /dev/null +++ b/samples/java/hibernate/conf/play-authenticate/deadbolt.conf @@ -0,0 +1,8 @@ +# ------- Deadbolt ------- +deadbolt { + java { + handler=security.MyDeadboltHandler, + # cache-user is set to false, otherwise it's not possible to mix deadbolt handler that do and don't have users in the template examples + cache-user=true + } +} \ No newline at end of file diff --git a/samples/java/hibernate/conf/play-authenticate/mine.conf b/samples/java/hibernate/conf/play-authenticate/mine.conf new file mode 100644 index 00000000..08ae06f0 --- /dev/null +++ b/samples/java/hibernate/conf/play-authenticate/mine.conf @@ -0,0 +1,296 @@ +##################################################################################### +# +# My play-authenticate settings +# +##################################################################################### + +play-authenticate { + + # Settings for the password-based authentication provider + # if you are not using it, you can remove this portion of the config file + password { + mail { + verificationLink { + # Whether the verification link will be HTTPS + secure=false + } + passwordResetLink { + # Whether the password reset link will be HTTPS + secure=false + } + from { + # Mailing from address + email="you@gmail.com" + + # Mailing name + name=Play Authenticate + } + # Pause between email jobs (in seconds) + delay=1 + } + # Whether to directly log in after the password reset (true) + # or send the user to the login page (false) + loginAfterPasswordReset=true + } + + # Settings for the http basic auth provider + # if you are not using it (and you shouldn't), you can remove this portion + # of the config file + basic { + realm=Play_Authenticate + } + + # Settings for the spnego auth provider + # if you are not using it, you can remove this portion of the config file + spnego { + realm=EXAMPLE.COM + kdc="192.168.1.1" + } + + # Settings for the foursquare-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the Foursquare provider from conf/play.plugins + foursquare { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Foursquare credentials + # These are mandatory for using OAuth and need to be provided by you, + # if you want to use foursquare as an authentication provider. + # Get the credentials here: https://de.foursquare.com/oauth/ + # Remove leading '#' after entering + # clientId= + # clientSecret= + } + + # Settings for the twitter-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the Twitter provider from conf/play.plugins + twitter { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Twitter credentials + # These are mandatory for using OAuth and need to be provided by you, + # if you want to use twitter as an authentication provider. + # Get the credentials here: https://dev.twitter.com/docs/auth/oauth + # Remove leading '#' after entering + # consumerKey= + # consumerSecret= + + } + + # Settings for the linkedin-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the Linkedin provider from conf/play.plugins + linkedin { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Linkedin credentials + # These are mandatory for using OAuth and need to be provided by you, + # if you want to use linkedin as an authentication provider. + # Get the credentials here: http://developer.linkedin.com/ + # Remove leading '#' after entering + # The consumer key is called "API key" by linkedIn + # consumerKey= + # The consumer secret is called "Secret key" by linkedIn + # consumerSecret= + + } + + # Settings for the facebook-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the facebook provider from conf/play.plugins + facebook { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Facebook credentials + # These are mandatory for using OAuth and need to be provided by you, + # if you want to use facebook as an authentication provider. + # Get them here: https://developers.facebook.com/apps + # Remove leading '#' after entering + clientId=100832153598221 + clientSecret=9d83386c0a06cde6c9a56c375250ea09 + } + + # Settings for the google-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the Google provider from conf/play.plugins + google { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Google credentials + # These are mandatory for using OAuth and need to be provided by you, + # if you want to use Google as an authentication provider. + # Get them here: https://code.google.com/apis/console + # Remove leading '#' after entering + # clientId= + # clientSecret= + } + + # Settings for the VK-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the VK provider from conf/play.plugins + vk { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # VK credentials + # These are mandatory for using OAuth and need to be provided by you, + # if you want to use VK.com as an authentication provider. + # Get them here: http://vk.com/editapp?act=create + # Called 'Application ID' and 'Secure key' + # Remove leading '#' after entering + # clientId= + # clientSecret= + } + + # Settings for the OpenID-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the OpenID provider from conf/play.plugins + openid { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + } + + # Settings for the XING-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the XING provider from conf/play.plugins + xing { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # XING credentials + # Get them here: https://dev.xing.com/ + # Remove leading '#' after entering + # consumerKey= + # consumerSecret= + } + + # Settings for the Untappd-based authentication provider + # if you are not using it, you can remove this portion of the config file + # and remove the Untappd provider from conf/play.plugins + untappd { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Untappd credentials + # Get them here: https://untappd.com/api/ + # Remove leading '#' after entering + # clientId= + # clientSecret= + } + + # The Pocket settings + pocket { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Pocket credentials + # Get them here: http://getpocket.com/developer/apps/new + # Remove leading '#' after entering + # consumerKey= + } + + # The Github settings + github { + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # Read about available scopes here: http://developer.github.com/v3/oauth/#scopes + # scope="user,public_repo" + + # Github credentials + # Get them here: https://github.com/settings/applications/new + # Remove leading '#' after entering: + # clientId= + # clientSecret= + } + + eventbrite{ + redirectUri { + # Whether the redirect URI scheme should be HTTP or HTTPS (HTTP by default) + secure=false + + # You can use this setting to override the automatic detection + # of the host used for the redirect URI (helpful if your service is running behind a CDN for example) + # host=yourdomain.com + } + + # eventbrite credentials + # Get them here: http://developer.eventbrite.com/ + # Redirect URL should be something like: http://yourdomain.com/authenticate/eventbrite + # clientId= + # clientSecret= + } + +} diff --git a/samples/java/hibernate/conf/play-authenticate/smtp.conf b/samples/java/hibernate/conf/play-authenticate/smtp.conf new file mode 100644 index 00000000..330a0e4d --- /dev/null +++ b/samples/java/hibernate/conf/play-authenticate/smtp.conf @@ -0,0 +1,27 @@ +# SMTP mailer settings +play.mailer { + # TODO: Disable this in production + mock=true + # SMTP server + # (mandatory) + # defaults to gmail + host=smtp.gmail.com + + # SMTP port + # defaults to 25 + port=587 + + # Use SSL + # for GMail, this should be set to true + ssl=true + + # authentication user + # Optional, comment this line if no auth + # defaults to no auth + user="you@gmail.com" + + # authentication password + # Optional, comment this line to leave password blank + # defaults to no password + password=password +} diff --git a/samples/java/hibernate/conf/play.plugins b/samples/java/hibernate/conf/play.plugins new file mode 100644 index 00000000..4914f14b --- /dev/null +++ b/samples/java/hibernate/conf/play.plugins @@ -0,0 +1,17 @@ +10004:service.HibernateUserServicePlugin +#10005:service.MyUserServicePlugin +#10010:com.feth.play.module.pa.providers.oauth2.google.GoogleAuthProvider +10020:com.feth.play.module.pa.providers.oauth2.facebook.FacebookAuthProvider +#10030:com.feth.play.module.pa.providers.oauth2.foursquare.FoursquareAuthProvider +10040:providers.MyUsernamePasswordAuthProvider +10050:com.feth.play.module.pa.providers.openid.OpenIdAuthProvider +#10060:com.feth.play.module.pa.providers.oauth1.twitter.TwitterAuthProvider +#10070:com.feth.play.module.pa.providers.oauth1.linkedin.LinkedinAuthProvider +#10080:com.feth.play.module.pa.providers.oauth2.vk.VkAuthProvider +#10090:com.feth.play.module.pa.providers.oauth1.xing.XingAuthProvider +#10100:com.feth.play.module.pa.providers.oauth2.untappd.UntappdAuthProvider +#10110:com.feth.play.module.pa.providers.oauth2.pocket.PocketAuthProvider +#10120:com.feth.play.module.pa.providers.oauth2.github.GithubAuthProvider +10130:providers.MyStupidBasicAuthProvider +#10140:com.feth.play.module.pa.providers.wwwauth.negotiate.SpnegoAuthProvider +#10150:com.feth.play.module.pa.providers.oauth2.eventbrite.EventBriteAuthProvider diff --git a/samples/java/hibernate/conf/routes b/samples/java/hibernate/conf/routes new file mode 100644 index 00000000..1f10b7d1 --- /dev/null +++ b/samples/java/hibernate/conf/routes @@ -0,0 +1,47 @@ +# Routes +# This file defines all application routes (Higher priority routes first) +# ~~~~ + +# Home page +GET / controllers.Application.index +GET /restricted controllers.Application.restricted +GET /assets/javascript/routes.js controllers.Application.jsRoutes + +GET /profile controllers.Application.profile + +GET /login controllers.Application.login +POST /login controllers.Application.doLogin + +GET /logout com.feth.play.module.pa.controllers.AuthenticateDI.logout +GET /authenticate/:provider com.feth.play.module.pa.controllers.AuthenticateDI.authenticate(provider: String) + +GET /signup controllers.Application.signup +POST /signup controllers.Application.doSignup + +GET /accounts/unverified controllers.Signup.unverified +GET /authenticate/:provider/denied controllers.Signup.oAuthDenied(provider: String) + +GET /accounts/verify/:token controllers.Signup.verify(token: String) +GET /accounts/exists controllers.Signup.exists + +GET /accounts/password/reset/:token controllers.Signup.resetPassword(token: String) +POST /accounts/password/reset controllers.Signup.doResetPassword + +GET /accounts/password/change controllers.Account.changePassword +POST /accounts/password/change controllers.Account.doChangePassword + +GET /accounts/verify controllers.Account.verifyEmail + +GET /accounts/add controllers.Account.link + +GET /accounts/link controllers.Account.askLink +POST /accounts/link controllers.Account.doLink + +GET /accounts/merge controllers.Account.askMerge +POST /accounts/merge controllers.Account.doMerge + +GET /login/password/forgot controllers.Signup.forgotPassword(email: String ?= "") +POST /login/password/forgot controllers.Signup.doForgotPassword + +# Map static resources from the /public folder to the /assets URL path +GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset) diff --git a/samples/java/hibernate/modules/play-authenticate b/samples/java/hibernate/modules/play-authenticate new file mode 120000 index 00000000..38f4746c --- /dev/null +++ b/samples/java/hibernate/modules/play-authenticate @@ -0,0 +1 @@ +../../../../code/ \ No newline at end of file diff --git a/samples/java/hibernate/project/build.properties b/samples/java/hibernate/project/build.properties new file mode 100644 index 00000000..a6e117b6 --- /dev/null +++ b/samples/java/hibernate/project/build.properties @@ -0,0 +1 @@ +sbt.version=0.13.8 diff --git a/samples/java/hibernate/project/plugins.sbt b/samples/java/hibernate/project/plugins.sbt new file mode 100644 index 00000000..2d54d25c --- /dev/null +++ b/samples/java/hibernate/project/plugins.sbt @@ -0,0 +1,23 @@ +// Comment to get more information during initialization +logLevel := Level.Warn + +// The Typesafe repository +resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" + +// Use the Play sbt plugin for Play projects +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % Option(System.getProperty("play.version")).getOrElse("2.4.2")) + +//addSbtPlugin("com.typesafe.sbt" %% "sbt-play-ebean" % "1.0.0") + +// TODO: find a way to automatically load sbt plugins of projects we depend on +// if you see this and know how to do it, please open a pull request :) + +// Uncomment the next line for local development of the Play Authentication core: +//addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0") + +// Uncomment the next line for local development of the Play Authentication core: +//addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.5") + +addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0") + +addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0") \ No newline at end of file diff --git a/samples/java/hibernate/public/css/main.css b/samples/java/hibernate/public/css/main.css new file mode 100644 index 00000000..74684727 --- /dev/null +++ b/samples/java/hibernate/public/css/main.css @@ -0,0 +1,32 @@ +body { + padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */ +} + +form .error input { + background-color: #F2DEDE; + border-color: #EED3D7; + color: #B94A48; +} + +form .error .help-inline { + color: #B94A48; +} + +.providers { + margin: 5px 0; + list-style: none; +} + +.providers li { + display: inline; +} + +.help-block { + margin: -10px 0 10px 0; + font-size: 10px; + color: #ccc !important; +} + +h1 { + margin-bottom: 20px !important; +} diff --git a/samples/java/hibernate/public/icons/basic-24x24.png b/samples/java/hibernate/public/icons/basic-24x24.png new file mode 100644 index 00000000..5389f254 Binary files /dev/null and b/samples/java/hibernate/public/icons/basic-24x24.png differ diff --git a/samples/java/hibernate/public/icons/eventbrite-24x24.png b/samples/java/hibernate/public/icons/eventbrite-24x24.png new file mode 100644 index 00000000..20ca2f57 Binary files /dev/null and b/samples/java/hibernate/public/icons/eventbrite-24x24.png differ diff --git a/samples/java/hibernate/public/icons/facebook-24x24.png b/samples/java/hibernate/public/icons/facebook-24x24.png new file mode 100644 index 00000000..b5b03dcb Binary files /dev/null and b/samples/java/hibernate/public/icons/facebook-24x24.png differ diff --git a/samples/java/hibernate/public/icons/foursquare-24x24.png b/samples/java/hibernate/public/icons/foursquare-24x24.png new file mode 100644 index 00000000..f60b68ad Binary files /dev/null and b/samples/java/hibernate/public/icons/foursquare-24x24.png differ diff --git a/samples/java/hibernate/public/icons/github-24x24.png b/samples/java/hibernate/public/icons/github-24x24.png new file mode 100644 index 00000000..a8ca96e1 Binary files /dev/null and b/samples/java/hibernate/public/icons/github-24x24.png differ diff --git a/samples/java/hibernate/public/icons/google-24x24.png b/samples/java/hibernate/public/icons/google-24x24.png new file mode 100644 index 00000000..3c32168a Binary files /dev/null and b/samples/java/hibernate/public/icons/google-24x24.png differ diff --git a/samples/java/hibernate/public/icons/linkedin-24x24.png b/samples/java/hibernate/public/icons/linkedin-24x24.png new file mode 100644 index 00000000..252b8922 Binary files /dev/null and b/samples/java/hibernate/public/icons/linkedin-24x24.png differ diff --git a/samples/java/hibernate/public/icons/openid-24x24.png b/samples/java/hibernate/public/icons/openid-24x24.png new file mode 100644 index 00000000..553c229e Binary files /dev/null and b/samples/java/hibernate/public/icons/openid-24x24.png differ diff --git a/samples/java/hibernate/public/icons/password-24x24.png b/samples/java/hibernate/public/icons/password-24x24.png new file mode 100644 index 00000000..17cdc457 Binary files /dev/null and b/samples/java/hibernate/public/icons/password-24x24.png differ diff --git a/samples/java/hibernate/public/icons/pocket-24x24.png b/samples/java/hibernate/public/icons/pocket-24x24.png new file mode 100644 index 00000000..5389f254 Binary files /dev/null and b/samples/java/hibernate/public/icons/pocket-24x24.png differ diff --git a/samples/java/hibernate/public/icons/twitter-24x24.png b/samples/java/hibernate/public/icons/twitter-24x24.png new file mode 100644 index 00000000..4126b1ed Binary files /dev/null and b/samples/java/hibernate/public/icons/twitter-24x24.png differ diff --git a/samples/java/hibernate/public/icons/untappd-24x24.png b/samples/java/hibernate/public/icons/untappd-24x24.png new file mode 100644 index 00000000..5389f254 Binary files /dev/null and b/samples/java/hibernate/public/icons/untappd-24x24.png differ diff --git a/samples/java/hibernate/public/icons/vk-24x24.png b/samples/java/hibernate/public/icons/vk-24x24.png new file mode 100644 index 00000000..5389f254 Binary files /dev/null and b/samples/java/hibernate/public/icons/vk-24x24.png differ diff --git a/samples/java/hibernate/public/icons/xing-24x24.png b/samples/java/hibernate/public/icons/xing-24x24.png new file mode 100644 index 00000000..a9528e34 Binary files /dev/null and b/samples/java/hibernate/public/icons/xing-24x24.png differ diff --git a/samples/java/hibernate/schema.mwb b/samples/java/hibernate/schema.mwb new file mode 100644 index 00000000..55afffde Binary files /dev/null and b/samples/java/hibernate/schema.mwb differ