Package org.olat.basesecurity

Examples of org.olat.basesecurity.Authentication


    }
    return allOk;
  }
 
  private static boolean changeOlatPassword(Identity doer, Identity identity, String hashedPwd) {
    Authentication auth = ManagerFactory.getManager().findAuthentication(identity, OLATAuthenticationController.PROVIDER_OLAT);
    if (auth == null) { // create new authentication for provider OLAT
      auth = ManagerFactory.getManager().createAndPersistAuthentication(identity, OLATAuthenticationController.PROVIDER_OLAT, identity.getName(), hashedPwd);
      log.audit(doer.getName() + " created new authenticatin for identity: " + identity.getName());
    }

    auth.setCredential(hashedPwd);
    DBFactory.getInstance().updateObject(auth);
    log.audit(doer.getName() + " set new password for identity: " +identity.getName());
    return true;
  }
View Full Code Here


      Tracing.logWarn("Identity not found for username="+username, ClientManagerImpl.class);
      return null;
    }
    // synchronized: not needed here, since the credentials are only created once for a user (when that user logs in for the very first time).
    // And a user will almost! never log in at the very same time from two different machines.
    Authentication auth = ManagerFactory.getManager().findAuthentication(identity, PROVIDER_INSTANT_MESSAGING);
    InstantMessaging im = InstantMessagingModule.getAdapter();
    if (auth == null) { // create new authentication for provider and also a new IM-account
     
      //if account exists on IM server but not on OLAT delete it first
      if (im.hasAccount(username)) {
        im.deleteAccount(username);
      }
     
      String pw = RandomStringUtils.randomAlphanumeric(6);
      if (im.createAccount(username, pw,
          getFullname(identity), identity.getUser().getProperty(UserConstants.EMAIL, null))) {
        auth = ManagerFactory.getManager().createAndPersistAuthentication(identity, PROVIDER_INSTANT_MESSAGING,
            identity.getName().toLowerCase(), pw);
        Tracing.logAudit("New instant messaging authentication account created for user:" + username, this.getClass());
        return auth.getCredential();
      } else {
        Tracing.logWarn("new instant messaging account creation failed for user: " + username, ClientManagerImpl.class);
        return null;
      }
    }
    /**
     * this does not decouple IM from the loginprocess, move account recreations in background thread somewhere else
     * maybe to the login background thread...
     */
//    else {
//      //user has IM account credentials on OLAT, check whether account on IM server side exists
//      if (!im.hasAccount(username)) {
//        boolean success = im.createAccount(username, auth.getCredential(), getFullname(identity), identity.getUser().getProperty(UserConstants.EMAIL, null));
//        if (success) {
//          Tracing.logAudit("New instant messaging authentication account created for user:" + username, this.getClass());
//        } else {
//          Tracing.logWarn("new instant messaging account creation failed for user: " + username, ClientManagerImpl.class);
//        }
//      }
//    }
    return auth.getCredential();
  }
View Full Code Here

   
    return changeWebDAVPassword(doer, identity, hashedPwd);
  }
 
  private static boolean changeWebDAVPassword(Identity doer, Identity identity, String hashedPwd) {
    Authentication auth = ManagerFactory.getManager().findAuthentication(identity, PROVIDER_WEBDAV);
    if (auth == null) { // create new authentication for provider OLAT
      auth = ManagerFactory.getManager().createAndPersistAuthentication(identity, PROVIDER_WEBDAV, identity.getName(), hashedPwd);
      log.audit(doer.getName() + " created new WebDAV authenticatin for identity: " + identity.getName());
    }

    auth.setCredential(hashedPwd);
    DBFactory.getInstance().updateObject(auth);
    log.audit(doer.getName() + " set new WebDAV password for identity: " +identity.getName());
    return true;
  }
View Full Code Here

  public static Identity authenticate(String login, String pass) {
    Identity ident = ManagerFactory.getManager().findIdentityByName(login);
    if (ident == null) return null;
   
    //find WEBDAV authentication provider
    Authentication auth = ManagerFactory.getManager().findAuthentication(ident, PROVIDER_WEBDAV);
    if (auth != null && auth.getCredential().equals(Encoder.encrypt(pass)))  return ident;
    //fallback to OLAT authentication provider
    return OLATAuthenticationController.authenticate(login, pass);
  }
View Full Code Here

          } else { // there is an emailaddress
            state = STATE_NEW_SHIB_USER;
            mainContainer.setPage(VELOCITY_ROOT + "/disclaimer.html");
          }
        } else { // offer identity migration, if OLAT provider exists
          Authentication auth = secMgr.findAuthentication(identity, OLATAuthenticationController.PROVIDER_OLAT);         
          if (auth == null) { // no OLAT provider, migration not possible...
            getWindowControl().setError(translator.translate("sr.error.loginexists", new String[] {WebappHelper.getMailConfig("mailSupport")}));
          else { // OLAT provider exists, offer migration...
            migrationForm = new ShibbolethMigrationForm("migrationForm", translator, auth);
            migrationForm.addListener(this);
View Full Code Here

          RegistrationManager.getInstance().setHasConfirmedDislaimer(identity);
          doLogin(identity, ureq);
          return;
        } else if (state == STATE_MIGRATED_SHIB_USER) { // ...proceed and migrate user
          // create additional authentication
          Authentication auth = migrationForm.getAuthentication();
          Identity authenticationedIdentity = auth.getIdentity();
          Manager secMgr = ManagerFactory.getManager();
          secMgr.createAndPersistAuthentication(authenticationedIdentity, ShibbolethDispatcher.PROVIDER_SHIB, shibbolethUniqueID, null);
         
          // update user profile
          User user = authenticationedIdentity.getUser();
View Full Code Here

    Boolean canChangePwd = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_MODIFY_PWD);
    if (canChangePwd.booleanValue() || isOlatAdmin) {
      // show pwd form only if user has also right to create new passwords in case
      // of a user that has no password yet
      Boolean canCreatePwd = (Boolean) configuration.get(BaseSecurityModule.CONFIG_USERMANAGER_CAN_CREATE_PWD);
      Authentication OLATAuth = ManagerFactory.getManager().findAuthentication(identity,OLATAuthenticationController.PROVIDER_OLAT);
      if (OLATAuth != null || canCreatePwd.booleanValue() || isOlatAdmin) {
        pwdCtr =  new UserChangePasswordController(ureq, getWindowControl(), identity);       
        this.listenTo(pwdCtr); // listen when finished to update authentications model
        userTabP.addTab(translate(NLS_EDIT_UPWD), pwdCtr.getInitialComponent());
      }
View Full Code Here

   * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
   */
  public void event(UserRequest ureq, Controller source, Event event) {
    if (source == confirmationDialog) {
      if (DialogBoxUIFactory.isYesEvent(event)) {
        Authentication auth = (Authentication)confirmationDialog.getUserObject();
        ManagerFactory.getManager().deleteAuthentication(auth);
        getWindowControl().setInfo(getTranslator().translate("authedit.delete.success",
            new String[] { auth.getProvider(), changeableIdentity.getName() }));
        authTableModel.setObjects(ManagerFactory.getManager().getAuthentications(changeableIdentity));
        tableCtr.modelChanged();
      }
    }
     else if (source ==  tableCtr) {
      if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
        TableEvent te = (TableEvent) event;
        String actionid = te.getActionId();
        if (actionid.equals("delete")) {
          int rowid = te.getRowId();
          Authentication auth = (Authentication) authTableModel.getObject(rowid);
          confirmationDialog = activateYesNoDialog(ureq, null, getTranslator().translate("authedit.delete.confirm", new String[] { auth.getProvider(), changeableIdentity.getName() }), confirmationDialog);
          confirmationDialog.setUserObject(auth);
          return;
        }
      }
    }
View Full Code Here

    /**
     * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int)
     */
    public final Object getValueAt(int row, int col) {
      Authentication auth = (Authentication) getObject(row);
      switch (col) {
        case 0 : return auth.getProvider();
        case 1 : return auth.getAuthusername();
        case 2 : return auth.getCredential();
        default :
          return "error";
      }
    }
View Full Code Here

    Tracing.logInfo("deleteUserProperties user=" + identity.getUser(), this.getClass());
    UserManager.getInstance().deleteUserProperties(identity.getUser());
    // Delete all authentications for certain identity
    List authentications = ManagerFactory.getManager().getAuthentications(identity);
    for (Iterator iter = authentications.iterator(); iter.hasNext();) {
      Authentication auth = (Authentication) iter.next();
      Tracing.logInfo("deleteAuthentication auth=" + auth, this.getClass());
      ManagerFactory.getManager().deleteAuthentication(auth);
      Tracing.logInfo("Delete auth=" + auth + "  of identity="  + identity, this.getClass());
    }
   
View Full Code Here

TOP

Related Classes of org.olat.basesecurity.Authentication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.