Menu

Showing posts with label Apache Felix. Show all posts
Showing posts with label Apache Felix. Show all posts

Grant other AEM user to Apache Felix web console

By default only admin user have access to open the Apache Felix web console. Most of the time people have requirement to grant other users and group of users as well to manage the Felix console, so granted users also can read the write the configurations.

How to grant other user to Apache Felix


Apache Sling Web Console Security Provider is a configuration in Apache Felix [http://localhost:4502/system/console/configMgr] where we need to add other users to whom we want to allow access to Apache Felix web console.

Configuration for the security provider used to verify user credentials and grant access to the Apache Felix Web Console based on registered JCR Repository users.

Apache Sling Web Console Security Provider - Apache Felix restriction
Apache Sling Web Console Security Provider

Persistent Identity (PID): 

org.apache.sling.extensions.webconsolesecurityprovider.internal.SlingWebConsoleSecurityProvider

User Names 

Names of users granted full access to the Apache Felix Web Console. By default this lists the "admin" user. A maximum of 20 users may be configured. Administrators are encouraged to create a group whose members are to be granted access to Web Console instead of allowing access to individual users. (users)

Group Names 

Names of groups whose members are granted full access to the Apache Felix Web Console. The default lists no groups. Administrators are encouraged to create a group whose members are to be granted access to the Web Console. A maximum of 20 groups may be configured. Using groups to control access requires a Jackrabbit based repository. (groups)

metatype=true in AEM

Why we add parameter metatype=true in @Component annotation?


When we add parameter metatype=true then Apache felix generate a metatype.xml file for that component, if we don’t then there will no metaype.xml file.
Metatype.xml file contains an element <OCD> which have parameters name and description of the component. Under the <OCD> we have another ta <AD> which have detail information of property which we want to make visible and configurable on Apache felix console localhost:4502/system/console/configMgr.
So if we specified ten properties in our component then there will be ten <AD> elements under the <OCD>

Metatype.xml file also contains the element <Designate> with attribute PID and <Object> which has parameter OCDREF under the <Designate> element, which represent and store the configured values. Value for PID and OCDREF is always used to same and that is also the name of the file which you will find in the CRX.  

When we add metatype=true in the parameter of @component that means we have made the property of that component or service configurable and visible on Felix console, which is an easy and helpful way to configure properties of any component and service. Felix web console uses the meta type information to show user-friendly and easy the GUI configuration.

interface MetaTypeService helps to obtain the meta type information of any bundle and component. MetaType Service will examine the specified bundle for meta type documents to create the returned MetaTypeInformation object.
If the specified bundle does not contain any meta type documents, then a MetaTypeInformation object will be returned that wrappers any ManagedService or ManagedServiceFactory services registered by the specified bundle that implement MetaTypeProvider. Thus the MetaType Service can be used to retrieve meta type information for bundles which contain a meta-type document or which provide their own MetaTypeProvider objects.

Where I could find the metatype.xml file in my project? Or Where metatype.xml file exist?

[PROJECT NAME]\core\bin\target\classes\OSGI-INF\metatype

Example of a metafile.xml



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="UTF-8"?><metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/com.rashid.jorvee.aem.services.MetaTypeExample">

    <OCD id="com.rashid.jorvee.aem.services.MetaTypeExample" name="%com.rashid.jorvee.aem.services.MetaTypeExample.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.description">

        <AD id="MetaType.userID" type="String" name="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.userID.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.userID.description"/>

        <AD id="MetaType.contact" type=" Integer " name="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType. contact.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.contact.description"/>

        <AD id="MetaType.address" type="String" default="Boston, united States" name="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.address.name" description="%com.rashid.jorvee.aem.services.MetaTypeExample.MetaType.address.description"/>

    </OCD>

    <Designate pid="com.rashid.jorvee.aem.services.MetaTypeExample">

        <Object ocdref="com.rashid.jorvee.aem.services.MetaTypeExample"/>

    </Designate>

</metatype:MetaData>

In the above example, we have created a service class MetaTypeExample which have following configurable properties.
  1. userID
  2. contact
  3. address