Search in sources :

Example 1 with AuthenticationProvider

use of org.olat.login.auth.AuthenticationProvider in project OpenOLAT by OpenOLAT.

the class EdubaseManagerImpl method getUserId.

@Override
public String getUserId(IdentityEnvironment identityEnvironment) {
    String providerName = identityEnvironment.getAttributes().get(AuthHelper.ATTRIBUTE_AUTHPROVIDER);
    AuthenticationProvider authenticationProvider = loginModul.getAuthenticationProvider(providerName);
    return new StringBuilder().append(authenticationProvider.getIssuerIdentifier(identityEnvironment)).append(USER_ID_CONCAT).append(identityEnvironment.getIdentity().getName()).toString();
}
Also used : AuthenticationProvider(org.olat.login.auth.AuthenticationProvider)

Example 2 with AuthenticationProvider

use of org.olat.login.auth.AuthenticationProvider in project OpenOLAT by OpenOLAT.

the class LoginModule method init.

@Override
public void init() {
    // configure timed cache default params: refresh 1 minute, timeout according to configuration
    failedLoginCache = coordinatorManager.getCoordinator().getCacher().getCache(LoginModule.class.getSimpleName(), "blockafterfailedattempts");
    updateProperties();
    boolean defaultProviderFound = false;
    for (Iterator<AuthenticationProvider> iterator = authenticationProviders.iterator(); iterator.hasNext(); ) {
        AuthenticationProvider provider = iterator.next();
        if (provider.isDefault()) {
            defaultProviderFound = true;
            defaultProviderName = provider.getName();
            log.info("Using default authentication provider '" + defaultProviderName + "'.");
        }
    }
    if (!defaultProviderFound) {
        throw new StartupException("Defined DefaultAuthProvider::" + defaultProviderName + " not existent or not enabled. Please fix.");
    }
}
Also used : StartupException(org.olat.core.logging.StartupException) AuthenticationProvider(org.olat.login.auth.AuthenticationProvider)

Example 3 with AuthenticationProvider

use of org.olat.login.auth.AuthenticationProvider in project OpenOLAT by OpenOLAT.

the class UserManagerImplTest method shouldEnsureEmailIfHasNoEmail.

@Test
public void shouldEnsureEmailIfHasNoEmail() {
    Long userKey = 123l;
    String issuer = "issuer";
    AuthenticationProvider authenticationProviderMock = mock(AuthenticationProvider.class);
    when(authenticationProviderMock.getIssuerIdentifier(any())).thenReturn(issuer);
    when(loginModuleMock.getAuthenticationProvider("OLAT")).thenReturn(authenticationProviderMock);
    User userWithoutEmailMock = mock(User.class);
    when(userWithoutEmailMock.getKey()).thenReturn(userKey);
    String ensuredEmail = sut.getEnsuredEmail(userWithoutEmailMock);
    String expectedValue = userKey + "@" + issuer;
    assertThat(ensuredEmail).isEqualTo(expectedValue);
}
Also used : User(org.olat.core.id.User) AuthenticationProvider(org.olat.login.auth.AuthenticationProvider) Test(org.junit.Test)

Example 4 with AuthenticationProvider

use of org.olat.login.auth.AuthenticationProvider in project openolat by klemens.

the class LoginAuthprovidersController method initLoginContent.

private VelocityContainer initLoginContent(UserRequest ureq, String provider) {
    // in every case we build the container for pages to fill the panel
    VelocityContainer contentBorn = createVelocityContainer("main_loging", "login");
    // browser not supported messages
    // true if browserwarning should be showed
    boolean bwo = Settings.isBrowserAjaxBlacklisted(ureq);
    contentBorn.contextPut("browserWarningOn", bwo ? Boolean.TRUE : Boolean.FALSE);
    // prepare login
    if (provider == null) {
        provider = loginModule.getDefaultProviderName();
    }
    AuthenticationProvider authProvider = loginModule.getAuthenticationProvider(provider);
    if (authProvider == null) {
        authProvider = loginModule.getAuthenticationProviderHeuristic(provider);
    }
    // clean-up controllers
    if (authController != null) {
        removeAsListenerAndDispose(authController);
    }
    for (Controller controller : authControllers) {
        removeAsListenerAndDispose(controller);
    }
    authControllers.clear();
    // recreate controllers
    authController = authProvider.createController(ureq, getWindowControl());
    listenTo(authController);
    contentBorn.put("loginComp", authController.getInitialComponent());
    contentBorn.contextPut("currentProvider", authProvider.getName());
    Collection<AuthenticationProvider> providers = loginModule.getAuthenticationProviders();
    List<AuthenticationProvider> providerSet = new ArrayList<>(providers.size());
    int count = 0;
    for (AuthenticationProvider prov : providers) {
        if (prov.isEnabled()) {
            providerSet.add(prov);
            if (!prov.getName().equals(authProvider.getName())) {
                // hang these components to the component tree, for state-less behavior
                Controller controller = prov.createController(ureq, getWindowControl());
                authControllers.add(controller);
                Component cmp = controller.getInitialComponent();
                contentBorn.put("dormant_" + count++, cmp);
                listenTo(controller);
            }
        }
    }
    contentBorn.contextPut("providerSet", providerSet);
    contentBorn.contextPut("locale", ureq.getLocale());
    // prepare info message
    InfoMessageManager mrg = CoreSpringFactory.getImpl(InfoMessageManager.class);
    String infomsg = mrg.getInfoMessage();
    if (infomsg != null && infomsg.length() > 0) {
        contentBorn.contextPut("infomsg", infomsg);
    }
    String infomsgNode = mrg.getInfoMessageNodeOnly();
    if (infomsgNode != null && infomsgNode.length() > 0) {
        contentBorn.contextPut("infomsgNode", infomsgNode);
    }
    // add additional login intro message for custom content
    String customMsg = translate("login.custommsg");
    if (!StringUtils.isBlank(customMsg)) {
        contentBorn.contextPut("logincustommsg", customMsg);
    }
    // add additional login footer message for custom content
    String footerMsg = translate("login.customfootermsg");
    if (!StringUtils.isBlank(footerMsg)) {
        contentBorn.contextPut("loginfootermsg", footerMsg);
    }
    // login is blocked?
    if (AuthHelper.isLoginBlocked()) {
        contentBorn.contextPut("loginBlocked", Boolean.TRUE);
    }
    // guest link
    if (loginModule.isGuestLoginEnabled()) {
        anoLink = LinkFactory.createButton("menu.guest", contentBorn, this);
        anoLink.setIconLeftCSS("o_icon o_icon-2x o_icon_provider_guest");
        anoLink.setTitle("menu.guest.alt");
        anoLink.setEnabled(!AuthHelper.isLoginBlocked());
    }
    return contentBorn;
}
Also used : AuthenticationProvider(org.olat.login.auth.AuthenticationProvider) ArrayList(java.util.ArrayList) InfoMessageManager(org.olat.admin.sysinfo.InfoMessageManager) BaseFullWebappController(org.olat.core.commons.fullWebApp.BaseFullWebappController) Controller(org.olat.core.gui.control.Controller) MainLayoutBasicController(org.olat.core.gui.control.controller.MainLayoutBasicController) Component(org.olat.core.gui.components.Component) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 5 with AuthenticationProvider

use of org.olat.login.auth.AuthenticationProvider in project openolat by klemens.

the class LoginModule method init.

@Override
public void init() {
    // configure timed cache default params: refresh 1 minute, timeout according to configuration
    failedLoginCache = coordinatorManager.getCoordinator().getCacher().getCache(LoginModule.class.getSimpleName(), "blockafterfailedattempts");
    updateProperties();
    boolean defaultProviderFound = false;
    for (Iterator<AuthenticationProvider> iterator = authenticationProviders.iterator(); iterator.hasNext(); ) {
        AuthenticationProvider provider = iterator.next();
        if (provider.isDefault()) {
            defaultProviderFound = true;
            defaultProviderName = provider.getName();
            log.info("Using default authentication provider '" + defaultProviderName + "'.");
        }
    }
    if (!defaultProviderFound) {
        throw new StartupException("Defined DefaultAuthProvider::" + defaultProviderName + " not existent or not enabled. Please fix.");
    }
}
Also used : StartupException(org.olat.core.logging.StartupException) AuthenticationProvider(org.olat.login.auth.AuthenticationProvider)

Aggregations

AuthenticationProvider (org.olat.login.auth.AuthenticationProvider)10 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 InfoMessageManager (org.olat.admin.sysinfo.InfoMessageManager)2 BaseFullWebappController (org.olat.core.commons.fullWebApp.BaseFullWebappController)2 Component (org.olat.core.gui.components.Component)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 Controller (org.olat.core.gui.control.Controller)2 MainLayoutBasicController (org.olat.core.gui.control.controller.MainLayoutBasicController)2 User (org.olat.core.id.User)2 StartupException (org.olat.core.logging.StartupException)2