ACLI and coArchi

Started by jsimoncello, June 14, 2023, 13:26:19 PM

Previous topic - Next topic

jsimoncello

Hi

I have a strange behavior on a brand new linux server (OEL 8)
xvfb-run /applis/archi/Archi/Archi -application com.archimatetool.commandline.app -consoleLog -nosplash  --modelrepository.cloneModel https://urlOfMyModel.git --modelrepository.loadModel /var/tmp/archi/  --modelrepository.userName  bytoken  --modelrepository.passFile /applis/archi/archimate_coop/token.txt   --xmlexchange.export /applis/archi/archimate_coop/export.xml --html.createReport  /applis/archi/archimate_coop/tmp_websiteproduces a "not authorized" exception
[LoadModelFromRepositoryProvider] Cloning from https://urlOfMyModel.git to /var/tmp/archi
org.eclipse.jgit.api.errors.TransportException: https://urlOfMyModel.git: not authorized
        at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:224)
        at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:311)
        at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:182)

I am pretty sure it is not caused by the token as from the same machine, I can clone this repository either from Archi UI (I am using X11 Forwarding) or git Clone with this token.
I am using Archi 5.0.2 and coArchi_0.8.7
On an older server, using 4.9.3, everything works fine with the same command line and same token...

Any idea ?


Phil Beauvoir

If you're using username/password for a HTTPS connection and both of these are correct then it should work. GitHub uses a Personal Access Token for password. Double-check you got these right.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

jsimoncello

Hi Phil, thanks for your quick reply.
I am using an access token on our private gitlab instance and I am sure it works : as a workaround I first clone my repo using git then load it with archi
git clone https://token:glpat-FGUS7xwwwwwwwwwwwc@urlOfMyModel.git /var/tmp/archi

xvfb-run /applis/archi/Archi/Archi -application com.archimatetool.commandline.app -consoleLog -nosplash   --modelrepository.loadModel /var/tmp/archi/ --html.createReport  /var/tmp/archi_tmp_website

Phil Beauvoir

#3
coArchi uses the same mechanism for authentication in the UI as the ACLI, except ACLI reads the password/token in from file. Can you make sure the file is UTF-8 and no special characters or spaces, please.

Edit - you don't have to set it as UTF-8. If you do, ensure that it is not UTF-8 BOM (Byte Order Mark).
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

jsimoncello

indeed
$ file -bi token.txt
text/plain; charset=us-ascii
But I thought that us-ascii was a subset of UTF-8.
Anyway I tried to convert to utf-8 with iconv still produces a file of us-ascii encoding

$ file -bi tokenutf8.txt
text/plain; charset=us-ascii

so i have done
echo -ne '\xEF\xBB\xBF' > tokenutf8.txt
$ iconv  -f us-ascii -t UTF-8  token.txt >> tokenutf8.txt
$ file -bi tokenutf8.txt
text/plain; charset=utf-8
With this file I still get the  "not authorized" exception and I have checked for special characters (unless '-' is a special character ?) and spaces

Phil Beauvoir

#5
Just tested it on my setup.  I created a new text file and it defaulted to "ANSI" encoding and that works OK. UTF-8 is OK but doesn't work if it is UTF-8 BOM (Byte Order Mark).

The only reason I can see this not working is if there is a newline character in there or the file uses a different encoding such as UTF-8 BOM.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

jsimoncello

Thanks for your help Phil, File has no BOM. Anyway, using git first and then loading the model works so I'll stick to that for the time being

Phil Beauvoir

If the token is working in coArchi 0.8.7 in the UI but not in the command line it must be some encoding issue. When coArchi reads in the file containing the token/password it reads it in as bytes and then converts these to a Java string character array. In my tests, this works, except for UTF-8 BOM.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

#8
I've tested this on Linux Mint. I created a new text file with a password token in it and it defaulted to "US-ASCII". When reading it into coArchi it has a newline character appended. This is why it's not working. If you open the text file in the Linux Text Editor app (or Libre Office) you won't see the newline, but if you open it in Eclipse or VS Code on Linux, you will. Also, you'll see the newline if you open the same file on Windows.

I'll guard against this in the next version of coArchi, but for now you should create the text file in another app or in Windows and copy it to Linux.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

I've just released coArchi 0.8.8 to workaround this issue:

https://www.archimatetool.com/plugins/#coArchi
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

jsimoncello

Thanks !!!!!
It works perfectly with 0.8.8, and I checked with notepad++ on my win, indeed there is a new line added.

Phil Beauvoir

I find it strange that the default text editor in Linux (Mint) and the Libre Office editor do this. If you create a file with one line of text without a line break and then open it in another app such as Eclipse or VS Code, or on Windows, the line break is visible. Don't know if any of the other text editors on Linux behave like this.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.