Procedure to add new login page:

tastelessbeachInternet and Web Development

Nov 12, 2013 (3 years and 7 months ago)

69 views

Procedure to add new login page:

Create a new login jsp page. Example entry.jsp

Keep it in

jasperserver
-
war/src/main/webapp/WEB
-
INF/jsp/modules/login/

Add entry of property of page in
urlHandlerMapping

bean

section in

jasper
-
servlet.xml

in
anonymous pages

section as follows:

<
bean

id
=
"urlHandlerMapping"

class
=
"org.springframework.beans.factory.config.PropertiesFactoryBean"
>


<
property

name
=
"properties"
>


<
props
>


<!
--

note: any new anonymous or user pages must be added


to the filterInvocationInterceptor bean in applicationContext
-
security.xml


All other pages require ROLE_ADMINISTRATOR to access


--
>





<
prop

key
=
"/fileview/**"
>
jsFileViewContr
</
prop
>




<!
--

anonymous pages
--
>


<
prop

key
=
"/entry.html"
>
jsCommContr
</
prop
>


<
prop

key
=
"/login.html"
>
jsCommContr
</
prop
>


<
prop

key
=
"/logout.html"
>
jsCommContr
</
prop
>


Also add following code in same file
in
paramResolver

bean

section.


<!
--

js

mac

method name resolver
--
>


<
bean

id
=
"paramResolver"

class
=
"org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver"
>


<
property

name
=
"mappings"
>


<
props
>



<
prop

key
=
"/entry.html"
>
entry
</
prop
>



<
prop

key
=
"/home.html"
>
homePage
</
prop
>



<
prop

key
=
"/login.html"
>
login
</
prop
>


<
prop

key
=
"/entry.html"
>
jsCommContr
</
prop
> This will call controller servlet which is
mapped as


<
bean

id
=
"
jsCommContr"
c
lass
=
"com.jaspersoft.jasperserver.war.control.JSCommonController"
>


Add following code in
com.jaspersoft.jasperserver.war.control.JSCommonController.java


public

ModelAndView entry(HttpServletRequest req, HttpServletResponse res)




throws

ServletException {



setupLoginPage(req);




return

new

ModelAndView(
"modules/login/entry"
);


}


This will load
entry.jsp

from folder
modules/login/

folder for url
localhost:8080/jasperserver/entry.html


We also have to add this page entry to the

filterInvocationInterceptor
bean in
applicationContext
-
security
-
web
.xml


Modify
applicationContext
-
security.xml
as follows:


<
bean

id
=
"filterInvocationInterceptor"

class
=
"org.springframework.security.intercept.web.FilterSecurityInterceptor"
>


<
property

name
=
"authenticationManager"
>


<
ref

bean
=
"authenticationManager"
/>


</
property
>


<
property

name
=
"accessDecisionManager"
>


<
ref

bean
=
"httpRequestAccessDecisionManager"
/>


</
property
>


<!
--

<
property name="runAsManager"><ref bean="runAsManager"/></property>
--
>


<
property

name
=
"objectDefinitionSource"
>


<
value
>


CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON


PATTERN_TYPE_APACHE_ANT


/entry.html=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMINISTRATOR


/login.html=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMINISTRATOR


/logout.html=ROLE_ANONYMOUS,ROLE_USER,ROLE_ADMINISTRATOR,IS_AUTHENTICATED_FULLY


Build the war file again and
redeploy it on server.

Now you can use
http://localhost:8080/jasperserver/entry.html

as login page.

To change UI of login page customize entry.jsp and pageSpecific.css.



Locations of files:


en
try.jsp

:
-

/jasperserver/jasperserver
-
war/src/main/webapp/WEB
-
INF/jsp/modules/login/entry.jsp


jasperserver
-
servlet.xml

:
-

/jasperserver/jasperserver
-
war/src/main/webapp/WEB
-
INF/jasperserver
-
servlet.xml


JSCommonController.java

:
-

Physical path
:

/jasperser
ver/jasperserver
-
war
-
jar/src/main/java/com/jaspersoft/jasperserver/war/control/JSCommonController.java

Package Path:

com.jaspersoft.jasperserver.war.control/

JSCommonController


applicationContext
-
security
-
web.xml

:
-

/jasperserver/jasperserver
-
war/shared
-
config/applicationContext
-
security
-
web.xml