Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.73 KB | None | 0 0
  1. <context-param>
  2. <param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
  3. <param-value>true</param-value>
  4. </context-param>
  5. <context-param>
  6. <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
  7. <param-value>true</param-value>
  8. </context-param>
  9. <context-param>
  10. <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
  11. <param-value>server</param-value>
  12. </context-param>
  13. <context-param>
  14. <param-name>javax.faces.CONFIG_FILES</param-name>
  15. <param-value>/WEB-INF/faces-config.xml</param-value>
  16. </context-param>
  17. <context-param>
  18. <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
  19. <param-value>.jsp</param-value>
  20. </context-param>
  21. <context-param>
  22. <param-name>com.ibm.faces.DISABLE_JWL_MULTIPART_CONTEXT</param-name>
  23. <param-value>false</param-value>
  24. </context-param>
  25. <context-param>
  26. <param-name>com.ibm.faces.RESOURCE_EXPIRE_MS</param-name>
  27. <param-value>31536000000</param-value>
  28. </context-param>
  29. <context-param>
  30. <param-name>com.ibm.faces.DATETIME_ASSIST_STRICTNESS</param-name>
  31. <param-value>1</param-value>
  32. </context-param>
  33. <context-param>
  34. <param-name>com.ibm.faces.NUMBER_ASSIST_STRICTNESS</param-name>
  35. <param-value>1</param-value>
  36. </context-param>
  37. <context-param>
  38. <param-name>com.ibm.faces.USE_UNENCODED_CONTEXT_PATH</param-name>
  39. <param-value></param-value>
  40. </context-param>
  41. <context-param>
  42. <param-name>com.ibm.faces.JS_RESOURCE_SERVLET_CACHE</param-name>
  43. <param-value>false</param-value>
  44. </context-param>
  45. <context-param>
  46. <param-name>com.ibm.faces.ENCODING_MAPPING</param-name>
  47. <param-value>converter.properties</param-value>
  48. </context-param>
  49. <context-param>
  50. <param-name>com.ibm.faces.USE_HXCLIENT_FULL</param-name>
  51. <param-value>false</param-value>
  52. </context-param>
  53. <context-param>
  54. <param-name>com.ibm.faces.MAX_REQUEST_CONTENT_SIZE</param-name>
  55. <param-value>0</param-value>
  56. </context-param>
  57.  
  58. <context-param>
  59. <param-name>com.sun.faces.numberOfLogicalViews</param-name>
  60. <param-value>100</param-value>
  61. </context-param>
  62. <context-param>
  63. <param-name>com.sun.faces.numberOfViewsInSession</param-name>
  64. <param-value>100</param-value>
  65. </context-param>
  66. <context-param>
  67. <param-name>com.sun.faces.displayConfiguration</param-name>
  68. <param-value>false</param-value>
  69. </context-param>
  70. <listener>
  71. <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  72. </listener>
  73. <filter>
  74. <display-name>AaFilter</display-name>
  75. <filter-name>AaFilter</filter-name>
  76. <filter-class>orgmanager.AaFilter</filter-class>
  77. <init-param>
  78. <param-name>loginpage</param-name>
  79. <param-value>/orgmanagerWeb/faces/Login.jsp</param-value>
  80. </init-param>
  81. <init-param>
  82. <param-name>logoutpage</param-name>
  83. <param-value>/orgmanagerWeb/faces/Logout.jsp</param-value>
  84. </init-param>
  85. </filter>
  86. <filter-mapping>
  87. <filter-name>AaFilter</filter-name>
  88. <url-pattern>/faces/Jsp/*</url-pattern>
  89. </filter-mapping>
  90. <servlet>
  91. <servlet-name>Faces Servlet</servlet-name>
  92. <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  93. <load-on-startup>1</load-on-startup>
  94. </servlet>
  95. <servlet-mapping>
  96. <servlet-name>Faces Servlet</servlet-name>
  97. <url-pattern>/faces/*</url-pattern>
  98. </servlet-mapping>
  99. <servlet-mapping>
  100. <servlet-name>Faces Servlet</servlet-name>
  101. <url-pattern>*.faces</url-pattern>
  102. </servlet-mapping>
  103. <welcome-file-list>
  104. <welcome-file>index.html</welcome-file>
  105. <welcome-file>index.htm</welcome-file>
  106. <welcome-file>index.jsp</welcome-file>
  107. <welcome-file>default.html</welcome-file>
  108. <welcome-file>default.htm</welcome-file>
  109. <welcome-file>default.jsp</welcome-file>
  110. </welcome-file-list>
  111. <jsp-config>
  112. <taglib>
  113. <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
  114. <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
  115. </taglib>
  116. </jsp-config>
  117.  
  118. <error-page>
  119. <error-code>500</error-code>
  120. <location>/error.jsp</location>
  121. </error-page>
  122.  
  123. <jsp-config>
  124. <taglib>
  125. <taglib-uri>http://www.ibm.com/jsf/html_extended</taglib-uri>
  126. <taglib-location>/WEB-INF/tld/html_extended.tld</taglib-location>
  127. </taglib>
  128. </jsp-config>
  129.  
  130. <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
  131. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  132. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
  133. version="1.2">
  134.  
  135. <application>
  136. <message-bundle>Messages</message-bundle>
  137. <state-manager>com.ibm.faces.application.DevelopmentStateManager</state-manager>
  138. <property-resolver>com.ibm.faces.databind.SelectItemsPropResolver</property-resolver>
  139. <variable-resolver>com.ibm.faces.databind.SelectItemsVarResolver</variable-resolver>
  140. </application>
  141. <factory>
  142. <faces-context-factory>com.ibm.faces.context.AjaxFacesContextFactory</faces-context-factory>
  143. <render-kit-factory>com.ibm.faces.renderkit.AjaxRenderKitFactory</render-kit-factory>
  144. </factory>
  145.  
  146. <managed-bean>
  147. <managed-bean-name>aaController</managed-bean-name>
  148. <managed-bean-class>orgmanager.aaController</managed-bean-class>
  149. <managed-bean-scope>session</managed-bean-scope>
  150. <managed-property>
  151. <property-name>role</property-name>
  152. <property-class>java.lang.String</property-class>
  153. <value>INTERNAL</value>
  154. </managed-property>
  155. </managed-bean>
  156.  
  157. <navigation-rule>
  158. <from-view-id>/Login.jsp</from-view-id>
  159. <navigation-case>
  160. <from-outcome>ok</from-outcome>
  161. <to-view-id>/Jsp/ManagerFrontpage.jsp</to-view-id>
  162. <redirect />
  163. </navigation-case>
  164. </navigation-rule>
  165. <navigation-rule>
  166. <navigation-case>
  167. <from-action>#{aaController.logout}</from-action>
  168. <from-outcome>ok</from-outcome>
  169. <to-view-id>/Logout.jsp</to-view-id>
  170. <redirect />
  171. </navigation-case>
  172. </navigation-rule>
  173.  
  174. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  175. <%@ taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
  176. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  177.  
  178. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  179. <HTML>
  180. <HEAD>
  181. <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  182. <META name="GENERATOR" content="IBM Software Development Platform">
  183. <META http-equiv="Content-Style-Type" content="text/css">
  184. <LINK href="theme/Master.css" rel="stylesheet" type="text/css">
  185. <TITLE>Organisation Manager</TITLE>
  186. <LINK rel="stylesheet" href="theme/standardiwsadpan.css"
  187. type="text/css">
  188. <LINK rel="stylesheet" type="text/css" href="theme/stylesheet.css"
  189. title="Style">
  190.  
  191. </HEAD>
  192. <f:view>
  193. <BODY>
  194.  
  195. <h:form styleClass="form" id="loginform">
  196.  
  197. <TABLE border="0" class="SisaankirjausTaulukko">
  198. <TBODY>
  199. <TR>
  200. <TD colspan="2" align="center" class="Mustalihavoitu">Organisation manager</TD>
  201.  
  202. </TR>
  203. <TR>
  204. <TD colspan="2" height="5"><IMG border="0" src="kuvat/tyhja.gif"></TD>
  205.  
  206. </TR>
  207.  
  208. <TR>
  209. <TD class="Mustalihavoitu">Login</TD>
  210. <TD><h:inputText styleClass="inputText" tabindex="1" id="kayttajatunnus" size="8"
  211. value="#{aaController.loginView.login}"></h:inputText></TD>
  212. </TR>
  213. <TR>
  214. <TD class="Mustalihavoitu">Password</TD>
  215. <TD><h:inputSecret styleClass="inputText" tabindex="2" id="password" size="8"
  216. value="#{aaController.loginView.password}"></h:inputSecret></TD>
  217. </TR>
  218. <TR>
  219. <TD colspan="2" height="5"><IMG border="0" src="kuvat/tyhja.gif"></TD>
  220.  
  221. </TR>
  222. <TR>
  223. <TD colspan="2" align="right"><hx:commandExButton type="submit"
  224. value="Sign in" styleClass="submit-button90"
  225. id="button1" action="#{aaController.login}"
  226. tabindex="3"></hx:commandExButton></TD>
  227. </TR>
  228. </TBODY>
  229. </TABLE>
  230. </h:form>
  231. </BODY>
  232.  
  233. public class AaController extends BaseController {
  234. public static final int ROLE_INTERNAL = 1;
  235. public static final int ROLE_EXTERNAL = 2;
  236.  
  237. private loginView loginView = new loginView();
  238. private int role;
  239.  
  240. public String login() throws OrgHallintaException {
  241. String result = null;
  242. AaFasadi aaFasadi = new AaFasadi();
  243. log.info("Loggin in");
  244.  
  245.  
  246. if (aaFasadi.login(loginView.getLogin(), loginView.getPassword())) {
  247.  
  248. if (aaFasadi.getEnviroment().trim().equals("PRODUCTION")) {
  249. loginView.setEnviroment(" ");
  250. } else {
  251. loginView.setEnviroment(aaFasadi.getEnviroment());
  252. }
  253. result = "ok";
  254.  
  255. } else {
  256. result = "error";
  257. }
  258.  
  259. return result;
  260. }
  261.  
  262. public String logout() {
  263. AaFasadi aaFasadi = new AaFasadi();
  264. aaFasadi.logout();
  265. return "ok";
  266. }
  267.  
  268. public loginView getloginView() {
  269. return loginView;
  270. }
  271.  
  272. public Kayttaja getUser() {
  273. return AaFasadi.getUser();
  274. }
  275.  
  276. public class AaFasadi {
  277.  
  278. private String enviroment="";
  279.  
  280. private static final String USER_SESSION_KEY = "orgmanager.User";
  281.  
  282. public static User getUser() {
  283. ServletRequest req = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
  284. return getUser(req);
  285. }
  286.  
  287. public static User getUser(ServletRequest req) {
  288. HttpServletRequest request = (HttpServletRequest) req;
  289.  
  290. User user = (User) request.getSession(true).getAttribute(USER_SESSION_KEY);
  291.  
  292. return user;
  293.  
  294. }
  295.  
  296. public boolean login(String LoginName, String password) throws OrgHallintaException {
  297.  
  298. User user = null;
  299.  
  300. try {
  301. PersonelLoginTask personelLoginTask = new PersonelLoginTask();
  302. PersonelLoginView personelLoginView = toimihenkiloSisaankirjausTehtava.execute(LoginName.toUpperCase(), password);
  303.  
  304. if (personelLoginView != null) {
  305. if (personelLoginView.getEnviroment().trim().equals("PRODUCTION"))
  306. personelLoginView.setEnviroment(" ");
  307. User = new DefaultUserImpl(personelLoginView);
  308. Enviroment = personelLoginView.getEnviroment();
  309. }
  310.  
  311. } catch (TehtavanHallintaException e) {
  312. System.out.println("User " + Usertunnus + " Login failed " + e);
  313. }
  314.  
  315.  
  316. if (User != null) {
  317.  
  318. ServletRequest req = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
  319. HttpServletRequest request = (HttpServletRequest) req;
  320. request.getSession(true).setAttribute(User_SESSION_KEY, User);
  321.  
  322. return true;
  323. } else {
  324. return false;
  325. }
  326. }
  327.  
  328. public void logout() {
  329. ServletRequest req = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
  330. HttpServletRequest request = (HttpServletRequest) req;
  331. request.getSession(true).removeAttribute(User_SESSION_KEY);
  332. request.getSession().invalidate();
  333. }
  334.  
  335.  
  336.  
  337. public String getEnviroment() {
  338. return enviroment;
  339. }
  340.  
  341. public void setEnviroment(String ymparisto) {
  342. this.enviroment = enviroment;
  343. }
  344.  
  345. public class loginView extends BaseView {
  346.  
  347. private String login;
  348. private String password;
  349. private String Enviroment;
  350. private Date date = new Date(System.currentTimeMillis());
  351.  
  352.  
  353.  
  354.  
  355. public String getlogin() {
  356. return login;
  357. }
  358. public void setlogin(String login) {
  359. this.login = login;
  360. }
  361. public String getpassword() {
  362. return password;
  363. }
  364. public void setpassword(String password) {
  365. this.password = password;
  366. }
  367.  
  368. public String getEnviroment() {
  369. return Enviroment;
  370. }
  371.  
  372. public void setEnviroment(String Enviroment) {
  373. this.Enviroment = Enviroment;
  374. }
  375.  
  376.  
  377. public void setDate(Date date) {
  378. this.date = date;
  379. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement