use of org.olat.login.auth.AuthenticationProvider in project openolat by klemens.
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();
}
use of org.olat.login.auth.AuthenticationProvider in project OpenOLAT by OpenOLAT.
the class UserManagerImpl method getDomain.
private String getDomain() {
AuthenticationProvider authenticationProvider = loginModule.getAuthenticationProvider("OLAT");
String issuer = authenticationProvider.getIssuerIdentifier(null);
String domain = issuer.startsWith("https://") ? issuer.substring(8) : issuer;
return domain;
}
use of org.olat.login.auth.AuthenticationProvider in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.login.auth.AuthenticationProvider in project openolat by klemens.
the class UserManagerImpl method getDomain.
private String getDomain() {
AuthenticationProvider authenticationProvider = loginModule.getAuthenticationProvider("OLAT");
String issuer = authenticationProvider.getIssuerIdentifier(null);
String domain = issuer.startsWith("https://") ? issuer.substring(8) : issuer;
return domain;
}
use of org.olat.login.auth.AuthenticationProvider in project openolat by klemens.
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);
}
Aggregations