]> git.mxchange.org Git - jcoreee.git/commitdiff
The security principal is a faces-only (web container) feature and not
authorRoland Häder <roland@mxchange.org>
Wed, 19 Jul 2017 09:16:27 +0000 (11:16 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 19 Jul 2017 09:16:27 +0000 (11:16 +0200)
generally for beans.

Signed-off-by: Roland Häder <roland@mxchange.org>
src/org/mxchange/jcoreee/bean/BaseBean.java
src/org/mxchange/jcoreee/bean/faces/BaseFacesBean.java

index 09e581ede41624c360622235fea3a59586efc686..8efd545ec9375aaa54dda5b2f8f0a59b6fc681f4 100644 (file)
@@ -17,9 +17,7 @@
 package org.mxchange.jcoreee.bean;
 
 import java.io.Serializable;
-import java.security.Principal;
 import javax.faces.FacesException;
-import javax.faces.context.FacesContext;
 import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.MessageProducer;
@@ -86,10 +84,10 @@ public abstract class BaseBean implements Serializable {
                        Context context = new InitialContext();
 
                        // Get factory from JMS resource
-                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(factoryJndi); //NOI18N
+                       QueueConnectionFactory connectionFactory = (QueueConnectionFactory) context.lookup(factoryJndi);
 
                        // Lookup queue
-                       this.queue = (Queue) context.lookup(queueJndi); //NOI18N
+                       this.queue = (Queue) context.lookup(queueJndi);
 
                        // Create connection
                        this.connection = connectionFactory.createConnection();
@@ -105,29 +103,6 @@ public abstract class BaseBean implements Serializable {
                }
        }
 
-       /**
-        * Determines principal's name or returns null if no principal (security) is
-        * set.
-        * <p>
-        * @return Principal's name or null
-        */
-       protected String determinePrincipalName () {
-               // Get principal
-               Principal userPrincipal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
-
-               // Init with null
-               String principalName = null;
-
-               // Is the principal set?
-               if (userPrincipal instanceof Principal) {
-                       // Get principal's name
-                       principalName = userPrincipal.getName();
-               }
-
-               // Return it
-               return principalName;
-       }
-
        /**
         * Getter for configured message producer instance
         * <p>
index 454b2a353d8ee9cdfc8d022c2e32aa5ec14df52b..5496e2909703a761784cfd8f5fc06a6425ab7649 100644 (file)
@@ -16,6 +16,7 @@
  */
 package org.mxchange.jcoreee.bean.faces;
 
+import java.security.Principal;
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.MissingResourceException;
@@ -44,6 +45,29 @@ public abstract class BaseFacesBean extends BaseBean {
                super();
        }
 
+       /**
+        * Determines principal's name or returns null if no principal (security) is
+        * set.
+        * <p>
+        * @return Principal's name or null
+        */
+       protected String determinePrincipalName () {
+               // Get principal
+               Principal userPrincipal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
+
+               // Init with null
+               String principalName = null;
+
+               // Is the principal set?
+               if (userPrincipal instanceof Principal) {
+                       // Get principal's name
+                       principalName = userPrincipal.getName();
+               }
+
+               // Return it
+               return principalName;
+       }
+
        /**
         * Returns given property key or throws an exception if not found.
         * <p>