Struts Pass Login Screen Form Data To Next Page Action - struts

Basically I have your standard login page for a struts application.
You enter password and Username and post back to the server, whilst moving onto the main application page.
I have java code within the main page that requires the login data from the last page to populate the table on screen. I have tried ActionRedirect but it keeps bring back nullpointerexception:
ActionRedirect redirect =
new ActionRedirect(mapping.findForward(SUCCESS));
redirect.addParameter("userName",loginForm.getUserName());
return redirect;
here is the struts config:
<action input="/login.jsp" name="LoginForm" path="/Login" scope="request" type="com.myapp.struts.LoginAction" validate="false">
<result name="success" type="redirect-action">
<param name="location">/timesheet.jsp</param>
<param name="parse">false</param>
</result>
<forward name="failure" path="/login.jsp" />
</action>
and the error comes back as:
WARNING: Unable to find 'timesheet.jsp' forward.
and yes I have tried to add another forward relating to 'SUCCESS' but again it fails.

Struts config was missing forward, had put the result section within the forward param and thats why its wasnt working

Related

Nuxeo: after activating the Anonymous User can't log in

My goal is to add the anonymous authentication to Nuxeo web ui.
I followed the steps on https://doc.nuxeo.com/nxdoc/how-to-define-public-pages-viewable-by-anonymous-users/.
Created anonymous-auth-config.xml with the following content:
<component name="org.nuxeo.ecm.platform.login.anonymous.config">
<!-- Add an Anonymous user -->
<extension target="org.nuxeo.ecm.platform.usermanager.UserService"
point="userManager">
<userManager>
<users>
<anonymousUser id="Guest">
<property name="firstName">Guest</property>
<property name="lastName">User</property>
</anonymousUser>
</users>
</userManager>
</extension>
</component>
First I copied the file into the C:\Nuxeo\nxserver\config then try folder C:\Nuxeo\templates\common\config.
Modified nuxeo.conf and set nuxeo.user.anonymous.enable=true.
Restart the application server.
Now I can only enter the web ui as Anonymous user, but can't log in as Administrator or any other valid user.
There is forceAnonymousLogin=true query string in the url now by default.
I'm not sure should I change and how the authenticationChain as stated in another link: https://doc.nuxeo.com/nxdoc/using-anonymous-authentication/
Thanks for your help in advance!

How to configure custom url on Google Oauth2

I'm trying to set up login with google on my react native app.
I set up my custom uri on Android as such:
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.myapp" android:host='app'/>
</intent-filter>
And if I launch the app using com.myapp://app, everything works perfectly.
https://developers.google.com/identity/protocols/OAuth2InstalledApp#creatingcred
According to these docs, the redirect_uri can be a custom one. "Note that the path should begin with a single slash, which is different from regular HTTP URLs." The only way the redirect works without issue is this:
Linking.openURL([
'https://accounts.google.com/o/oauth2/auth',
'?response_type=code',
'&client_id=' + clientID,
'&redirect_uri=com.myapp:/app',
'&scope=https://www.googleapis.com/auth/plus.login',
'+https://www.googleapis.com/auth/userinfo.email',
'+https://www.googleapis.com/auth/userinfo.profile'
].join(''))
Except when I type my password and accept the terms, I get the following error:
The webpage at com.myapp:/app?code=XXXX could not be loaded because:
net:: ERROR_UNKNOWN_URL_SCHEME
Where am I going wrong?

Dynamic url generation using Struts 2 using version [struts2-core-2.0.11.1] [duplicate]

I am working on a project where I want to provide unique URL for each user.
For example:
www.SocialNetwork.com/jhon
www.SocialNetwork.com/jasmine
So far I'm able to achieve this:
www.SocialNetwork.com/profiles/jasmine
here profiles is my action where I can get the user name by
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.patternMatcher" value="namedVariable"/>
<action name="profiles/{username}" class="com.example.actions.ViewProfileAction">
<result name="input">/WEB-INF/jsp/profile.jsp</result>
</action>
but I want to achieve something like this:
www.SocialNetwork.com/jasmine
Just use domain name and username.
Like Twitter does:
www.twitter.com/username
How to achieve this?
If you want to use named patterns in wildcard mapping then you should configure following in the struts.xml:
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
<constant name="struts.patternMatcher" value="regex"/>
now assume com.example.actions.ViewProfileAction bean has a property username, and method execute that returns a SUCCESS result. Then you can map the action in the root namespace "/" configured to your package.
<action name="{username}" class="com.example.actions.ViewProfileAction">
<result>/WEB-INF/jsp/profile.jsp</result>
</action>
you can get the name in the JSP using OGNL
<s:property value="username"/>
Also note that you should deploy to the root context to have
your.domain.com/username mapped to your action.
Try this out. It may work. Use Freemarker USE $.
<action name="profiles/${username}" class="com.example.actions.ViewProfileAction">
<result name="input">/WEB-INF/jsp/profile.jsp</result>
</action>
It may work

FreeSWITCH dialplan to check if enduser is registered for WebRTC to SIP

I am trying to use FreesSWITCH with the Mizu WebRTC to SIP client.
If the called user is registered to FreesSWITCH than the call should be routed to the user. Otherwise the call should be routed to outbound SIP server.
The problem is that I am unable to find out from the FreesSWITCH dialplan if user is currently registered or not. I have the following in the default dialplan:
<!-- If the user doesn't exist, forward to outbound SIP -->
<extension name="check_user">
<condition field="${user_exists(id ${destination_number} $${domain})}" expression="false">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
<!-- If the user is registered, forward the call to them -->
<extension name="check_user_registered">
<condition field="${sofia_contact(profile/${destination_number}#$${domain})}" expression="(.+)">
<action application="bridge" data="$1" />
</condition>
</extension>
<!-- Otherwise forward to outbound SIP -->
<extension name="outbound">
<condition field="destination_number" expression="^.*$">
<action application="bridge" data="sofia/gateway/asterisk/${destination_number}"/>
</condition>
</extension>
However the "check_user_registered" rule seems to be passed even if the user is not actually registered from the Webphone, so the FreesSWITCH will go to send the call to the user, but then finds out that it is not registered and the call fails. (I think that WebRTC doesn't matter here, this would be the same for SIP to SIP calls).This is the relevant log:
Dialplan: sofia/internal/2233#81.12.74.77 Regex (PASS) [check_user_registered] ${sofia_contact(profile/${destination_number}#rtc.mizu-voip.com)}(error/user_not_registered) =~ /(.+)/ break=on-false
Dialplan: sofia/internal/2233#81.12.74.77 Action bridge(error/user_not_registered)
Freeswitch hangup with 480 Temporarily Unavailable / USER_NOT_REGISTERED
Do you know any reliable way to query from FreesSWITCH dialplan the user registered status?
Use sofia_contact to know whether the called person is registered or not.
For example:
sofia_contact 1001 return this to me
sofia/internal/sip:1001#myip_address:52573;rinstance=a1b0a9cfddc6a8c3;transport=TCP
sofia_contact 1002
error/user_not_registered
Another option is to store the registered user into database and using odbc query fetch the result and compare.(That will be a brilliant idea)
sofia_contact returns the string error/user_not_registered if the user is not registered. And in your condition, you check the returned value against .+ regular expression. Of course the error string would match too.
You need a condition which matches on ^error, and then define the action and anti-action.

How to redirect logged in user to the same page using spring security?

I have implemented my website using spring security.
I have added default-target-url in form-login tag:
<security:form-login login-page="/pages/dashboard.action" default-target-url="/welcome.action" authentication-failure-url="/pages/dashboard.action?error=true" />
So when ever user successfully logs in it will be redirected to the page which is defined by mapping given in default-target-url.
But I dont want this, I have log-in button at many places and i want user to directed to the same page from where he is logging in.
Can any one help me with this?
my dispather-servlet.xml:
<security:http use-expressions="true">
<security:intercept-url pattern="/IGG/citizen/*" access="hasRole('IGG_CITIZEN')" />
<security:form-login login-page="/pages/dashboard.action" default-target-url="/welcome.action" authentication-failure-url="/pages/dashboard.action?error=true" />
<security:logout logout-success-url="/pages/dashboard.action" delete-cookies="JSESSIONID" />
<security:anonymous username="guest" granted-authority="ROLE_GUEST"/>
<security:session-management invalid-session-url="/pages/dashboard.action"/>
<security:remember-me/>
<security:access-denied-handler delete-cookies="JSESSIONID"/>
</security:http>
Use bean SavedRequestAwareAuthenticationSuccessHandler as your success handler:
<bean id="successHandler"
class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"
<property name="defaultTargetUrl" value="/welcome.action"/>
</bean>
And refer to it from the form-login using authentication-success-handler-ref parameter:
<security:form-login authentication-success-handler-ref="successHandler"/>
The SavedRequestAwareAuthenticationSuccessHandler uses page which user tried to access before initialization of the authentication process as the default landing page. When it's not available the defaultTargetUrl is used instead. The "stored page" value is set inside ExceptionTranslationFilter.