Package org.olat.basesecurity

Examples of org.olat.basesecurity.Manager


  /**
   * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
   */
  protected void formOK(UserRequest ureq) {
    UserManager um = UserManager.getInstance();
    Manager secMgr = ManagerFactory.getManager();
    // Refresh user from DB to prevent stale object issues
    tobeChangedIdentity = secMgr.loadIdentityByKey(tobeChangedIdentity.getKey());
    Preferences prefs = tobeChangedIdentity.getUser().getPreferences();
    prefs.setLanguage(language.getSelectedKey());
    prefs.setFontsize(fontsize.getSelectedKey());
    if (notificationInterval != null) {
      // only read notification interval if available, could be disabled by configuration
View Full Code Here


   * @param token
   * @return True if authentication is valid
   */
  private boolean validAuthentication(Identity identity, String token) {
    boolean valid = false;
    Manager secMgr = ManagerFactory.getManager();
    Authentication authentication = secMgr.findAuthenticationByAuthusername(identity.getKey().toString(), TOKEN_PROVIDER);
    if (authentication != null && authentication.getCredential().equals(token)) {
      valid = true;
    }
    return valid;
  }
View Full Code Here

   * database. It has nothing to do with accounts on the jabber server itself.
   */
  private void checkAndCreateTestUsers() {
    Identity identity;
    Authentication auth;
    Manager securityManager = ManagerFactory.getManager();
    identity = securityManager.findIdentityByName("author");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "test");
      InstantMessagingModule.getAdapter().createAccount("author", "test", "Aurich Throw", "author@olat-newinstallation.org");
    }

    identity = securityManager.findIdentityByName("administrator");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "olat");
      InstantMessagingModule.getAdapter().createAccount("administrator", "olat", "Administrator", "administrator@olat-newinstallation.org");
    }

    identity = securityManager.findIdentityByName("learner");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "test");
      InstantMessagingModule.getAdapter().createAccount("learner", "test", "Leise Arnerich", "learner@olat-newinstallation.org");
    }

    identity = securityManager.findIdentityByName("test");
    auth = ManagerFactory.getManager().findAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING);
    if (auth == null) { // create new authentication for provider
      ManagerFactory.getManager().createAndPersistAuthentication(identity, ClientManager.PROVIDER_INSTANT_MESSAGING, identity.getName(),
          "test");
      InstantMessagingModule.getAdapter().createAccount("test", "test", "Thomas Est", "test@olat-newinstallation.org");
View Full Code Here

   * @param feed
   * @param identityKey
   * @return The feed base uri for the given user (identity)
   */
  public static String getFeedBaseUri(Feed feed, Identity identity, Long courseId, String nodeId) {
    Manager manager = ManagerFactory.getManager();
    boolean isCourseNode = courseId != null && nodeId != null;

    final String slash = "/";
    StringBuffer uri = new StringBuffer();
    uri.append(Settings.getServerContextPathURI());
    uri.append(slash);
    uri.append(FeedMediaDispatcher.uriPrefixes.get(feed.getResourceableTypeName()));
    uri.append(slash);

    if (isCourseNode) {
      uri.append(COURSE_NODE_INDICATOR);
      uri.append(slash);
    }

    if (identity != null) {
      // The identity can be null for guests
      String idKey = identity.getKey().toString();
      Authentication authentication = manager.findAuthenticationByAuthusername(idKey, TOKEN_PROVIDER);
      if (authentication == null) {
        // Create an authentication
        String token = RandomStringUtils.randomAlphanumeric(6);
        authentication = manager.createAndPersistAuthentication(identity, TOKEN_PROVIDER, idKey, token);
      }
      // If the repository entry allows guest access it is public, thus not
      // private.
      boolean isPrivate = true;
      RepositoryEntry entry = RepositoryManager.getInstance().lookupRepositoryEntry(feed, false);
View Full Code Here

   * @param wControl
   */
  public PersonalSettingsController(UserRequest ureq, WindowControl wControl) {
    super(wControl);
      translator = new PackageTranslator(PACKAGE, ureq.getLocale());
      Manager mgr = ManagerFactory.getManager();
      if (!mgr.isIdentityPermittedOnResourceable(
          ureq.getIdentity(),
          Constants.PERMISSION_ACCESS,
          OresHelper.lookupType(this.getClass())))
        throw new OLATSecurityException("Insufficient permissions to access PersonalSettingsController");

View Full Code Here

      return;
    }
   
   

    Manager mgr = ManagerFactory.getManager();
    if (!mgr.isIdentityPermittedOnResourceable(
        ureq.getIdentity(),
        Constants.PERMISSION_ACCESS,
        OresHelper.lookupType(this.getClass())))
      throw new OLATSecurityException("Insufficient permissions to access ChangePasswordController");
View Full Code Here

  /**
   * @see org.olat.commons.servlets.util.WebDAVProvider#getContainer(org.olat.core.id.Identity)
   */
  public VFSContainer getContainer(Identity identity) {
    Manager secMgr = ManagerFactory.getManager();
    //FIXME: RH: check if it really should return something => why an empty container?
    if (!secMgr.isIdentityPermittedOnResourceable(identity, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_ADMIN)){
      return new MergeSource(null, null);
    }   

    // mount /static/themes, filter out CVS!
    String staticAbsPath = WebappHelper.getContextRoot() + "/static/themes";
View Full Code Here

    if (!uhd.getBooleanDataValue(TASK_CHECK_OPEN_QTI_EDITOR_SESSIONS)) {
      Tracing.logAudit("+------------------------------------------+",this.getClass());
      Tracing.logAudit("+... LOCKS FOR OPEN QTI EDITOR SESSIONS ...+",this.getClass());
      Tracing.logAudit("+------------------------------------------+",this.getClass());
      //
      Manager manager = ManagerFactory.getManager();
      RepositoryManager rm = RepositoryManager.getInstance();
      RepositoryEntry myEntry;
      HashMap logmsg = new HashMap();
      VFSContainer qtiTmpDir = new LocalFolderImpl(QTIEditorPackage.getTmpBaseDir());
      VFSContainerFilter foldersOnly = new VFSContainerFilter();
      //folders in ../tmp/qtieditor hold the usernames
      List foldersUsername = qtiTmpDir.getItems(foldersOnly);
      for (Iterator iter = foldersUsername.iterator(); iter.hasNext();) {
        VFSContainer folderOfUser = (VFSContainer) iter.next();
        //the users folders holds folders with ids of OLATResourceable's
        List oResFolders = folderOfUser.getItems(foldersOnly);
        for (Iterator resources = oResFolders.iterator(); resources.hasNext();) {
          VFSContainer folderOfResource = (VFSContainer) resources.next();
          folderOfResource.createChildContainer(QTIEditorPackage.FOLDERNAMEFOR_CHANGELOG);
         
          //these are eiterh surveys or tests
          //try it as testresource then as survey, after this give up
          Long oresId = new Long(folderOfResource.getName());
          FileResource fr = new TestFileResource();
          fr.overrideResourceableId(oresId);
          myEntry = rm.lookupRepositoryEntry(fr,false);
          if(myEntry==null){
            //no qti test found, try the qti survey
            fr = new SurveyFileResource();
            fr.overrideResourceableId(oresId);
            myEntry = rm.lookupRepositoryEntry(fr,false);
          }
          //
          if(myEntry!=null){
            List identites = manager.getVisibleIdentitiesByPowerSearch(folderOfUser.getName(),null,false, null,null,null,null,null);
            if(identites!=null && identites.size()==1){
              //found exact one user, which is the expected case
              //a qti resource was found, update its metadata entry to generate a lock
              String repoEntry = myEntry.getDisplayname();
              String oresIdS = myEntry.getOlatResource().getResourceableId().toString();
View Full Code Here

   * Create an identity with user permissions
   * @param login
   * @return
   */
  public static final Identity createAndPersistIdentityAsUser(String login) {
    Manager securityManager = ManagerFactory.getManager();
    SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
    if (group == null) group = securityManager.createAndPersistNamedSecurityGroup(Constants.GROUP_OLATUSERS);
    User user = UserManager.getInstance().createUser("first" + login, "last" + login, login + "@" + maildomain);
    Identity identity = securityManager.createAndPersistIdentityAndUser(login, user, OLATAuthenticationController.PROVIDER_OLAT, login,
        Encoder.encrypt("A6B7C8"));
    securityManager.addIdentityToSecurityGroup(identity, group);
    return identity;
  }
View Full Code Here

   * Create an identity with author permissions
   * @param login
   * @return
   */
  public static final Identity createAndPersistIdentityAsAuthor(String login) {
    Manager securityManager = ManagerFactory.getManager();
    SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS);
    if (group == null) group = securityManager.createAndPersistNamedSecurityGroup(Constants.GROUP_AUTHORS);
    User user = UserManager.getInstance().createUser("first" + login, "last" + login, login + "@" + maildomain);
    Identity identity = securityManager.createAndPersistIdentityAndUser(login, user, OLATAuthenticationController.PROVIDER_OLAT, login,
        Encoder.encrypt("A6B7C8"));
    securityManager.addIdentityToSecurityGroup(identity, group);
    return identity;
  }
View Full Code Here

TOP

Related Classes of org.olat.basesecurity.Manager

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.