public User login()
        {
            // Get the service stub
            SessionService sessionService = SessionService.getService(connection);

            try
            {
                // Prompt for credentials until they are right, or until user
                // cancels
                String[] credentials = credentialManager.PromptForCredentials();
                while (true)
                {
                    try
                    {
                        // *****************************
                        // Execute the service operation
                        // *****************************
                        LoginResponse resp = sessionService.Login(credentials[0], credentials[1],
                                                                  credentials[2], credentials[3], "", credentials[4]);

                        return(resp.User);
                    }
                    catch (InvalidCredentialsException e)
                    {
                        credentials = credentialManager.GetCredentials(e);
                    }
                }
            }
            // User canceled the operation, don't need to tell him again
            catch (CanceledOperationException /*e*/) {}

            // Exit the application
            //System.exit(0);
            return(null);
        }
예제 #2
0
        /**
         * Login to the Teamcenter Server
         *
         */
        public User login(string Username, string Password, string Group, string Role, string Locale, string SessionDiscriminator)
        {
            // Get the service stub
            SessionService sessionService = SessionService.getService(connection);


            try
            {
                // Prompt for credentials until they are right, or until user
                // cancels
                //String[] credentials = credentialManager.PromptForCredentials();
                String[] credentials = { "infodba", "infodba", "", "", "SoaAppX" };

                while (true)
                {
                    try
                    {
                        // *****************************
                        // Execute the service operation
                        // *****************************
                        //LoginResponse resp = sessionService.Login(credentials[0], credentials[1],
                        //        credentials[2], credentials[3], "", credentials[4]);
                        LoginResponse resp = sessionService.Login(Username, Password, Group, Role, Locale, SessionDiscriminator);

                        return(resp.User);
                    }
                    catch (InvalidCredentialsException e)
                    {
                        credentials = credentialManager.GetCredentials(e);
                    }
                }
            }
            // User canceled the operation, don't need to tell him again
            catch (CanceledOperationException /*e*/) { }

            // Exit the application
            //System.exit(0);
            return(null);
        }