NodeJs : Liferay api to fetch the "custom field" created for Role - node.js

According to my requirement in Liferay, I have created custom fields for roles and assigned it to a user. My goal is to call the JSONWS API and get these custom fields using NodeJS. I am not able to decide which API I should call.
This Url is having APIs: http://www.liferay.com/api/jsonws
I will appreciate for any kind of help.
Regards

AFAIK there is no options to access the expando value via exposed webserveices.
Probably what you can do is that, create a custom portlet, add a dummy entity in the service builder and in that expose a method for web service. In that method call the role API and expando API , and return the result you want.

Custom Fields are called "Expando" in the API and are modeled like virtual tables. The functionality that's exposed through webservices is ExpandoColumn and ExpandoValue. Probably the best way to figure out the parameters to give is to look at the matching database tables. Careful: You should only ever read the database and not be tempted to write to it.
I hate giving the advice to go to the database, but this is probably the quickest - at least for my explanation :)

Finally, I got a genuine solution without hitting database directly. JSONWS is having api :
/portal.expandovalue/get-data
Which helped me to get attributes assigned to a particular role.
The above API needs 5 parameters to be passed.
companyId: whaterver the companyId assigned for your liferay.
className: It depends upon, we created attribute for role or user
com.liferay.portal.model.Role or com.liferay.portal.model.User
tableName: CUSTOM_FIELDS
columnName: It is the same name you given for attribute
classPK: It is nothing but your role or user ID for which you have created Attribute.

In case you are getting "java.lang.NullPointerException" when using #user3771220 solution, try com.liferay.portal.kernel.model.User

Related

User Info from JWT Kogito

I understand the mechanism of OIDC in Kogito with the help of process-usertasks-with-security-oidc-quarkus example.
However, I have a question about user information. In the given example, the approved field is filled by a Query string. Is there any way to get user information in Kogito? If it doesn't have that feature, can it reflect from header to service?
The integration with the security context inside the Kogito app is something that is on the radar, see https://issues.redhat.com/browse/KOGITO-6162. That would ignore the query string and use the authenticated user. Perhaps, for now, you could create your own endpoint to retrieve the authenticated information as needed and mimic the same API call that is done in the generated endpoint.
I figure out a temporary fix that problem with help of written Custom Service when using Kogito with Quarkus.
https://quarkus.io/guides/security-jwt
JWT Injection can call from the Service layer when used with Kogito.
It is also possible to propagate user identity to other workflow items with internally tagged process variables.

How can I fetch the existing table data in aportlet

I am trying to create the user by site admin so I have created a portlet which has basic user details form and in the action class I called the UserLocalServiceUtil.adduser(). Now the values are inserting into the DB in USER_. Now I want to display the list of created users by only site admin how can I do that? I have the following queries.
1) How can I fetch the values from USER_ in my portlet. Do I need to create the service builder OR are there API methods to fetch the values from the USER_ table?
2) I want to display only the users list which is created by site admin in my portlet. I don't want to display the whole company list of users. So How can I achieve this?
Suggest me any references or guidelines to do this.
Your help will be very much appreciated.
For Q1 :
http://cdn.docs.liferay.com/portal/6.1/javadocs/com/liferay/portal/service/UserLocalServiceUtil.html#getUsers(int, int)
This might help you. You don't need service builder for that. Just create a simple Liferay MVC portlet and call the relevant methods.
for Q2 : I don't think this would be possible by API methods. What you can do is to set an expando variable for user at time of creation by site-admin. And # time of fetching users, you can cross-check the value of that field manually.
EDIT :
One more point for suggestion : Never create user with Site-Admin role for user creation. This role is supposed to manage site & user assignment to the site. You can use more appropriate role i.e. Org-Admin rather than site-Admin.
How to set an expando variable while adding the user?
Liferay provides Expando API interface, which you can use while creation of user in your portlet. refer following links Developing with Expando, Liferay Expando API
I hope this would be helpful to you.

Customizing ASP.NET Identity, OWIN and Social provider logins

I am new to ASP.NET MVC 5 and OWIN.
I have upgraded my project to MVC 5 to implement the authentication and authorization of my project. Problem is that my project does not store the user data. When user logins in I ask a different system via a WCF service to tell me if the user is authenticated. So I do not have a database nor tables that the user is stored in.
But I want to add the ability to login via social providers using OWIN. For this I will add a local database table to store the social provider Id/Token
Looking around other have asked similar question but only when they want to change database type store... Whilst I actually don't store the data... Is it still possible to customize this with ASP.NET Identity and how would I do this?
I would recommend creating a custom IUserStore that connects to the wcf service.
http://www.asp.net/identity/overview/extensibility/overview-of-custom-storage-providers-for-aspnet-identity
If you don't want to implement your own IUserStore, you can still use the built in default EF based UserStore and just only use the external login apis. The database schema will have a bunch of columns that will always be null like PasswordHash etc, but the operations you care about would still work fine:
CreateAsync(TUser) - Create a user
AddLoginAsync(userId, UserLoginInfo) - Associate an external login
FindAsync(UserLoginInfo) - Return the user with the associated external login
I looked into the solutions suggested. I found that the method names of the interfaces to implement did not really fit and there where way too many methods as well.
I ended up only using the OWIN Context in AccountController to extract the LoginInfo with all the details I wanted. This way I did not have to implement any custom versions of IUserLoginStore etc...
I wanted the simplest solution to implement and therefore I ended up with:
1. Added StartupAuth class from template mvc project and configured different providers there
1. In AccountController: Extracted the claims from LoginInfo,
2. Stored OpenId in a table for lookup and then continued on as before.
You have to provide a UserStore and pass it to the UserManager, if you are already using entityframework in the default mvc5 project, you can write your CustomUserStore which inherits from Microsoft.AspNet.Identity.EntityFramework.UserStore and override the methods defined in Microsoft.AspNet.Identity.EntityFramework.IUserLoginStore:
public interface IUserLoginStore<TUser, in TKey> : IUserStore<TUser, TKey>, IDisposable where TUser : class, Microsoft.AspNet.Identity.IUser<TKey>
{
Task AddLoginAsync(TUser user, UserLoginInfo login);
Task<TUser> FindAsync(UserLoginInfo login);
Task<Collections.Generic.IList<UserLoginInfo>> GetLoginsAsync(TUser user);
Task RemoveLoginAsync(TUser user, UserLoginInfo login);
}
if you don't use entityframework, you have to provide your own way of accessing your database,by writing a UserStore which implements IUserStore, IUserLoginStore, IUserClaimStore, IUserRoleStore,IUserPasswordStore,IUserSecurityStampStore (depends on your need but at least IUserStore and IUserLoginStore as IUserStore is mandatory and IUserLoginStore is what you want to add)
all these interfaces are in Microsoft.AspNet.Identity namespace.
here how to implement a Custom MySQL ASP.NET Identity Storage Provider and
here how to use Dapper ORM instead of EntityFramwework.

Liferay - Authentication without populating liferay db

Again, Do we have any possible solution that avoid populating liferay db with user information for authentication using extending methods/custom implementation/hooks/plugins/extensions?
Regards
Vishal G
There's no way to avoid creating a user in the Liferay database. You can though create a dummy user that all users use or a dummy user for every user depending on your needs
It is generally not desirable to share accounts as you cannot benefit from all functionality regarding groups, personalization, ... This is basically why one would install a portal.
To create users you can use Liferay's services.
If authorization is not your concern, it is possible to override the authenitaction mechanism with a variety of methods. THe authentication pipeline might be a good starting point.
http://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/authentication-pipeline
Good luck!
You can create a Liferay Hook to Authenticate using your custimization.
override the following jsp page.
/html/portlet/login/login.jsp
Or you can create your own login portlet. No need to populate all users in db.
Just findUserById().
Dont forget to mention this change in portal-ext.properties file. You will need to specify custom Login portlet id.

Complex mapped properties in Sharepoint

Is there any way to set a more complex mapping in a sharepoint profile? What I'm trying to do is set it so that a user's picture is set as the equivilent of
String.Format("http://sharepoint/Photos/{0}_{1}.jpg", givenName, sn)
But the properties only seem to support a simple 1-1 mapping of AD to profile attributes.
I don't think there is a way to do this, other than writing a custom timer job to populate the profile fields by querying AD.
It's possible to map SharePoint profiles to data sources other than AD, for example if HR data is stored in a custom database a BDC model can be made, which can be used as a data source for user profile importing.
For this scenario it sounds like you'd be better off doing as the above poster suggested and just writing a timer job that queries the user profile service for users with an empty picture property, and setting it to your custom URL.
Thanks guys, I'm going to stick with the previous solution though, which was updating one of the extension attributes in AD to the formatted string, then mapping that directly to the profile field.

Resources