Class SecUserTableWriteCallback
java.lang.Object
de.businesscode.bcdui.binding.write.WriteProcessingCallback
de.businesscode.bcdui.subjectsettings.SecUserTableWriteCallback
To enable this class, add it as WriteProcessing/Callbacks/Callback/@class to bcd_sec_user BindingSet
When writing to bcd_src_user we apply special handling:
1. Real column names of password and salt are not available in the BindingSet, so we set them here (for this one Wrq instance only, the value in BindingSet itself is not touched)
Defaults are 'password' and 'password_salt', can be overwritten in web.xml in shiro as realmBcdJdbc.bcdSecUserPasswordColumnName/.bcdSecUserPasswordSaltColumnName
2. Password column writing is allowed only if
a) the current user has the right given in PARAM_NAME_PERMISSION, which defaults to DEFAULT_PERMISSION, empty means everybody can write, or
b) the old password is also given in an wrs:M and it matches the one currently found in database
3. If BindingItem password_salt is available in the BindingSet, we want the password salted
On write we take the plain text pwd, hash it with salt and store both values. We may need to add the salt column before, if it is not present in the Wrq to the header and each row
4. If password BindingItem is not in the Wrq, or password is empty or equals NO_PW_GIVEN_VALUE, we remove the column
-
Nested Class Summary
Nested classes/interfaces inherited from class de.businesscode.bcdui.binding.write.WriteProcessingCallback
WriteProcessingCallback.ROW_TYPE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected List<BindingItem>
protected List<BindingItem>
protected List<BindingItem>
protected Connection
static final String
static final String
static final String
protected BindingItem
protected BindingItem
protected boolean
protected org.apache.shiro.subject.Subject
Fields inherited from class de.businesscode.bcdui.binding.write.WriteProcessingCallback
bindingSet
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
endDataRow
(WriteProcessingCallback.ROW_TYPE rowType, List<String> cValues, List<String> oValues) Salt the password and save the hashed pwd and salt into their columns We are only allowed to write the password, if we have admin rights or provide the old password and change ourselvesvoid
endHeader
(List<BindingItem> columns, List<Integer> columnTypes, Collection<String> keyColumnNames) Find out where our target columns are (pwd and salt), add salt if it is not present but password is and the BindingSet contains itprotected boolean
isAllowed
(WriteProcessingCallback.ROW_TYPE wrqRowType, List<String> cValues, List<String> oValues, int wrqPasswordColIdx) Check permissions.Methods inherited from class de.businesscode.bcdui.binding.write.WriteProcessingCallback
getParams, getValueBean, indexOf, initialize, setBindingSet, setParams, setValueBean
-
Field Details
-
PARAM_NAME_PERMISSION
- See Also:
-
DEFAULT_PERMISSION
- See Also:
-
NO_PW_GIVEN_VALUE
- See Also:
-
pwdInOrigWrq
protected boolean pwdInOrigWrq -
passwordBi
-
passwordSaltBi
-
columnsOfCaller
-
columnsFull
-
columnsWoPwd
-
columnTypesOfCaller
-
columnTypesFull
-
columnTypesWoPwd
-
con
-
bsHasSalt
protected boolean bsHasSalt -
subject
protected org.apache.shiro.subject.Subject subject
-
-
Constructor Details
-
SecUserTableWriteCallback
public SecUserTableWriteCallback()
-
-
Method Details
-
endHeader
public void endHeader(List<BindingItem> columns, List<Integer> columnTypes, Collection<String> keyColumnNames) throws Exception Find out where our target columns are (pwd and salt), add salt if it is not present but password is and the BindingSet contains it- Overrides:
endHeader
in classWriteProcessingCallback
- Throws:
Exception
-
endDataRow
public void endDataRow(WriteProcessingCallback.ROW_TYPE rowType, List<String> cValues, List<String> oValues) throws Exception Salt the password and save the hashed pwd and salt into their columns We are only allowed to write the password, if we have admin rights or provide the old password and change ourselves- Overrides:
endDataRow
in classWriteProcessingCallback
- Parameters:
rowType
- depending on the rowtype cValues and oValues change semantics, i.e: wrs:C in wrs:I vs wrs:C in wrs:McValues
- list of values of wrs:C columnsoValues
- list of values of wrs:O columns- Throws:
Exception
-
isAllowed
protected boolean isAllowed(WriteProcessingCallback.ROW_TYPE wrqRowType, List<String> cValues, List<String> oValues, int wrqPasswordColIdx) throws Exception Check permissions. Either we are user-admin or are the user itself and know the old password- Parameters:
cValues
-oValues
-- Returns:
- Throws:
Exception
-