You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by GitBox <gi...@apache.org> on 2021/09/01 09:29:11 UTC
[GitHub] [james-project] Arsnael commented on a change in pull request #630: JAMES-3643 Local part resolution with virtual hosting
Arsnael commented on a change in pull request #630:
URL: https://github.com/apache/james-project/pull/630#discussion_r699182636
##########
File path: server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/CassandraLocalPartLookupRepository.java
##########
@@ -0,0 +1,69 @@
+package org.apache.james.user.cassandra;
Review comment:
Missing license
##########
File path: mailbox/store/src/main/java/org/apache/james/mailbox/store/SessionProviderImpl.java
##########
@@ -59,16 +62,14 @@ public MailboxSession createSystemSession(Username userName) {
@Override
public MailboxSession login(Username userid, String passwd) throws MailboxException {
- if (isValidLogin(userid, passwd)) {
- return createSession(userid, MailboxSession.SessionType.User);
- } else {
- throw new BadCredentialsException();
- }
+ return validLogin(userid, passwd)
+ .map(Throwing.function(username -> createSession(username, MailboxSession.SessionType.User)))
+ .orElseThrow(BadCredentialsException::new);
}
@Override
public MailboxSession loginAsOtherUser(Username adminUserid, String passwd, Username otherUserId) throws MailboxException {
- if (! isValidLogin(adminUserid, passwd)) {
+ if (! validLogin(adminUserid, passwd).map(adminUserid::equals).orElse(false)) {
Review comment:
```suggestion
if (!validLogin(adminUserid, passwd).map(adminUserid::equals).orElse(false)) {
```
##########
File path: server/data/data-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersDAO.java
##########
@@ -103,6 +104,28 @@ public void init() {
}
}
+ @Override
+ public List<Username> retrieveUserFromLocalPart(LocalPart localPart) {
+ EntityManager entityManager = entityManagerFactory.createEntityManager();
+
+ try {
+ List<JPAUser> results = entityManager
+ .createNamedQuery("findUserByLocalPart", JPAUser.class)
+ .setParameter("name", localPart.asString() + "@%")
+ .getResultList();
+ return results.stream()
+ .map(JPAUser::getUserName)
+ .collect(ImmutableList.toImmutableList());
Review comment:
Can't do it in one shot? Like:
```
return entityManager
.createNamedQuery("findUserByLocalPart", JPAUser.class)
.setParameter("name", localPart.asString() + "@%")
.getResultList()
.stream()
.map(JPAUser::getUserName)
.collect(ImmutableList.toImmutableList());
```
##########
File path: server/data/data-cassandra/src/main/java/org/apache/james/user/cassandra/LocalPartLookupModule.java
##########
@@ -0,0 +1,21 @@
+package org.apache.james.user.cassandra;
Review comment:
Missing license
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org