You are viewing limited content. For full access, please sign in.

Question

Question

logging into LFCloud using RA cloudTicket

asked on September 14, 2016

I am trying to figure out how to log into a cloud repository using Session.Create(RepositoryHost, CloudTicket).

I can get the cloudTicket

      CloudTicketRequestSettings ctrSettings = new CloudTicketRequestSettings();
      ctrSettings.AccountId = sCustomerID;
      ctrSettings.UserName = sUserName;
      ctrSettings.Password = sPassword;
      CloudTicket CurrentTicket = CloudTicket.GetTicket(ctrSettings);

But how do I get (lookup) the Repository host name?

1 0

Answer

SELECTED ANSWER
replied on September 16, 2016

The repository name is inside the CloudTicket SAML xml, here is how you can extract it:

using System.Xml;
using System.IO;
using System.Text;
//...
string samlTokenXml = CurrentTicket.GetSamlToken();

using (XmlReader reader = XmlReader.Create(new StringReader(samlTokenXml)))
{
    while (reader.Read())
    {
        if (reader.NodeType == XmlNodeType.Element)
        {
            if (reader.LocalName == "Attribute" && reader.GetAttribute("Name") == "http://laserfiche.com/identity/claims/catalyst/roles")
            {
                int depth = reader.Depth;
                while (reader.Read() && reader.Depth > depth)
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "AttributeValue")
                    {
                        reader.Read();
                                 
                        string roleValue = reader.Value;
                        if (!string.IsNullOrEmpty(roleValue) && roleValue.Contains(":"))
                        {
                            int colonPos = roleValue.IndexOf(":");
                            string roleDomain = roleValue.Substring(0, colonPos);
                            string role = roleValue.Substring(colonPos + 1);

                            if (role == "CreateSession")
                                repositoryName = roleDomain;
                        }
                    }
                }
            }
        }
    }
}

In the future the web API will be published.

3 0

Replies

replied on September 14, 2016

The host name should be [repository name].laserfiche.com and you should connect with SSL.

0 0
replied on September 14, 2016

Thanks for the reply.  How do we go about pulling the Repository name?  When you look at the login screen in the 10 client, it just asks for the account id, user name, and password.

0 0
replied on September 14, 2016

On the "Summary" screen of the "Repository Administration" page, you'll see the Repository ID, r-XXXXXXXX

The host will use that Repository ID value so it would be

r-XXXXXXXX.laserfiche.com

0 0
replied on September 14, 2016

This information will also be available in the "About" dialog in Web Access after the next update.  Currently it is not in the Web Access UI, but you can see it in the URL.

0 0
replied on September 15, 2016

I know and understand how to get the information manually, but I was trying to grab it programmatically and stay consistent with how it appears in the client.

It never asks for the Host name, but still logs into the correct repository.  I do not want to make the user have to provide a host name if I don't have to.

0 0
SELECTED ANSWER
replied on September 16, 2016

The repository name is inside the CloudTicket SAML xml, here is how you can extract it:

using System.Xml;
using System.IO;
using System.Text;
//...
string samlTokenXml = CurrentTicket.GetSamlToken();

using (XmlReader reader = XmlReader.Create(new StringReader(samlTokenXml)))
{
    while (reader.Read())
    {
        if (reader.NodeType == XmlNodeType.Element)
        {
            if (reader.LocalName == "Attribute" && reader.GetAttribute("Name") == "http://laserfiche.com/identity/claims/catalyst/roles")
            {
                int depth = reader.Depth;
                while (reader.Read() && reader.Depth > depth)
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "AttributeValue")
                    {
                        reader.Read();
                                 
                        string roleValue = reader.Value;
                        if (!string.IsNullOrEmpty(roleValue) && roleValue.Contains(":"))
                        {
                            int colonPos = roleValue.IndexOf(":");
                            string roleDomain = roleValue.Substring(0, colonPos);
                            string role = roleValue.Substring(colonPos + 1);

                            if (role == "CreateSession")
                                repositoryName = roleDomain;
                        }
                    }
                }
            }
        }
    }
}

In the future the web API will be published.

3 0
replied on September 16, 2016

Robert

Thank you so much for the reply and answer.  That is exactly what I was looking for.

0 0
replied on July 23, 2020 Show version history

Hi,

 

Do you have anything equivalent in JRA for CloudTicketRequestSettings, CloudTicket? We are also trying to retrieve the list of repositories from cloud and using Java in our case.

 

One other thing, I tried using RepositoryRegistration to connect to the cloud repository with this line below:

 

Session session = new Session();

RepositoryRegistration repository = new RepositoryRegistration("r-xxxxxxxx.laserfiche.com", "r-xxxxxxxx.laserfiche.com", 443);

session.connect(repository);

session.logIn(userName, password);

 

It was mentioned in our previous query that both the server and repository name would be r-xxxxxxxx.laserfiche.com hence we have an identical values entered for server and repository in the line of code above. However, it won't work and I got the following exception in the line "session.connect(repository);":

 

com.laserfiche.protocol.HttpException: The target server failed to respond
 at com.laserfiche.protocol.HttpConnection.sendRequest(HttpConnection.java:222)
 at com.laserfiche.protocol.HttpRequest.sendRequest(HttpRequest.java:58)
 at com.laserfiche.repositoryaccess.Session.connect(Session.java:481)

  

 

 

0 0
replied on July 24, 2020 Show version history

Besides setting the port, on the Session object there is ".IsSecure" property that needs to be True.  Also, don't use the Session.Connect method.  Instead, add the RepositoryRegistration object into the ".login" arguements.

RepositoryRegistration repository = new RepositoryRegistration("r-xxxxxxxx.laserfiche.com", "r-xxxxxxxx.laserfiche.com");
repository.SecurePort = 443;
Session session = new Session();
session.IsSecure= true;
session.logIn(userName, password, repository);

 

1 0
replied on July 24, 2020 Show version history

Bert,

We will try with your latest instruction. Thanks!

0 0
replied on July 27, 2020

Laserfiche Community,

Is there Web API available to retrieve server/repository name  from cloud as of today? Or is there JRA API for the function to be used in Java?

 

0 0
replied on July 27, 2020

The cloud server does not broadcast repositories the way it does on-premises. What are you actually trying to do?

0 0
replied on July 27, 2020

We're trying to get cloud server/repository using Account ID/User Name/Password, the same as how end user logs into Cloud from client. 

User won't know how to get "r-xxxxxxxx.laserfiche.com" value without further instruction.

0 0
replied on July 29, 2020

Also, how do we retrieve the properties for a particular template from the cloud server using JRA API? For on-premises, we are currently using LFQL which I think, won't work in cloud interaction.

0 0
replied on August 10, 2020 Show version history

LFQL is supported for cloud repositories, so you can use that the same as self-hosted.

0 0
replied on August 11, 2020

We will test with existing on-prem LFQL against Cloud to check result.

How about repository name inquiry? Is there Web API available to retrieve server/repository name  from cloud as of today? Or is there JRA API for the function to be used in Java? See reason listed in my previous post as why this is needed.

0 0
replied on August 12, 2020 Show version history

Below is part of the sample java code to test LFQL against Cloud and we got an error.

 

Sample Code:

String connectionUrl = "jdbc:lfql://r-xxxxxxxx.laserfiche.com";

// also tried this url: 

//jdbc:lfql://r-8d364fe4.laserfiche.com/r-8d364fe4.laserfiche.com

Connection con = null;

String userName = "qinlei.fan@ricoh-usa.com";

String password = "***********"; Class.forName("com.laserfiche.repositoryaccess.LFQLDriver");

con = DriverManager.getConnection(connectionUrl, userName, password); //This is where issue is encountered.

 

Also, even tried to add a port 443 in the connectionUrl but still couldn't get through.

The code above is same with the sample code that is found under SDK 10.2.

 

 

0 0
replied on August 12, 2020

Neither connection string looks right to me, the repository name is just "r-8d364fe4". What error do you get?

0 0
replied on August 12, 2020 Show version history

Using the url you suggested, I'm getting the error below:

I also tried using the following connectionUrl but I got the following error:

 

Note: I don't encounter neither of these errors when using local on-premise server.

 

0 0
replied on August 13, 2020

The ConnectionURL is Server/Repository.  You changed the value of both the Server and Repository when Brian said the Repository value was only the r-xxxxxxxx value.  I am not a Java developer, but it seems to me that the Server value should still be the whole r-xxxxxxxx.laserfiche.com value.

0 0
replied on August 13, 2020

Actually, I also tried that. Below are other connectionUrls strings that I have tried and still got the same error:

 

jdbc:lfql://r-8d364fe4.laserfiche.com/r-8d364fe4

jdbc:lfql://laserfiche.com/r-8d364fe4

 

 

 

0 0
replied on August 14, 2020 Show version history

When accessing the Repository through the Web Access, the URL does not have the the repository name as the first part of the url.  You may want to try one of these to see if it works.

 

jdbc:lfql://webaccess.laserfiche.com/r-8d364fe4
jdbc:lfql://webaccess.laserfiche.com:443/r-8d364fe4

The other thing that I would suggest that you try is to create a logged in session object and then get the server IP using the Session.RawHostName method and try using the IP in place of a server name.

 

jdbc:lfql://xxx.xxx.xxx.xxx:443/r-xxxxxxxx

 

0 0
replied on August 17, 2020

Tried adding webaccess with and without port 443 for the connection url below. Below are screenshots showing connectionUrl and its exceptions.

Also,  I was able to get the IP using session.getRawHostName() and used it in the connection url string. however, it failed and I got "connection refused" when I tried to connect to it. Tried it with port 443 as well but its no use. Below are the screenshots.

0 0
replied on August 17, 2020

The JRA library doesn't include the CloudTicket class in Robbie's initial answer. You can use the implementation in the attached file to get a list of repositories and authenticate into them. (Since this forum doesn't allow zip attachments, I've combined the source files into a single text file - it should be clear how to split it back out into Java source files.

---

Laserfiche Cloud Sign-In Java Sample

This project uses JRepositoryAccess (JRA) to sign in to a Laserfiche
repository hosted in Laserfiche Cloud.  The code also shows off how to
retrieve the list of repositories a user is able to access given an
account ID, user name, and password.

The code uses the HttpClient API implementation that is developed as part
of Apache HttpComponents <http://hc.apache.org/httpcomponents-client-4.5.x/index.html>.
However, the sample code could be converted to use any other HTTP client
implementation that is compatible with TLS 1.2.

dom4j is used to parse XML, but any XML parser implementation could be used.

JRA requires the following Java libraries:
- dom4j 2.1
- commons-codec
- httpcore (from Apache HttpComponents)
- jaxen
- icu4j

0 0
replied on August 17, 2020

Brian, 

We will try with the sample code and let you know the result. This is the type of details we're looking for and very helpful.

Can you also provide the exact ConnectionURL we should use for LFQL? As you can see how many we've tested but none of them works. 

0 0
replied on August 17, 2020

Have you tried the LFQLConnection constructor that takes a Session object? That separates the authentication step out.

0 0
replied on August 17, 2020

Would you mind providing sample code to demonstrate the approach you suggested above?

0 0
replied on August 18, 2020

The attachment I posted yesterday has a complete code sample for authenticating to the cloud using JRA. Then it's just

LFQLConnection conn = new LFQLConnection(session);

 

0 0
replied on August 20, 2020

Its now working with LFQLConnection. We are now able to run the query and get the expected response from the Cloud for the properties information.  

The sample code that you provided to retrieve the repository list also worked. 

Thanks. 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.