1 package org.kuali.ole.sip2.requestParser;
2
3 import org.apache.log4j.Logger;
4 import org.kuali.ole.sip2.constants.OLESIP2Constants;
5
6
7
8
9 public class OLESIP2LoginRequestParser extends OLESIP2RequestParser {
10
11 private static final Logger LOG = Logger.getLogger(OLESIP2LoginRequestParser.class);
12
13 public Integer uidAlgorithm;
14 public Integer passwordAlgorithm;
15 public String loginUserId;
16 public String loginPassword;
17 public String locationCode;
18
19 public OLESIP2LoginRequestParser(String requestData) {
20 this.parseLoginRequest(requestData);
21 }
22
23
24 public void parseLoginRequest(String requestData) {
25
26 String[] requestDataArray = requestData.split("\\|");
27 LOG.info("Entry OLESIP2LoginRequestParser.parseLoginRequest(String requestData)");
28
29 try {
30 for (String data : requestDataArray) {
31 if (data.startsWith(OLESIP2Constants.LOGIN_REQUEST)) {
32 code = data.substring(0, 2);
33 uidAlgorithm = stringToInt(String.valueOf(data.charAt(2)));
34 passwordAlgorithm = stringToInt(String.valueOf(data.charAt(3)));
35 loginUserId = data.substring(6);
36 }
37 if (data.startsWith(OLESIP2Constants.LOGIN_PWD_ID_CODE)) {
38 loginPassword = (data.replaceFirst(OLESIP2Constants.LOGIN_PWD_ID_CODE, "")).trim();
39 }
40 if (data.startsWith(OLESIP2Constants.LOCATION_CODE_SIP)) {
41 locationCode = (data.replaceFirst(OLESIP2Constants.LOCATION_CODE_SIP, "")).trim();
42 }
43 if (data.startsWith(OLESIP2Constants.SEQUENCE_NUM_CODE)) {
44 sequenceNum = data.substring(2, 5);
45 checkSum = data.substring(5);
46 }
47 }
48
49 } catch (Exception e) {
50 LOG.error(e.getMessage(), e);
51 }
52 LOG.info("Entry OLESIP2LoginRequestParser.parseLoginRequest(String requestData)");
53 }
54
55
56 public Integer getUidAlgorithm() {
57 return uidAlgorithm;
58 }
59
60 public void setUidAlgorithm(Integer uidAlgorithm) {
61 this.uidAlgorithm = uidAlgorithm;
62 }
63
64 public Integer getPasswordAlgorithm() {
65 return passwordAlgorithm;
66 }
67
68 public void setPasswordAlgorithm(Integer passwordAlgorithm) {
69 this.passwordAlgorithm = passwordAlgorithm;
70 }
71
72 public String getLoginUserId() {
73 return loginUserId;
74 }
75
76 public void setLoginUserId(String loginUserId) {
77 this.loginUserId = loginUserId;
78 }
79
80 public String getLocationCode() {
81 return locationCode;
82 }
83
84 public void setLocationCode(String locationCode) {
85 this.locationCode = locationCode;
86 }
87
88 public String getLoginPassword() {
89 return loginPassword;
90 }
91
92 public void setLoginPassword(String loginPassword) {
93 this.loginPassword = loginPassword;
94 }
95 }