Ejemplo n.º 1
0
        private void initializeContext()
        {
            ContextFactory contextFactory = ContextFactory.Instance;
            serviceContext = contextFactory.NewContext();

            RepositoryIdentity repoId = new RepositoryIdentity();
            RepositoryIdentity repositoryIdentity = 
                new RepositoryIdentity(DefaultRepository, UserName, Password, "");
            serviceContext.AddIdentity(repositoryIdentity);

            ContentTransferProfile contentTransferProfile = new ContentTransferProfile();
            contentTransferProfile.TransferMode = ContentTransferMode.MTOM;
            contentTransferProfile.Geolocation = "Pleasanton";
            serviceContext.SetProfile(contentTransferProfile);

            PropertyProfile propertyProfile = new PropertyProfile();
            propertyProfile.FilterMode = PropertyFilterMode.ALL_NON_SYSTEM;
            serviceContext.SetProfile(propertyProfile);

            if (SecondaryRepository != null)
            {
                RepositoryIdentity repoId1 = new RepositoryIdentity();
                repoId1.RepositoryName = SecondaryRepository;
                repoId1.UserName = UserName;
                repoId1.Password = Password;
                serviceContext.AddIdentity(repoId1);
            }
        }
Ejemplo n.º 2
0
        private void initializeContext()
        {
            ContextFactory contextFactory = ContextFactory.Instance;

            serviceContext = contextFactory.NewContext();

            RepositoryIdentity repoId             = new RepositoryIdentity();
            RepositoryIdentity repositoryIdentity =
                new RepositoryIdentity(DefaultRepository, UserName, Password, "");

            serviceContext.AddIdentity(repositoryIdentity);

            ContentTransferProfile contentTransferProfile = new ContentTransferProfile();

            contentTransferProfile.TransferMode = ContentTransferMode.MTOM;
            contentTransferProfile.Geolocation  = "Pleasanton";
            serviceContext.SetProfile(contentTransferProfile);

            PropertyProfile propertyProfile = new PropertyProfile();

            propertyProfile.FilterMode = PropertyFilterMode.ALL_NON_SYSTEM;
            serviceContext.SetProfile(propertyProfile);

            if (SecondaryRepository != null)
            {
                RepositoryIdentity repoId1 = new RepositoryIdentity();
                repoId1.RepositoryName = SecondaryRepository;
                repoId1.UserName       = UserName;
                repoId1.Password       = Password;
                serviceContext.AddIdentity(repoId1);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creazione oggetto identity documentum dal token di autenticazione generato precedentemente
        /// </summary>
        /// <param name="authenticationToken"></param>
        /// <returns></returns>
        public static RepositoryIdentity GetIdentity(string authenticationToken)
        {
            RepositoryIdentity identity = null;

            try
            {
                string decryptedToken = DctmTokenHelper.Decrypt(authenticationToken);

                // Creazione oggetto RepositoryIdentity
                if (!string.IsNullOrEmpty(decryptedToken))
                {
                    string[] items = decryptedToken.Split('|');

                    if (items.Length == 5)
                    {
                        identity = new RepositoryIdentity(items[0], items[1], items[2], items[3]);
                    }
                }
            }
            catch (Exception ex)
            {
                string errorMessage = "Documentum.GetIdentity: Si è verificato un errore nella decodifica del token di autenticazione";
                logger.Error(errorMessage);
                throw new ApplicationException(errorMessage, ex);
            }

            return(identity);
        }
Ejemplo n.º 4
0
        public DfsContext(IDfsConfiguration dfsConfiguration)
        {
            this.dfsConfiguration = dfsConfiguration;
            serviceFactory = ServiceFactory.Instance;

            var contextFactory = ContextFactory.Instance;
            serviceContext = contextFactory.NewContext();

            var repositoryIdentity = new RepositoryIdentity(dfsConfiguration.Repository, dfsConfiguration.UserName, dfsConfiguration.Password, string.Empty);
            serviceContext.AddIdentity(repositoryIdentity);

            var contentTransferProfile = new ContentTransferProfile
            {
                TransferMode = ContentTransferMode.MTOM
            };
            serviceContext.SetProfile(contentTransferProfile);

            // Setting the filter to ALL can cause errors if the DataObject
            // passed to the operation contains system properties, so to be safe 
            // set the filter to ALL_NON_SYSTEM unless you explicitly want to update
            // a system property
            var propertyProfile = new PropertyProfile
            {
                FilterMode = PropertyFilterMode.ALL_NON_SYSTEM
            };
            serviceContext.SetProfile(propertyProfile);

            serviceContext.SetRuntimeProperty("USER_TRANSACTION_HINT", "TRANSACTION_REQUIRED");
        }
Ejemplo n.º 5
0
        private static IServiceContext createContext(String repository, String userName, String password)
        {
            Console.Out.WriteLine("Creating new empty IServiceContext instance...");

            //build context factory and an empty context
            ContextFactory  cf      = ContextFactory.Instance;
            IServiceContext context = cf.NewContext();

            Console.Out.WriteLine("Creating new repository identity...");

            //create a repository ID and seed it with the login credentials
            RepositoryIdentity repoIdent = new RepositoryIdentity(repository, userName, password, "");

            Console.Out.WriteLine("Adding repository ID into IServiceContext object...");

            //seed the IServiceContext with the Repository ID
            context.AddIdentity(repoIdent);

            ContentTransferProfile ctp = new ContentTransferProfile();

            ctp.TransferMode = ContentTransferMode.BASE64;
            context.SetProfile(ctp);

            return(context);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creazione di un token di autenticazione a partire da un oggetto RepositoryIdentity documentum
        /// </summary>
        /// <param name="identity"></param>
        /// <returns></returns>
        public static string CreateAuthenticationToken(RepositoryIdentity identity)
        {
            // Formattazione token di autenticazione
            string token = string.Format("{0}|{1}|{2}|{3}|{4}",
                                         identity.RepositoryName, identity.UserName, identity.Password, identity.Domain, Guid.NewGuid().ToString());

            return(DctmTokenHelper.Encrypt(token));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Impersonate come utente superuser documentum
        /// </summary>
        /// <returns></returns>
        internal static string ImpersonateSuperUser()
        {
            // Per creare il folder per contenere i documenti, è necessario fare l'impersonate come utente amministratore (superuser in dctm)
            RepositoryIdentity superIdentity = DctmRepositoryIdentityHelper.GetIdentity(DctmConfigurations.GetRepositoryName(),
                                                                                        DctmConfigurations.GetDocumentumSuperUser(),
                                                                                        DctmConfigurations.GetDocumentumSuperUserPwd(),
                                                                                        string.Empty);

            return(DctmRepositoryIdentityHelper.CreateAuthenticationToken(superIdentity));
        }
Ejemplo n.º 8
0
        public void setContext(string userName, string password, string address, string repository)
        {
            /*
             * Get the service context and set the user
             * credentials and repository information
             */
            this.userName   = userName;
            this.password   = password;
            this.repository = repository;
            this.address    = address;

            ContextFactory contextFactory = ContextFactory.Instance;

            serviceContext = contextFactory.NewContext();
            RepositoryIdentity repositoryIdentity =
                new RepositoryIdentity(repository, userName, password, "");

            serviceContext.AddIdentity(repositoryIdentity);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Modifica password utente
        /// </summary>
        /// <param name="oldPassword"/></param>
        /// <param name="user"></param>
        ///// <returns></returns>
        public ValidationResultInfo ChangeUserPwd(DocsPaVO.utente.UserLogin user, string oldPassword)
        {
            ValidationResultInfo retValue = new ValidationResultInfo();

            try
            {
                // La password deve essere modificata con le credenziali di superuser
                IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(UserManager.ImpersonateSuperUser());

                ObjectIdentity identity = Dfs4DocsPa.getUserIdentityByName(TypeUtente.NormalizeUserName(user.UserName));

                DataObject userDataObject = new DataObject(identity, ObjectTypes.UTENTE);
                userDataObject.Properties.Set <string>("user_password", user.Password);

                DataPackage dataPackage = new DataPackage(userDataObject);
                dataPackage = objectService.Update(dataPackage, null);

                retValue.Value = (dataPackage.DataObjects.Count > 0);

                if (!retValue.Value)
                {
                    throw new ApplicationException("Password non aggiornata");
                }
                else
                {
                    RepositoryIdentity newIdentity = DctmRepositoryIdentityHelper.GetIdentity(DctmConfigurations.GetRepositoryName(), user.UserName, user.Password, string.Empty);
                    user.DST = DctmRepositoryIdentityHelper.CreateAuthenticationToken(newIdentity);

                    logger.Debug(string.Format("Documentum.ChangePassword: password modificata per l'utente {0}", user.UserName));
                }
            }
            catch (Exception ex)
            {
                logger.Debug(string.Format("Errore in Documentum.ChangePassword:\n{0}", ex.ToString()));

                retValue.BrokenRules.Add(new BrokenRule("ChangePassword_ERROR", "Errore nella modifica della password per il documentale DOCUMENTUM", DocsPaVO.Validations.BrokenRule.BrokenRuleLevelEnum.Error));
            }

            retValue.Value = (retValue.BrokenRules.Count == 0);

            return(retValue);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// verifica che il server DCTM risponda correttamente, effettuando un controllo sulle credenziali dell'amministratore
        /// </summary>
        /// <returns></returns>
        public virtual bool Checkconnection()
        {
            bool   retValue = false;
            string userAdm  = DctmConfigurations.GetDocumentumSuperUser();

            //loginResult = UserLogin.LoginResult.APPLICATION_ERROR;

            try
            {
                RepositoryIdentity identity = DctmServices.DctmRepositoryIdentityHelper.GetIdentity(
                    DctmConfigurations.GetRepositoryName(),
                    userAdm,
                    DctmConfigurations.GetDocumentumSuperUserPwd(),
                    "");

                string token = DctmServices.DctmRepositoryIdentityHelper.CreateAuthenticationToken(identity);

                IObjectService objectService = DctmServiceFactory.GetServiceInstance <IObjectService>(token);

                Qualification qual = new Qualification("dm_docbaseid_map enable(RETURN_TOP 1)");

                ObjectIdentity objectIdentity = new ObjectIdentity(qual, DctmConfigurations.GetRepositoryName());
                objectIdentity.ValueType          = ObjectIdentityType.QUALIFICATION;
                objectIdentity.valueTypeSpecified = true;

                DataPackage dataPackage = objectService.Get(new ObjectIdentitySet(objectIdentity), null);

                retValue = (dataPackage != null);
            }

            /*
             *          catch (Emc.Documentum.FS.Runtime.AuthenticationException exAuth)
             *          {
             *              //AuthenticationException - Exception in com.emc.documentum.fs.rt
             *              //Exception which is raised when authentication errors occur
             *              //  loginResult = DocsPaVO.utente.UserLogin.LoginResult.UNKNOWN_DTCM_USER;
             *              retValue = false;
             *
             *              logger.Error(string.Format("Credenziali utente DTCM non valide: '{0}'", userAdm + " " + exAuth.Message));
             *          }
             */
            catch (Emc.Documentum.FS.Runtime.ServiceInvocationException exServiceInvocation)
            {
                //AuthenticationException - Exception in com.emc.documentum.fs.rt
                //Exception which is raised when authentication errors occur
                //  loginResult = DocsPaVO.utente.UserLogin.LoginResult.DTCM_SERVICE_NO_CONTACT;
                retValue = false;

                logger.Error(string.Format("Errore nel tentativo di contattare i servizi DCTM: '{0}'", userAdm + " " + exServiceInvocation.Message));
            }

            /*
             *          catch (Emc.Documentum.FS.Runtime.ServiceException exService)
             *          {
             *              //AuthenticationException - Exception in com.emc.documentum.fs.rt
             *              //Exception which is raised when authentication errors occur
             *              //  loginResult = DocsPaVO.utente.UserLogin.LoginResult.DTCM_SERVICE_NO_CONTACT;
             *              retValue = false;
             *
             *              logger.Error(string.Format("Errore nel tentativo di contattare i servizi DTCM: '{0}'", userAdm + " " + exService.Message));
             *          }
             */
            catch (Exception ex)
            {
                //AuthenticationException - Exception in com.emc.documentum.fs.rt
                //Exception which is raised when authentication errors occur
                //  loginResult = DocsPaVO.utente.UserLogin.LoginResult.UNKNOWN_USER;
                retValue = false;

                logger.Error(string.Format("Error durante il controllo checkpage utente : '{0}'", userAdm + " errore: " + ex.Message));
            }

            return(retValue);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Login al sistema documentale
        /// </summary>
        /// <param name="utente"></param>
        /// <param name="loginResult"></param>
        /// <returns></returns>
        public bool LoginUser(DocsPaVO.utente.UserLogin userLogin, out DocsPaVO.utente.Utente utente, out DocsPaVO.utente.UserLogin.LoginResult loginResult)
        {
            bool retValue = false;

            utente      = null;
            loginResult = UserLogin.LoginResult.UNKNOWN_USER;

            try
            {
                string userName     = TypeUtente.NormalizeUserName(userLogin.UserName);
                string userPassword = string.Empty;
                // Modifica 21-12-2012, recupero ticket documentum se login tramite token.
                //if (DocsPaServices.DocsPaQueryHelper.isUtenteDominioOrLdap(userLogin))
                if (userLogin.SSOLogin)
                {
                    // L'utente è agganciato in amministrazione ad un dominio,
                    // pertanto viene richiamato il servizio documentum per la generazione del ticket di autenticazione
                    userPassword = DctmTokenFactoryHelper.Generate(userName);
                }
                else
                {
                    userPassword = userLogin.Password;
                }

                RepositoryIdentity identity = DctmServices.DctmRepositoryIdentityHelper.GetIdentity(
                    DctmConfigurations.GetRepositoryName(),
                    userName,
                    userPassword,
                    userLogin.Dominio);

                string token = DctmServices.DctmRepositoryIdentityHelper.CreateAuthenticationToken(identity);

                // Verifica validità credenziali
                if (this.VerifyCredentials(userName, token, out loginResult))
                {
                    utente      = new Utente();
                    utente.dst  = token;
                    loginResult = DocsPaVO.utente.UserLogin.LoginResult.OK;
                }

                //per LDAP oppure per SHIBBOLETH
                if (userLogin.SSOLogin)
                {
                    utente.dst = UserManager.ImpersonateSuperUser();
                }
                //FINE per LDAP oppure per SHIBBOLETH


                retValue = (loginResult == DocsPaVO.utente.UserLogin.LoginResult.OK);
            }
            catch (Exception ex)
            {
                retValue    = false;
                utente      = null;
                loginResult = UserLogin.LoginResult.UNKNOWN_USER;

                logger.Debug(string.Format("Errore in Documentum.Login:\n{0}", ex.ToString()));
            }

            return(retValue);
        }