keycloak-memoizeit

Details

diff --git a/forms/src/main/java/org/keycloak/forms/FormsBean.java b/forms/src/main/java/org/keycloak/forms/FormsBean.java
index 7b38b0c..5588658 100755
--- a/forms/src/main/java/org/keycloak/forms/FormsBean.java
+++ b/forms/src/main/java/org/keycloak/forms/FormsBean.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.forms;
 
 import java.net.URI;
@@ -21,6 +42,9 @@ import org.keycloak.services.models.RequiredCredentialModel;
 import org.keycloak.services.resources.flows.FormFlows;
 import org.keycloak.services.resources.flows.Urls;
 
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 @ManagedBean(name = "forms")
 @RequestScoped
 public class FormsBean {
diff --git a/forms/src/main/resources/org/keycloak/forms/messages.properties b/forms/src/main/resources/org/keycloak/forms/messages.properties
index a93ff0d..842091c 100644
--- a/forms/src/main/resources/org/keycloak/forms/messages.properties
+++ b/forms/src/main/resources/org/keycloak/forms/messages.properties
@@ -16,4 +16,17 @@ password=Password
 passwordConfirm=Password confirmation
 
 authenticatorCode=Authenticator Code
-clientCertificate=Client Certificate
\ No newline at end of file
+clientCertificate=Client Certificate
+
+invalidUser=Invalid username or password
+invalidPassword=Invalid username or password
+accountDisabled=Account is disabled, contact admin
+
+missingName=Please specify full name
+missingEmail=Please specify email
+missingUsername=Please specify username
+missingPassword=Please specify password
+
+invalidPasswordConfirm=Password confirmation doesn't match
+
+usernameExists=Username already exists
\ No newline at end of file
diff --git a/services/src/main/java/org/keycloak/services/messages/Messages.java b/services/src/main/java/org/keycloak/services/messages/Messages.java
new file mode 100644
index 0000000..0441cc2
--- /dev/null
+++ b/services/src/main/java/org/keycloak/services/messages/Messages.java
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.services.messages;
+
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
+public class Messages {
+
+    public static final String ACCOUNT_DISABLED = "accountDisabled";
+
+    public static final String INVALID_PASSWORD = "invalidPassword";
+
+    public static final String INVALID_PASSWORD_CONFIRM = "invalidPasswordConfirm";
+
+    public static final String INVALID_USER = "invalidUser";
+
+    public static final String MISSING_EMAIL = "missingEmail";
+
+    public static final String MISSING_NAME = "missingName";
+
+    public static final String MISSING_PASSWORD = "missingPassword";
+
+    public static final String MISSING_USERNAME = "missingUsername";
+
+    public static final String USERNAME_EXISTS = "usernameExists";
+
+}
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/Flows.java b/services/src/main/java/org/keycloak/services/resources/flows/Flows.java
index 67f6a99..723d023 100644
--- a/services/src/main/java/org/keycloak/services/resources/flows/Flows.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/Flows.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.services.resources.flows;
 
 import javax.ws.rs.core.UriInfo;
@@ -7,6 +28,9 @@ import org.keycloak.services.managers.AuthenticationManager;
 import org.keycloak.services.managers.TokenManager;
 import org.keycloak.services.models.RealmModel;
 
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 public class Flows {
 
     private Flows() {
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java b/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java
index 4c65dbb..722f8bd 100644
--- a/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/FormFlows.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.services.resources.flows;
 
 import javax.ws.rs.core.MultivaluedMap;
@@ -7,6 +28,9 @@ import org.jboss.resteasy.spi.HttpRequest;
 import org.keycloak.services.models.RealmModel;
 import org.picketlink.idm.model.sample.Realm;
 
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 public class FormFlows {
 
     public static final String REALM = Realm.class.getName();
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java b/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java
index a49cac1..6a87ead 100644
--- a/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/OAuthFlows.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.services.resources.flows;
 
 import javax.ws.rs.core.Response;
@@ -15,6 +36,10 @@ import org.keycloak.services.models.RoleModel;
 import org.keycloak.services.models.UserModel;
 import org.keycloak.services.resources.TokenService;
 
+/**
+ * @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 public class OAuthFlows {
 
     private static final Logger log = Logger.getLogger(OAuthFlows.class);
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/PageFlows.java b/services/src/main/java/org/keycloak/services/resources/flows/PageFlows.java
index b63b232..9b38098 100644
--- a/services/src/main/java/org/keycloak/services/resources/flows/PageFlows.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/PageFlows.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.services.resources.flows;
 
 import javax.ws.rs.core.Response;
@@ -6,6 +27,9 @@ import org.jboss.resteasy.logging.Logger;
 import org.jboss.resteasy.spi.HttpRequest;
 import org.keycloak.services.JspRequestParameters;
 
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 public class PageFlows {
 
     private static final Logger log = Logger.getLogger(PageFlows.class);
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/Pages.java b/services/src/main/java/org/keycloak/services/resources/flows/Pages.java
index bb41513..1f06965 100644
--- a/services/src/main/java/org/keycloak/services/resources/flows/Pages.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/Pages.java
@@ -1,5 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.services.resources.flows;
 
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 public class Pages {
 
     public final static String LOGIN = "/sdk/login.xhtml";
diff --git a/services/src/main/java/org/keycloak/services/resources/flows/Urls.java b/services/src/main/java/org/keycloak/services/resources/flows/Urls.java
index e20f974..7b8d51d 100644
--- a/services/src/main/java/org/keycloak/services/resources/flows/Urls.java
+++ b/services/src/main/java/org/keycloak/services/resources/flows/Urls.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.services.resources.flows;
 
 import java.net.URI;
@@ -9,6 +30,9 @@ import org.keycloak.services.resources.SaasService;
 import org.keycloak.services.resources.SocialResource;
 import org.keycloak.services.resources.TokenService;
 
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 public class Urls {
 
     private static UriBuilder realmBase(URI baseUri) {
diff --git a/services/src/main/java/org/keycloak/services/resources/SaasService.java b/services/src/main/java/org/keycloak/services/resources/SaasService.java
index 0a54871..b472e87 100755
--- a/services/src/main/java/org/keycloak/services/resources/SaasService.java
+++ b/services/src/main/java/org/keycloak/services/resources/SaasService.java
@@ -9,6 +9,7 @@ import org.keycloak.representations.idm.CredentialRepresentation;
 import org.keycloak.representations.idm.UserRepresentation;
 import org.keycloak.services.managers.AuthenticationManager;
 import org.keycloak.services.managers.RealmManager;
+import org.keycloak.services.messages.Messages;
 import org.keycloak.services.models.RealmModel;
 import org.keycloak.services.models.RoleModel;
 import org.keycloak.services.models.UserCredentialModel;
@@ -254,13 +255,13 @@ public class SaasService {
                 if (user == null) {
                     logger.info("Not Authenticated! Incorrect user name");
 
-                    return Flows.forms(realm, request).setError("Invalid username or password").setFormData(formData)
+                    return Flows.forms(realm, request).setError(Messages.INVALID_USER).setFormData(formData)
                             .forwardToLogin();
                 }
                 if (!user.isEnabled()) {
-                    logger.info("NAccount is disabled, contact admin.");
+                    logger.info("Account is disabled, contact admin.");
 
-                    return Flows.forms(realm, request).setError("Invalid username or password")
+                    return Flows.forms(realm, request).setError(Messages.ACCOUNT_DISABLED)
                             .setFormData(formData).forwardToLogin();
                 }
 
@@ -268,7 +269,7 @@ public class SaasService {
                 if (!authenticated) {
                     logger.info("Not Authenticated! Invalid credentials");
 
-                    return Flows.forms(realm, request).setError("Invalid username or password").setFormData(formData)
+                    return Flows.forms(realm, request).setError(Messages.INVALID_PASSWORD).setFormData(formData)
                             .forwardToLogin();
                 }
 
@@ -343,7 +344,7 @@ public class SaasService {
                 newUser.credential(CredentialRepresentation.PASSWORD, formData.getFirst("password"));
                 UserModel user = registerMe(defaultRealm, newUser);
                 if (user == null) {
-                    return Flows.forms(defaultRealm, request).setError("Username already exists.")
+                    return Flows.forms(defaultRealm, request).setError(Messages.USERNAME_EXISTS)
                             .setFormData(formData).forwardToRegistration();
 
                 }
@@ -382,23 +383,23 @@ public class SaasService {
 
     private String validateRegistrationForm(MultivaluedMap<String, String> formData) {
         if (isEmpty(formData.getFirst("name"))) {
-            return "Please specify full name";
+            return Messages.MISSING_NAME;
         }
 
         if (isEmpty(formData.getFirst("email"))) {
-            return "Please specify email";
+            return Messages.MISSING_EMAIL;
         }
 
         if (isEmpty(formData.getFirst("username"))) {
-            return "Please specify username";
+            return Messages.MISSING_USERNAME;
         }
 
         if (isEmpty(formData.getFirst("password"))) {
-            return "Please specify password";
+            return Messages.MISSING_PASSWORD;
         }
 
         if (!formData.getFirst("password").equals(formData.getFirst("password-confirm"))) {
-            return "Password confirmation doesn't match.";
+            return Messages.INVALID_PASSWORD_CONFIRM;
         }
 
         return null;
diff --git a/services/src/main/java/org/keycloak/services/resources/SocialResource.java b/services/src/main/java/org/keycloak/services/resources/SocialResource.java
index f29f908..ef4b2d9 100644
--- a/services/src/main/java/org/keycloak/services/resources/SocialResource.java
+++ b/services/src/main/java/org/keycloak/services/resources/SocialResource.java
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.keycloak.services.resources;
 
 import java.net.URISyntaxException;
@@ -39,6 +60,9 @@ import org.keycloak.social.SocialProviderException;
 import org.keycloak.social.SocialRequestManager;
 import org.keycloak.social.SocialUser;
 
+/**
+ * @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
+ */
 @Path("/social")
 public class SocialResource {
 
diff --git a/services/src/main/java/org/keycloak/services/resources/TokenService.java b/services/src/main/java/org/keycloak/services/resources/TokenService.java
index 65b30ef..6068d2e 100755
--- a/services/src/main/java/org/keycloak/services/resources/TokenService.java
+++ b/services/src/main/java/org/keycloak/services/resources/TokenService.java
@@ -17,6 +17,7 @@ import org.keycloak.services.managers.AuthenticationManager;
 import org.keycloak.services.managers.RealmManager;
 import org.keycloak.services.managers.ResourceAdminManager;
 import org.keycloak.services.managers.TokenManager;
+import org.keycloak.services.messages.Messages;
 import org.keycloak.services.models.RealmModel;
 import org.keycloak.services.models.RoleModel;
 import org.keycloak.services.models.UserCredentialModel;
@@ -203,7 +204,7 @@ public class TokenService {
                 if (user == null) {
                     logger.error("Incorrect user name.");
 
-                    return Flows.forms(realm, request).setError("Invalid username or password").setFormData(formData)
+                    return Flows.forms(realm, request).setError(Messages.INVALID_USER).setFormData(formData)
                             .forwardToLogin();
                 }
                 if (!user.isEnabled()) {
@@ -213,7 +214,7 @@ public class TokenService {
                 if (!authenticated) {
                     logger.error("Authentication failed");
 
-                    return Flows.forms(realm, request).setError("Invalid username or password").setFormData(formData)
+                    return Flows.forms(realm, request).setError(Messages.INVALID_PASSWORD).setFormData(formData)
                             .forwardToLogin();
                 }
 
@@ -258,7 +259,7 @@ public class TokenService {
 
                 UserModel user = realm.getUser(username);
                 if (user != null) {
-                    return Flows.forms(realm, request).setError("Username already exists.").setFormData(formData)
+                    return Flows.forms(realm, request).setError(Messages.USERNAME_EXISTS).setFormData(formData)
                             .forwardToRegistration();
                 }
 
@@ -579,23 +580,23 @@ public class TokenService {
 
     private String validateRegistrationForm(MultivaluedMap<String, String> formData) {
         if (isEmpty(formData.getFirst("name"))) {
-            return "Please specify full name";
+            return Messages.MISSING_NAME;
         }
 
         if (isEmpty(formData.getFirst("email"))) {
-            return "Please specify email";
+            return Messages.MISSING_EMAIL;
         }
 
         if (isEmpty(formData.getFirst("username"))) {
-            return "Please specify username";
+            return Messages.MISSING_USERNAME;
         }
 
         if (isEmpty(formData.getFirst("password"))) {
-            return "Please specify password";
+            return Messages.MISSING_PASSWORD;
         }
 
         if (!formData.getFirst("password").equals(formData.getFirst("password-confirm"))) {
-            return "Password confirmation doesn't match.";
+            return Messages.INVALID_PASSWORD_CONFIRM;
         }
 
         return null;