Getting started with Liferay SAML 2.0 Identity Provider


Liferay 6.1 EE comes with SAML 2.0 Identity Provider and Service Provider support via SAML plugin. If you are not familiar with SAML check out my Introduction to SAML presentation slides.

In this post we will configure Liferay to be SAML Identity Provider and configure Salesforce to be a Service Provider. After we are done we have a user that can move from Liferay to Salesforce without requiring to authenticate on Salesforce. 

You’ll need following things to complete this by yourself:

* Liferay Portal 6.1 EE GA1 Tomcat bundle
* SAML Portlet WAR
* Salesforce developer account. You can sign-up here for free.

The first thing to do is download and install Liferay. If you need help configuring Liferay refer to Liferay 6.1 User Guide. Once that is done you’ll need to configure the SAML identity provider before deploying the plugin. The IdP needs a private and public key pair for signing SAML messages. It uses Java keystore to store the them. We’ll create the keystore and they key pair using keytool that is part of the JDK. You need to pick a unique entity id for your IdP and a password that is used to protect keystore and the private key. In this example we’ll use liferaysamlidpdemo as the entity id and liferay as the password for both keystore and the key. The keystore is created in LIFERAY_HOME/data/keystore.jks as this is the default location SAML plugin will look for it. You can also configure the location and type of they keystore and will do it here just for reference.

keytool -genkeypair -alias liferaysamlidpdemo -keyalg RSA -keysize 2048 -keypass liferay -storepass liferay -keystore data/keystore.jks

You’ll be asked to provide some information that will be in the certificate with the public key.

What is your first and last name?
  [Unknown]:  Liferay SAML IdP Demo
What is the name of your organization?
  [Unknown]:  Liferay SAML IdP Demo
What is the name of your City or Locality?
What is the name of your State or Province?
What is the two-letter country code for this unit?
Is CN=Liferay SAML IdP Demo, OU=Unknown, O=Liferay SAML IdP Demo, L=Unknown, ST=Unknown, C=Unknown correct?
  [no]:  yes

Next step is to add SAML configuration to your





Now you can deploy SAML plugin by copying it to LIFERAY_HOME/deploy and starting up tomcat. Wait for the saml-portlet to be deployed and available and then open http://localhost:8080/c/portal/saml/metadata. If you have configured everything correctly you should see the IdP metadata similar to below. I’ve just shortened the data on signature and certificate elements.

<?xml version=“1.0” encoding=“UTF-8”?>
<md:EntityDescriptor xmlns:md=“urn:oasis:names:tc:SAML:2.0:metadata” entityID=“liferaysamlidpdemo”>
<ds:Signature xmlns:ds=“”>
   <ds:CanonicalizationMethod Algorithm=“”/>
   <ds:SignatureMethod Algorithm=“”/>
   <ds:Reference URI=“”>
     <ds:Transform Algorithm=“”/>
     <ds:Transform Algorithm=“”/>
    <ds:DigestMethod Algorithm=“”/>
  <ds:SignatureValue>AAJsDF8dJv5XQw6Ty1MSg7 … OXvQw==</ds:SignatureValue>
    <ds:X509Certificate>MIIDjjCCAnagAwIB… </ds:X509Certificate>
<md:IDPSSODescriptor ID=“liferaysamlidpdemo”
  WantAuthnRequestsSigned=“true” protocolSupportEnumeration=“urn:oasis:names:tc:SAML:2.0:protocol”>
  <md:KeyDescriptor use=“signing”>
   <ds:KeyInfo xmlns:ds=“”>
     <ds:X509Certificate>MIIDjj …</ds:X509Certificate>
  <md:SingleLogoutService Binding=“urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect”
  <md:SingleSignOnService Binding=“urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect”
  <md:SingleSignOnService Binding=“urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST”

Even though the IdP is configured and functioning it’s not very useful because there’s no Service Providers configured. For this example we are going to use Salesforce developer account to demonstrate single sign-on between Liferay and Salesforce. If you haven’t already signed up for Salesforce developer account do it here.

We’ll need to export the certificate from keystore because Salesforce doesn’t know how to read SAML metadata.

keytool -export -alias liferaysamlidpdemo -file liferaysamlidpdemo.crt -keystore data/keystore.jks -storepass liferay -keypass liferay

Now login to your Salesforce developer account in here. On your dashboard click on Setup. 


Then click on Security Controls > Single Sign-On Settings under Administration Setup.


Then click on Edit.

Here’s the setting you need:

* SAML Enabled.
* SAML Version: 2.0
* Issuer: liferaysamlidpdemo (this is the entity id of the IdP)
* Identity Provider Certificate: liferaysamlidpdemo.crt which you exported earlier.
* Identity Provider Login URL: http://localhost:8080/c/portal/saml/sso
* SAML User ID Type: Select Assetion contains User’s username
* SAML User ID Location: Select User ID is in the NameIdentifier element of the Subject statement
* Identity Provider Logout URL: http://localhost:8080/c/portal/logout (Salesforce does not support SAML Single Logout Profile)


Verify that your setting as correct and then click on Download Metadata. Also note the Entity Id as this will be needed on the IdP side.

Move the downloaded metadata xml to LIFERAY_HOME/data/saml/salesforce-metadata.xml. Now we need to configure the IdP to know about this Service Provider. This is done by telling saml plugin where to find the SAML metadata for Salesforce.


If your Salesforce Entity Id is not you’ll also need to add following lines to your Note I’m using as the entity id but you would replace it with what ever Salesforce reported it to be.


If you had your tomcat still running just restart it so that the new property value is read. Then login as / test. Now click on Manage > Site Pages. Click on Add Page. Add following values:

Name: Salesforce
Type: URL
URL:  /c/portal/saml/sso?entityId= 

Notice the entityId is the same Entity Id that was shown as entity id on the Salesforce Single Sign-On configuration page.

Go to Control Panel and add a new user with same email address as your Salesforce developer account. Sign out and login with that new account. Now click on the Salesforce page link. If everything was configured correctly you are redirected to Salesforce and you are signed in with your developer account. If you want to be redirected to some other page than they home page you can add a URL parameter RelayState with the page URL you want to be redirected to as the value. For example the URL could look like this /c/portal/saml/sso?entityId= This would take me to my Opportunities page directly.

Now sign out from Salesforce and you will be taken back to Liferay and logged out from Liferay. Now if you click on the Salesforce page it will take present you with Liferay login page and after login will take you to Salesforce.

Update: If you need to setup Liferay as SP check out my collegues post Setting up Liferay as Service Provider.

Where can I download the SAML Portlet WAR? -- Thanks
It's available in Customer Portal like all EE plugins.
Hi Mika,
thanks for your post.
i am able to use the single sign on functionality with salesforce with the admin user
but whenever i try to sign in with another user(imported from LDAP) this functionality is not working i am getting error "your login attempt with single sign on account have failed,please contact your salesforce administrator"

One more question i want to ask is the user which is getting authenticated using liferay sign up this particular user have to be registered on
means my use case is
we have a liferay integrated with LDAP and we would like SSO LDAP users in without registering those users in
we just want to create authentication certificate for
how can we achieve above functionality.
You'd need to provision the users from your LDAP to Salesforce or to configure Salesforce to automatically create users from attributes provided in SAML Assertion.
is this the only way to register ldap user in sales force or can we generate the keystore with ldap group which contains all the users and register that certificate in salesforce....
we cannot allow LDAP connectivity to Salesforce and would like to use SAML assertion for creating users. How to do that?
and one thing we want to add some custom fields from LDAP to be inserted in the SAML how can we do that.
please suggest
Hi Mika,

can you please tell how to pass RelayState in the link
my relay state value will be(tc=E1001)

Hi Mika,
thanks for the reply.
i just want to ask that on salesforce end how can we check the field firstname lastname email uuid and screenname and on liferay end we have configured
saml.idp.metadata.attribute.names[]=screenName,firstName,lastName,emailAddress,uuid this property
please reply because i am kind of stuck on this.
Cool! Thanks Mika!
Thanks Mika. I got the SAML WAR and it works like a charm!. Just one more question. How do I use Liferay as IdP to connect to two SPs? say one is Salesforce and another is Google App. And I would use different Liferay user fields other than email address as SSO subject, or two different email addresses, one for Salesforce, one for Google App.
Cool..thnx Mika for sharing this..
great job!
Thanks Mika, Very useful blog.....
Works very well, however on logout from salesforce, it's redirected to /c/portal/logout
Paul, that's because Salesforce does not support SAML Single Logout profile.
Liferay SAML 2.0 IdP support is it only for EE edition. Is it not available for CE.
Can CE be part of SP? Please let us know. Thank you.

The SAML plugin is for EE only.
Hi Mika,

we have a use case where we have to connect with one of the share point application which does not support SAML, so for that we have bring forward the ADFS as the broker between the liferay and share point application.

We have configure the ADFS metadata in liferay and sending the userprinciplename as the name id to adfs, and we are able to send the saml response successfully. In ADFS liferay has been configured as the claim provider and share point application has been configured as the relying party.

When we are posting the saml response to ADFS, it reaches the ADFS successfully but the application is not able to redirect to relying party , it stays on the ADFS only. Can you please help if you have came across such use case.

Thanks in advance..It will be a great help.
I cannot find the SAML portlet war. I looked for the Customer Portal, but could not find that either. Is this available with the 30 day free trial of 6.1 EE? I found the liferay-asb-sso-hook-1.0.1.war, is this what I need? Whenever I hit, http://localhost:8080/c/portal/saml/metadata, it redirects me to http://localhost:8080. Thanks.
Sorry, I didn't realize the customer portal was for actual customers and not trial users. The sales office gave me access to the necessary jar. Thanks again.
We tried to use it. It worked nicely, but not for us emoticon We need to have both SAML and plain-authentication available for users. Users must get forwarded to the login-page where they can choose. This was not possible (read: we didn't find out how) to set-up with SAML-plugin. When activated, all logins, are redirected right to the SAML (federatedt) in-logging-page only.
Can some one walk me thru the steps if we want to use our AD as the identity provider and use Liferay as the Service provider. This may help us to resolve our LDAP issue.
I don't think AD by itself can be SAML IdP but with Microsoft's Active Directory Federation Server (ADFS) 2.0 I think you could do that. The principals are the same but I can't help you with ADFS configuration as I've never used it.
Hi Mika,

Thanks for prompt response.I will try your suggestion with my seniors and if we succeed , will also update you.

Vipin Bardia
Good Information.Thank you Mika
Armaz Mellati, yeah the current version of the SP is very limited. I'll keep that in mind for the next version as I already had thought about adding support for multiple IdPs so that would fit right in with it.

Thanks everyone for your feedback. I'm always interested in hearing how and with what other SAML IdP or SP you are using it with. Also I'm very interested in hearing what features you think it's missing. Feel free to post here or email me firstname.lastname @
Mika, do you have a timeline for adding support for multiple IdPs?
To clarify what "multiple IDPs" mean, Mika are you referring to the ability of a single LR server in IDP mode to support using different certificates for signing assertions to different service providers? The SAML plugin in its current state allows me to configure multiple SPs for an IDP Initiated Web SSO scenario - but even if I configure 50 different SPs I would be signing all of those assertions with the same single certificate, right?

I have a client that is requiring that I provide them with a unique certificate for each of their SP entityIDs.

What I believe I would need is a way to configure multiple IDP entity IDs - each with their own keystore certificate - and then a way to associate that specific entityID with a specific SP entityID. That way I could utilize a different certificate for each SSO "route".

Example with proposed config changes:

/first.service.provider.metadata.xml, \
?? ??

# First IDP Entity ID Config[https\://]=https\://

# Second IDP Entity ID Config[https\://]=https\://

Is this something that is in the works at all? Or should I accept the fact that I'll need to roll my own to get this kind of functionality. Will try contacting you via email also.

Did you every got to configure Multiple Idp ?. Did you have to develop custom code to achieve this feature
Is the download for the WAR In the "Official Plugins"? When I do a search for SAML I can't find it. I can find the AssureBridge SAML war in the community plugins, but can't find the official one... Point me in the right direction?
Ryan, this is a EE only plugin so you need to be EE subscriber to get it. For EE subscribers it's found in the customer portal where you download EE version of the portal etc.
I have followed the steps to setup liferay as idp but when I try to access


Its redirecting me to home page instead of displaying metadata.
Did you login to Liferay before accessing the page? The URL pointed to a private page I believe
I followed these steps to a T and I keep getting:

Error [KeyStoreManagerImpl:122] Unable to load Keystore Keystore was tampered with, or password was incorrect

I have checked numerous times to make sure all information in my file is correct and it is. So not sure why I am getting this error.
I have followed the steps but when I try to access the url "http://localhost:8080/c/portal/saml/metadata" I got "Internal Server Error"

Any suggestions ?
Has it worked for you, i am getting the following errors " Unable to process SAML request "when i try to access the URL http://localhost:8080/c/portal/saml/metadata, in the logs the error is "Credential is Required"
how do i access the source code for SAML portlet plugin?
HI, Thanks for the plugin - in Service Provider mode, is it capable of getting a user's groups from attributes? I am an EE user, and am potentially interested in using this plugin.


I need it for WSRP (remote portlets) - How to make it work? does liferay support that?
Haikel, we don't currently support SAML with WSRP although it is on our future roadmap.

I went through the setup steps you outlined, but I am getting a null pointer exception. The authnRequest is coming back null after this line in: com.liferay.saml.profile.WebSsoProfileImpl:

AuthnRequest authnRequest = samlMessageContext.getInboundSAMLMessage();

I am trying to debug why and have this question: do I need to generate a keystore.js from the command line AS WELL AS in the SAML UI? They both seem to be doing the same exactly thing so do I need to do both of them or just from the command line?

Thank you.
If you got UI then use it only because using both will just make a mess. Make sure your Idp knows about your SP and vise versa.

Thanks for the quick response.

Just to be clear, I am talking about the form to generate a Certificate and Private Key in the General tab of the SAML portlet. I ask because you didn't mention that in your initial instructions, and it seems to require the same inputs as the command line you mentioned.

I did submitted the form, but will that cause a mess if I also specify the jeystore.jks file in as you said?

Thanks again,
Thank you!
When this blog post was written there was no UI. The UI writes to the same keystore specified in the if FileSystemKeyStoreManagerImpl is in use and it is the default one for backwards compatibility.
Thanks Mika, that helps.

After submitting the form, restarting Tomcat and refreshing the page:

com.liferay.saml.SamlException: No SAMLRequest or SAMLResponse query path parameter, invalid SAML 2 HTTP Redirect message
at com.liferay.saml.profile.WebSsoProfileImpl.processAuthnRequest(
at com.liferay.saml.profile.WebSsoProfileUtil.processAuthnRequest(

Am I missing a parameter somewhere?

Here's the saml props from my


Hi Mika,
Do you know when was the UI introduced?
I'm on 3.1.20 ee ga2 and I don't have UI.
I have configured SAML sso between 2 instances of LR (IdP and SP) and it seems to be working well to an extent (can't seem to get custom user fields working) but I can't even see SAML portlet anywhere in the portal, except for in portal properties in system administration. Now wondering if my installion is ok or If I'm missing something.
The UI should be included in the next release. When it will be made generally available I don't know the latest should be with 6.2 EE.
Hi Mika,
Thanks for the quick reply!

Can I also draw your attention to another question I posted related to SAML here -

Apologies for crossposting!

I apologize in advance for cross-posting, but I wanted to ask an urgent question about this:

Original link here:

We have a client who needs to implement Liferay as an SP for BOTH user login *and application login. We are already implementing SAML plugin for user login.

The Application login will be Liferay(SP) logging in to the IDP as an application user, not as a specific user so we need both. Does the SAML plugin have any support for this out of the box?

If not, would we need a BOTH a SAML metadata IDP XML for the user login *AND another SAML metadata IDP XML for the application login?

Is this completely out of the use case of SAML to do an application login? Please tell me we are not the first ones to be asked to use SAML to do this?

Thanks in advance.
Well it depends what you mean by application login. We don't support ECP profile yet which is something you'd need for example to do SAML based authentication to WSRP. You could use JAAS with SAML but that depends on your use case whether that works or not.
Thanks Mika. I just received more clarification. Does the SAML portlet support doing an AttributeQuery and getting a specific attribute from the IDP?

AttributeQuery is not supported at this point. You can include attributes in the Response only.
ughh... Thanks. General question to gage difficulty: can you give me a rough estimate on how long you would expect a good java java developer (with no knowledge of this plugin and limited knowledge of SAML) to get in and make those changes to support AttributeQuery and are there any external roadblocks that would prevent us from adding that? Again, I appreciate your help.
I took a quick look at the spec to refresh my memory on AttributeQuery and it seems that implementing just that part shouldn't be all that difficult. I'd say that a week should be more than enough for someone that knows SAML. I don't see any roadblocks from adding it and the plugin is fairly extendable. If you don't mind sharing more details on your use case I'd be interested in hearing. You can do that privately by emailing me directly. My email is firstname.lastname at
Thanks Mika. I may take you up on that when we get closer to implementation.

We have another issue related to setting up an IDP:

18:25:44,140 DEBUG [http-bio-8080-exec-14][BaseSAMLMessageDecoder:46] Intended message destination endpoint:
18:25:44,141 DEBUG [http-bio-8080-exec-14][BaseSAMLMessageDecoder:46] Actual message receiver endpoint:

Both SP and IDP are Liferay. When both servers were only listening on HTTP, the connection worked fine, but we just enabled https on the servers and now we are getting this error. We did set saml.require.ssl=true, but we are still seeing the same error. What do we need to do to get past this error?

Thanks in advance.
Hi Mika,

We are also getting this Exception in the logs of the IDP. They don't appear to be related:

Caused by: No SAMLRequest or SAMLResponse query path parameter, invalid SAML 2 HTTP Redirect message
at org.opensaml.saml2.binding.decoding.HTTPRedirectDeflateDecoder.doDecode(
at org.opensaml.saml2.binding.decoding.BaseSAML2MessageDecoder.decode(
at com.liferay.saml.profile.BaseProfile.decodeSamlMessage(
at com.liferay.saml.profile.WebSsoProfileImpl.decodeAuthnRequest(
at com.liferay.saml.profile.WebSsoProfileImpl.doProcessAuthnRequest(
at com.liferay.saml.profile.WebSsoProfileImpl.processAuthnRequest(

Do you have any idea what is causing this? Any tips would be very appreciated!

Thank you!
This could be caused by someone accessing /c/portal/saml/sso or /c/portal/saml/acs without correct parameters.
Hi Mika,
I am following up your conversation with Clint Wilde. We work in the same team. Now we are getting the response back from IDP, I can see NameID in SAML reponse.

<NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">YjY3ODliOGUtNGUwMy00MGIwLWEyYmYtZWE5MTk1OTUzYWE1JjNCRTk4MzIwLTA0RkEtNDQ1Ny04MTBFLTgwQkM0MTlGNUE4NA==</NameID>

But still getting this exception on our side (we are SP):

00:01:52,509 ERROR [http-bio-8080-exec-30][status_jsp:665] com.liferay.saml.SamlException: Name ID not present in subject
com.liferay.saml.SamlException: Name ID not present in subject
at com.liferay.saml.profile.WebSsoProfileImpl.doProcessResponse(

Your insight would be much appreciated. Thanks in advance.
First of all Liferay doesn't support transient NameID. Secondly the SubjectConfirmationMethod has to be urn:oasis:names:tc:SAML:2.0:cm:bearer in order for the subject to be accepted.
Did u get this error resolved? If so plz advise.
Make sure you are consuming the metadata from https url otherwise it will generate the urls with http.
HI Mika,

Please reply as i am stuck on this since a long time.

besides that does liferay support http redirect binding.

in my case the request is coming from the Service provider in the query string with request method as GET. can you please confirm.

Thanks & Regards
Hi Mika,

Quite an informative blog, i am able to setup the idp sso successfully, just quick query in the saml response the signature tag is not getting generated, besides that all the other tags are generated correctly.

Please let me know if any other property needs to be added in the saml configuration to add the signature in the saml response.