Search in sources :

Example 1 with IdentityImpl

use of org.olat.basesecurity.IdentityImpl in project OpenOLAT by OpenOLAT.

the class MailManagerImpl method appendRecipients.

private void appendRecipients(DBMailImpl mail, List<ContactList> ccLists, List<Address> toAddress, List<Address> ccAddress, boolean visible, boolean makeRealMail, MailerResult result) throws AddressException {
    // append cc/bcc recipients
    if (ccLists != null && !ccLists.isEmpty()) {
        for (ContactList contactList : ccLists) {
            if (makeRealMail && StringHelper.containsNonWhitespace(contactList.getName())) {
                Address[] groupAddress = InternetAddress.parse(contactList.getRFC2822Name() + ";");
                if (groupAddress != null && groupAddress.length > 0) {
                    for (Address groupAdd : groupAddress) {
                        toAddress.add(groupAdd);
                    }
                }
            }
            for (String email : contactList.getStringEmails().values()) {
                DBMailRecipient recipient = new DBMailRecipient();
                recipient.setEmailAddress(email);
                recipient.setGroup(contactList.getName());
                recipient.setVisible(visible);
                recipient.setDeleted(Boolean.FALSE);
                recipient.setMarked(Boolean.FALSE);
                recipient.setRead(Boolean.FALSE);
                mail.getRecipients().add(recipient);
                if (makeRealMail) {
                    createAddress(ccAddress, recipient, false, result, false);
                }
            }
            for (Identity identityEmail : contactList.getIdentiEmails().values()) {
                DBMailRecipient recipient = new DBMailRecipient();
                if (identityEmail instanceof IdentityImpl) {
                    recipient.setRecipient(identityEmail);
                } else {
                    recipient.setEmailAddress(identityEmail.getUser().getProperty(UserConstants.EMAIL, null));
                }
                recipient.setGroup(contactList.getName());
                recipient.setVisible(visible);
                recipient.setDeleted(Boolean.FALSE);
                recipient.setMarked(Boolean.FALSE);
                recipient.setRead(Boolean.FALSE);
                mail.getRecipients().add(recipient);
                if (makeRealMail) {
                    createAddress(ccAddress, recipient, false, result, false);
                }
            }
        }
    }
}
Also used : InternetAddress(javax.mail.internet.InternetAddress) Address(javax.mail.Address) IdentityImpl(org.olat.basesecurity.IdentityImpl) ContactList(org.olat.core.util.mail.ContactList) Identity(org.olat.core.id.Identity) DBMailRecipient(org.olat.core.util.mail.model.DBMailRecipient)

Example 2 with IdentityImpl

use of org.olat.basesecurity.IdentityImpl in project openolat by klemens.

the class EdubaseManagerImplTest method getUserIdShouldConcatIssuerAndIdentityName.

@Test
public void getUserIdShouldConcatIssuerAndIdentityName() {
    String userName = "user";
    IdentityImpl identity = new IdentityImpl();
    identity.setName(userName);
    String providerName = "OLAT";
    String issuerIdentifier = "https://issuer.abc";
    when(identityEnvironmentMock.getIdentity()).thenReturn(identity);
    when(identityEnvironmentMock.getAttributes().get(AuthHelper.ATTRIBUTE_AUTHPROVIDER)).thenReturn(providerName);
    when(authenticationProviderMock.getIssuerIdentifier(identityEnvironmentMock)).thenReturn(issuerIdentifier);
    when(loginModulMock.getAuthenticationProvider(providerName)).thenReturn(authenticationProviderMock);
    String userID = sut.getUserId(identityEnvironmentMock);
    String expectedUserId = issuerIdentifier.concat("#").concat(userName);
    assertThat(userID).isEqualTo(expectedUserId);
}
Also used : IdentityImpl(org.olat.basesecurity.IdentityImpl) Test(org.junit.Test)

Example 3 with IdentityImpl

use of org.olat.basesecurity.IdentityImpl in project openolat by klemens.

the class InputValidatorTest method setUp.

@Before
public void setUp() {
    inputMock = mock(AdvanceOrderInput.class);
    when(inputMock.getIdentity()).thenReturn(new IdentityImpl());
    Set<IdentifierKey> keys = new HashSet<>();
    keys.add(IdentifierKey.externalId);
    when(inputMock.getKeys()).thenReturn(keys);
    when(inputMock.getRawValues()).thenReturn("rawValues");
    doReturn(AutoAccessMethod.class).when(inputMock).getMethodClass();
}
Also used : IdentifierKey(org.olat.resource.accesscontrol.provider.auto.IdentifierKey) IdentityImpl(org.olat.basesecurity.IdentityImpl) AdvanceOrderInput(org.olat.resource.accesscontrol.provider.auto.AdvanceOrderInput) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 4 with IdentityImpl

use of org.olat.basesecurity.IdentityImpl in project OpenOLAT by OpenOLAT.

the class UserManagerImpl method updateUserFromIdentity.

@Override
public boolean updateUserFromIdentity(Identity identity) {
    try {
        String fullName = getUserDisplayName(identity);
        updateUsernameCache(identity.getKey(), identity.getName(), fullName);
    } catch (Exception e) {
        logWarn("Error update usernames cache", e);
    }
    User user = updateUser(identity.getUser());
    ((IdentityImpl) identity).setUser(user);
    return true;
}
Also used : User(org.olat.core.id.User) IdentityImpl(org.olat.basesecurity.IdentityImpl) AssertException(org.olat.core.logging.AssertException)

Example 5 with IdentityImpl

use of org.olat.basesecurity.IdentityImpl in project OpenOLAT by OpenOLAT.

the class InputValidatorTest method setUp.

@Before
public void setUp() {
    inputMock = mock(AdvanceOrderInput.class);
    when(inputMock.getIdentity()).thenReturn(new IdentityImpl());
    Set<IdentifierKey> keys = new HashSet<>();
    keys.add(IdentifierKey.externalId);
    when(inputMock.getKeys()).thenReturn(keys);
    when(inputMock.getRawValues()).thenReturn("rawValues");
    doReturn(AutoAccessMethod.class).when(inputMock).getMethodClass();
}
Also used : IdentifierKey(org.olat.resource.accesscontrol.provider.auto.IdentifierKey) IdentityImpl(org.olat.basesecurity.IdentityImpl) AdvanceOrderInput(org.olat.resource.accesscontrol.provider.auto.AdvanceOrderInput) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

IdentityImpl (org.olat.basesecurity.IdentityImpl)10 Address (javax.mail.Address)4 InternetAddress (javax.mail.internet.InternetAddress)4 DBMailRecipient (org.olat.core.util.mail.model.DBMailRecipient)4 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 Adler32 (java.util.zip.Adler32)2 AddressException (javax.mail.internet.AddressException)2 Before (org.junit.Before)2 Test (org.junit.Test)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 User (org.olat.core.id.User)2 AssertException (org.olat.core.logging.AssertException)2