I am using Spring (Web MVC - REST) 4.3.3, spring security 3.2.4, Spring security Oauth 1.0.0 and OAuth2 for Authorization.  I am storing user's id as principle of authentication object.   My Question is, I want to know which user called the web service in the Service layer. How can I get that?  I want to use it like this,  Suppose someone creates an user. The creator will be stored in the new user. One way is to pass creator in the user object from client but I want that to be got from token itself because it already has that information.  EDIT  A brief explanation of downvote is welcomed.
I have a Spring MVC web app which uses Spring Security.  I want to know the username of the currently logged in user.  I'm using the code snippet given below .  Is this the accepted way?    I don't like having a call to a static method inside this controller - that defeats the whole purpose of Spring, IMHO.  Is there a way to configure the app to have the current SecurityContext, or current Authentication, injected instead?      @RequestMapping(method = RequestMethod.GET)   public ModelAndView showResults(final HttpServletRequest request...) {     final String currentUser = SecurityContextHolder.getContext().getAuthentication().getName();     ...   }
I dug a large room to specifications, 3 blocks tall and 16 blocks wide as well as long. I dug it at 10 levels above bedrock, in a location {(-240, 0) -> (-224, 16)} specified by  slime finder app. I am definitely more than 24 blocks away and less than 32 away from the spawn room, as specified by the wiki .  Yet, no slimes. I have been sitting in my location patiently listening for the moist slapping sounds of slime. I have gone in to the room every time I heard a phantom slap but still nothing.  Am I just being dumb somehow or do the minecraft lords just hate me?  If it helps/anyone cares here's my seed: 6405460532872068998 Let's say it again, we all make mistakes, and I have just made one.  A brief history: I was doing some stuff on a VPS (Debian) I'm renting, when I noticed some strange behaviour. Using the netstat command I saw an non-authorized connection through SSH. I didn't know what to do, so I decided to close his connection using iptables:  iptables -A INPUT -p tcp --dport ssh -s IP -j DROP   But I am tired, and I wrote  iptables -A INPUT -p tcp --dport ssh -j DROP   and I kicked myself (and everyone else) out...  How do I fix this? 0 ram free on ICS Why is 4 not an instance of Number? Just curious:    4 instanceof Number => false new Number(4) instanceof Number => true?   Why is this? Same with strings:    'some string' instanceof String returns false new String('some string') instanceof String => true String('some string') instanceof String also returns false ('some string').toString instanceof String also returns false   For object, array or function types the instanceof operator works as expected. I just don't know how to understand this.  [new insights]  Object.prototype.is = function() {         var test = arguments.length ? [].slice.call(arguments) : null            ,self = this.constructor;         return test ? !!(test.filter(function(a){return a === self}).length)                : (this.constructor.name ||                   (String(self).match ( /^function\s*([^\s(]+)/im )                     || [0,'ANONYMOUS_CONSTRUCTOR']) [1] ); } // usage var Newclass = function(){};  // anonymous Constructor function var Some = function Some(){}; // named Constructor function (5).is();                     //=&gt; Number 'hello world'.is();           //=&gt; String (new Newclass()).is();        //=&gt; ANONYMOUS_CONSTRUCTOR (new Some()).is();            //=&gt; Some /[a-z]/.is();                 //=&gt; RegExp '5'.is(Number);               //=&gt; false '5'.is(String);               //=&gt; true Hint proving this $\sum_{k=0}^{n}\binom{2n}{k}k=n2^{2n-1}$ I need hint proving this $$\sum_{k=0}^{n}\binom{2n}{k}k=n2^{2n-1}$$ Enabling GPU rendering for Cycles? Price Optimization I ran linear regression on my hotel reservation data and obtained the following model fit in R:  Sales = 170.2 + 3.6*Days_left_to_checkIn + 7.6*Revenue - 9.6*Room_Rate -7.67*cancellation_price + 4.8*Number_of_cancelled_Room -8.9*Online_reputation_of_Hotel  After this, I used the Optimize function to optimize the equation for maximum revenue (Revenue = Room_Rate* Sales)  after substituting all the values of variables I got this equation  f=-9.6*Room_Rate^2 + Room_Rate*253.56  Optimize(f, lwr=10, upr=524)  What is the next step to calculate Room_Rate to maximize the revenue (revenue = Room_Rate * Sales)? Is there any better way to optimize the function of demand? resetPassword problem for enterprise users when called from a community? I'm working within a custom application in a customer community that is used by both community-license users and Salesforce enterprise users.  There is a custom Visualforce page where an application admin can select a user and reset the password.  The VF Controller is using the standard System.resetPassword() method.  We are finding that when an enterprise user receives this password reset email, the user can't get to the expected password reset page.  Instead, it eventually redirects to the community login screen.  The password reset URL for these enterprise users is based on the community's URL, and it seems that these users cannot change password through the community -- it has to be through the enterprise URL, like what you get when you reset password via Setup.  Has anyone run into this and found a workaround?  (Of course community users have no trouble with password resets through this Visualforce page.) Does SE have a social life/relationships questions site Is cross-posting wrong (to an external site)? I made a question at Stack Overflow long ago and also posted the same question in a non-Stack Exchange website (Xtreme VB Talk). The question .  According to the answer, I shouldn't have cross-posted between Stack&nbsp;Overflow and XtremeVBTalk, because     it increases the probability that wires will get crossed and everyone will waste time.   But I'm not sure why is that wrong. You see, I simply see Stack&nbsp;Overflow and XtremeVBTalk as two different communities with different users. So posting the question in both sites would just give me more answers. And if I got the answer in one of them, I would report back to the other site and let everyone know (and perhaps someone else would be benefited as well). I really doubt it is a waste of time - the more input, the better. The fact that someone was a user in both websites is simply a coincidence.  I realize that Meta&nbsp;Stack&nbsp;Exchange question  exists, but apparently it involves cross-posting within Stack Exchange sites, but this is about external websites instead.  I also realize that I was told that as "advice" (since my question was not flagged or anything), but well, I am now curious: Why would anyone consider this a bad practice? What is the US Visa Waiver Program and what is an ESTA? Connecting Asus USB-N13 Wireless Adapter I'm trying to connect my desktop (running 64-bit Ubuntu 12.04) to an Airport Extreme Base Station by using an ASUS USB-N13 wireless adapter.  I plugged it in, turned on the desktop, and the adapter was immediately recognized by the system. I found my home network listed in the available networks, typed my password (with the correct encryption) and hit connect. After that, the wireless icon just flashes (propagates? emits?) indefinitely, and every couple of minutes the "Wireless Authentication Required" box pops back up.   I don't know what to do. I've seen some solutions talking about an "rt2xxx" or "rt3xxx" driver or chipset. I don't know exactly what it is, but when I typed lsmod | grep rt I got:  parport_pc rtl8192cu rtl8192c_common rtlwifi mac80211 cfg80211 parport   I'm pretty much lost. Please AskUbuntu, what do? Complex number operations: telling Mathematica variables are real What exactly is a photon? Consider the question, .  The answers say, "an elementary particle" and not much else. They don't actually answer the question. Moreover, the question is flagged as a duplicate of,  &ndash; the answers there don't tell me what a photon is either. Nor do any of the answers to  mentioned in the comments. When I search on , I can't find anything useful. Questions such as,  look promising, but bear no fruit.  say things like, "the photon is an excitation of the photon field." That tells me  nothing. Nor does the , which says:     The photon is the quantum of the electromagnetic four-potential, and therefore the massless bosonic particle associated with the electromagnetic force, commonly also called the 'particle of light'...   I'd say that's less than helpful because it gives the impression that photons are forever popping into existence and flying back and forth exerting force. This same concept is in the  too - but it isn't true. As , "Virtual particles only exist in the mathematics of the model." So, who can tell me what a real photon is, or refer me to some kind of authoritative informative definition that is accepted and trusted by particle physicists? I say all this because I think it's of paramount importance. If we have no clear idea of what a photon actually is, we lack foundation. It's like what :     Photons seem to be one of the foundation ideas of quantum mechanics, so I am concerned that without a clear definition or set of concrete examples, the basis for understanding quantum experiments is a little fuzzy.   I second that, only more so. How can we understand pair production if we don't understand what the photon is? Or the electron? Or the electromagnetic field? Or everything else? It all starts with the photon.   I will give a 400-point bounty to the least-worst answer to the question. One answer will get the bounty, even if I don't like it. And the question is this:    What exactly is a photon? Counter example for $(A \times B) \cap (C \times D) = (A \cap C ) \times (B \cap D)$ Can a character in the middle of a move action alter his movement based on a change in his surroundings? For example:      A player (speed 6) moves two squares towards a human bandit (pg. 162 MM) becoming adjacent to him, then proceeds to move around him to the right, provoking an opportunity attack. The bandit hits with his basic melee attack (+4 vs. AC; 1d8+1 damage, and the human bandit shifts 1 square), shifting one square to the left immediately.    This free shift makes it so that the PC would no longer flank the bandit at the END of his move. Can the player adjust his remaining three squares of movement so that he can once again flank the now-shifted bandit, or does he have to stick with his earlier movement designation?  This question boils down to: Is movement counted as you go, or do you say, "I am moving to here, it is within my range, and on the way to my destination 'blah' happens?" Order of general- and special linear groups over finite fields. Let $\mathbb{F}_3$ be the field with three elements. Let $n\geq 1$. How many elements do the following groups have?   $\text{GL}_n(\mathbb{F}_3)$ $\text{SL}_n(\mathbb{F}_3)$   Here GL is the , the group of invertible n×n matrices, and SL is the , the group of n×n matrices with determinant 1. I haven't logged onto my blog for years, and have, of course, forgotten the password. I click the 'Forgot' button and get a mail with a link, but that mail already says     Sorry, that key does not appear to be valid.   And sends me round the click to reset, receive a mail, click the link again etc. As if the timeout for password resets has been set to 0.5s or something.  This is a shared hosted blog, so I have full access to cPanel and all of the WP files via FTP, if that helps anything. What is the physical meaning of commutators in quantum mechanics? This is a question I've been asked several times by students and I tend to have a hard time phrasing it in terms they can understand. This is a natural question to ask and it is not usually well covered in textbooks, so I would like to know of various perspectives and explanations that I can use when teaching.  The question comes up naturally in what is usually students' second course in quantum physics / quantum mechanics. At that stage one is fairly comfortable with the concept of wavefunctions and with the Schrödinger equation, and has had some limited exposure to operators. One common case, for example, is to explain that some operators commute and that this means the corresponding observables are 'compatible' and that there exists a mutual eigenbasis; the commutation relation is usually expressed as $[A,B]=0$ but no more is said about that object.  This naturally leaves students wondering     what is, exactly, the physical significance of the object $[A,B]$ itself?   and this is not an easy question. I would like answers to address this directly, ideally at a variety of levels of abstraction and required background. Note also that I'm much more interested in the object $[A,B]$ itself than what the consequences and interpretations are when it is zero, as those are far easier and explored in much more depth in most resources.    One reason this is a hard question (and that commutators are such confusing objects for students) is that they serve a variety of purposes, with only thin connecting threads between them (at least as seen from the bottom-up perspective).   Commutation relations are usually expressed in the form $[A,B]=0$ even though, a priori, there appears to be little motivation for the introduction of such terminology. A lot of stock is placed behind the canonical commutation relation $[x,p]=i \hbar$, though it is not always clear what it means.  (In my view, the fundamental principle that this encodes is essentially de Broglie's relation $\lambda=h/p$; this is made rigorous by the  but that's quite a bit to expect a student to grasp at a first go.) From this there is a natural extension to the Heisenberg Uncertainty Principle, which in its general form includes a commutator (and an anticommutator, to make things worse). Canonically-conjugate pairs of observables are often introduced, and this is often aided by observations on commutators. (On the other hand, the energy-time and angle-angular momentum conjugacy relations cannot be expressed in terms of commutators, making things even fuzzier.) Commutators are used very frequently, for example, when studying the angular momentum algebra of quantum mechanics. It is clear they play a big role in encoding symmetries in quantum mechanics but it is hardly made clear how and why, and particularly why the combination $AB-BA$ should be important for symmetry considerations.  This becomes even more important in more rigorous treatments of quantum mechanics, where the specifics of the Hilbert space become less important and the algebra of observable operators takes centre stage. The commutator is the central operation of that algebra, but again it's not very clear why that combination should be special. An analogy is occasionally made to the Poisson brackets of hamiltonian mechanics, but this hardly helps - Poisson brackets are equally mysterious. This also ties the commutator in with time evolution, both on the classical side and via the Heisenberg equation of motion.   I can't think of any more at the moment but they are a huge number of opposing directions which can make everything very confusing, and there is rarely a uniting thread. So: what are commutators, exactly, and why are they so important? How can I write the name show in axis of 3D array using TiKz I am drawing a 3D array like the attached picture, which actually describes a multidimensional array. However, I can not put the name of the axis and take the value from the matrix like the attached picture.  This is the code that I have:  \documentclass[margin=5mm]{standalone} \usepackage{tikz} \usetikzlibrary{matrix,calc}  \begin{document} \begin{tikzpicture}[every node/.style={anchor=north east,fill=white,minimum width=1.4cm,minimum height=7mm}] \matrix (mA) [draw,matrix of math nodes] { (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ };  \matrix (mB) [draw,matrix of math nodes] at ($(mA.south west)+(1.5,0.7)$) { (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ };  \matrix (mC) [draw,matrix of math nodes] at ($(mB.south west)+(1.5,0.7)$) { (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ (1,1,3) &amp; (1,1,3) &amp; (1,1,3) &amp; (1,1,3) \\ };  \draw[dashed](mA.north east)--(mC.north east); \draw[dashed](mA.north west)--(mC.north west); \draw[dashed](mA.south east)--(mC.south east); \end{tikzpicture}   \end{document}