Package de.hybris.platform.jalo.security
Class ImportExportUserRightsHelper
- java.lang.Object
-
- de.hybris.platform.jalo.security.ImportExportUserRightsHelper
-
public class ImportExportUserRightsHelper extends java.lang.ObjectThis class provides all methods that are necessary to import and export a principal in the form of a CSV file in which all entries (column names, lists of access rights, and so on) If you specify a configuration for the CSV file's entries, the file's content will comply to the hybris Platform's default import / export settings.
CSV file settings
The default settings for a CSV file are:- text separator char is " - This char encloses a CSV field. If any special character occurs in this field (like another textseparator char or a field separator char, for example), the " will be doubled.
- field separator char is ; - This char separates different CSV fields.
- data separator char is , - This char separates several bits of data contained in one single CSV field. In this class, the comma is used in the Field MemberOfGroups to seperates the groups which the principal belongs to.
CSV data structure
The first line is alway the CSV header line. By default, it is the following string:
"Type";"UID";"MemberOfGroups";"Password";"Target";"read";"change";"create";"remove";"change_perm"
Note: for the import it is important that the first five keywords occur in the string. If not at least these five keywords are there, the import will ignore the respective line.
A data set consists of at least one line. If only one line is specified, the principal will have no rights defined at any type. In the first line to be imported, the value for the fields Type and UID is always specified. If the principal comes with value the fields MemberOfGroups and Password (only for User) are also sets. If this principal has setted rights on a type (or types) in the next line the first four fields are empty. The field Target describes the type which the principal modified rights for. In the next five columns the rights are set.- + indicates a positive permission
- - indicates a negative permission
- if this field is empty the permission from the supertype is used
ImportExportUserRightsHelper(Writer writer, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals, ArrayList permissionlist)or the settersetDefaultPermissionList(ArrayList permissionlist). Remember to set the same list for the import.
other settings
- By default, the export will only write the principal to the csv file which have set some rights to types
- Since:
- 2.10
-
-
Field Summary
Fields Modifier and Type Field Description static charDEFAULT_DATASEP
-
Constructor Summary
Constructors Constructor Description ImportExportUserRightsHelper(java.io.Reader reader)Constructor.ImportExportUserRightsHelper(java.io.Reader reader, boolean exportallprincipals)Constructor.ImportExportUserRightsHelper(java.io.Reader reader, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals)ImportExportUserRightsHelper(java.io.Reader reader, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals, java.util.ArrayList permissionlist)Constructor.ImportExportUserRightsHelper(java.io.Writer writer)ImportExportUserRightsHelper(java.io.Writer writer, boolean exportallprincipals)ImportExportUserRightsHelper(java.io.Writer writer, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals)ImportExportUserRightsHelper(java.io.Writer writer, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals, java.util.ArrayList permissionlist)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexportSecurity()Export the user rights from all users and usergroups.voidexportSecurity(java.util.Set principallist)Writes all principals to a writer (is plaintext csv informations).chargetDataSeparator()java.util.ArrayListgetDefaultPermissionList()intimportSecurity()read from a reader (for example filereader) the CSV stream, interpretes them as principals (and all SubTypes) and writes them into the systembooleanisFlag_exportAllPrincipals()This method returnstruewhen all Principals (User and/or UserGroup) should be exported no matter if they have Rights defined or not.voidsetDataSeparator(char dataseparator)Set the char for the CSV file which seperates in the field MemberOfGroups (enclosed by textseparator char) the groups.voidsetDefaultPermissionList(java.util.ArrayList permissionlist)Set the default permissionlist.voidsetFlag_exportAllPrincipals(boolean flag_usesAllPrincipals)This method sets the export all User|UserGroup flag.
-
-
-
Field Detail
-
DEFAULT_DATASEP
public static final char DEFAULT_DATASEP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Reader reader)
Constructor. Set all to hybris default setting.
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Reader reader, boolean exportallprincipals)Constructor.- Parameters:
exportallprincipals- should be all principals exported(true) or only those with data(false). Only needed for export.
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Reader reader, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals)
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Reader reader, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals, java.util.ArrayList permissionlist)Constructor. Configures all.- Parameters:
textseparator- char which enclose a csv fieldfieldseparator- char which seperates a csv fielddataseparator- char which seperates in the field MemberOfGroups thegroupsexportallprincipals- flag which indicates if all principals should be exportet (true) or only those which set rights for types (false)permissionlist- a list with rights
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Writer writer)
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Writer writer, boolean exportallprincipals)
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Writer writer, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals)
-
ImportExportUserRightsHelper
public ImportExportUserRightsHelper(java.io.Writer writer, char textseparator, char fieldseparator, char dataseparator, boolean exportallprincipals, java.util.ArrayList permissionlist)
-
-
Method Detail
-
exportSecurity
public void exportSecurity()
Export the user rights from all users and usergroups.
-
exportSecurity
public void exportSecurity(java.util.Set principallist)
Writes all principals to a writer (is plaintext csv informations).- Parameters:
principallist- a list with rights
-
getDataSeparator
public char getDataSeparator()
- Returns:
- returns the char which seperates datavalues in the csv field MemberOfGroups
-
getDefaultPermissionList
public java.util.ArrayList getDefaultPermissionList()
- Returns:
- a list with a defined order of Rights which exists in the system. As default this list contains the rights
read, change, create, remove, change_perm
-
importSecurity
public int importSecurity() throws JaloInvalidParameterExceptionread from a reader (for example filereader) the CSV stream, interpretes them as principals (and all SubTypes) and writes them into the system- Returns:
- how many lines were imported
- Throws:
JaloInvalidParameterException
-
isFlag_exportAllPrincipals
public boolean isFlag_exportAllPrincipals()
This method returnstruewhen all Principals (User and/or UserGroup) should be exported no matter if they have Rights defined or not.- Returns:
- false if only principals should be exported when they have Rights defined
-
setDataSeparator
public void setDataSeparator(char dataseparator)
Set the char for the CSV file which seperates in the field MemberOfGroups (enclosed by textseparator char) the groups.- Parameters:
dataseparator- the char, as default the char ',' is used
-
setDefaultPermissionList
public void setDefaultPermissionList(java.util.ArrayList permissionlist)
Set the default permissionlist. The List contains all Rights (READ, WRITE, CHANGe for example) which exists in the system. This List is needed for export and import in which order the colums are sorted.- Parameters:
permissionlist- the new list with rights to set
-
setFlag_exportAllPrincipals
public void setFlag_exportAllPrincipals(boolean flag_usesAllPrincipals)
This method sets the export all User|UserGroup flag. If set tofalseall User|UserGroups in the system will be exported. These User|UserGroup which have no Rights defined will also be exported (if false)- Parameters:
flag_usesAllPrincipals-
-
-