MCPcopy Create free account
hub / github.com/annmuor/jnode / getAndCheckLink

Method getAndCheckLink

jnode-core/src/jnode/robot/AbstractRobot.java:57–95  ·  view source on GitHub ↗
(FtnMessage fmsg)

Source from the content-addressed store, hash-verified

55 protected abstract String getPasswordOption();
56
57 protected Link getAndCheckLink(FtnMessage fmsg) {
58 if (fmsg.getPkt() != null) {
59 if (!fmsg.getPkt().getFromAddr().equals(fmsg.getFromAddr())) {
60 FtnTools.writeReply(
61 fmsg,
62 ACCESS_DENIED,
63 MessageFormat.format(WRONG_PATH, fmsg.getPkt()
64 .getFromAddr().toString(), getRobotName()));
65 return null;
66 }
67 }
68 FtnAddress linkAddress = fmsg.getFromAddr();
69 Matcher m = aslink.matcher(fmsg.getText());
70 if (m.find()) {
71 try {
72 linkAddress = new FtnAddress(m.group(1));
73 } catch (NumberFormatException e) {
74 FtnTools.writeReply(fmsg, ACCESS_DENIED, WRONG_ASLINK);
75 return null;
76 }
77 }
78 Link link = FtnTools.getLinkByFtnAddress(linkAddress);
79 if (link == null) {
80 FtnTools.writeReply(fmsg, ACCESS_DENIED,
81 YOU_ARE_NOT_IN_LINKS_OF_ORIGIN);
82 return null;
83 }
84 if (!isEnabled(link)) {
85 FtnTools.writeReply(fmsg, YOU_ARE_NOT_WELCOME, MessageFormat
86 .format(SORRY_0_IS_OFF_FOR_YOU, getRobotName()));
87 return null;
88 }
89 String password = getPassword(link);
90 if (!password.equals(fmsg.getSubject())) {
91 FtnTools.writeReply(fmsg, ACCESS_DENIED, WRONG_PASSWORD);
92 return null;
93 }
94 return link;
95 }
96
97 protected String getPassword(Link link) {
98 if (link == null) {

Callers 3

executeMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80

Calls 13

writeReplyMethod · 0.95
getRobotNameMethod · 0.95
getLinkByFtnAddressMethod · 0.95
isEnabledMethod · 0.95
getPasswordMethod · 0.95
getPktMethod · 0.80
formatMethod · 0.80
findMethod · 0.80
getTextMethod · 0.65
getSubjectMethod · 0.65
equalsMethod · 0.45
getFromAddrMethod · 0.45

Tested by

no test coverage detected