IDEMPIERE-3408 Encrypted Field can explore by normal user
This commit is contained in:
parent
4157a647d0
commit
0154540290
|
@ -89,8 +89,8 @@ public class Obscure extends Object
|
|||
public static final String OBSCURETYPE_ObscureAlphaNumericButFirstLast4 = "A44";
|
||||
/** Obscure AlphaNumeric but last 4 = A04 */
|
||||
public static final String OBSCURETYPE_ObscureAlphaNumericButLast4 = "A04";
|
||||
/** Obscure by asterisk character, use for EncryptedField */
|
||||
public static final String OBSCURETYPE_ObscureAllAsterisk = "AA";
|
||||
/** Obscure by max 10 asterisk characters, use for EncryptedField - internal, not in the list of obscure type field */
|
||||
public static final String OBSCURETYPE_ObscureMaskMax10Asterisk = "AA";
|
||||
|
||||
/** Obscure Type */
|
||||
private String m_type = OBSCURETYPE_ObscureDigitsButLast4;
|
||||
|
@ -105,14 +105,18 @@ public class Obscure extends Object
|
|||
*/
|
||||
public void setType (String obscureType)
|
||||
{
|
||||
if (obscureType == null || obscureType.equals("904") || obscureType.equals("944") || obscureType.equals("A44") || obscureType.equals("A04") ||
|
||||
OBSCURETYPE_ObscureAllAsterisk.equals(obscureType))
|
||||
if ( obscureType == null
|
||||
|| OBSCURETYPE_ObscureDigitsButLast4.equals(obscureType)
|
||||
|| OBSCURETYPE_ObscureDigitsButFirstLast4.equals(obscureType)
|
||||
|| OBSCURETYPE_ObscureAlphaNumericButFirstLast4.equals(obscureType)
|
||||
|| OBSCURETYPE_ObscureAlphaNumericButLast4.equals(obscureType)
|
||||
|| OBSCURETYPE_ObscureMaskMax10Asterisk.equals(obscureType))
|
||||
{
|
||||
m_type = obscureType;
|
||||
m_obscuredValue = null;
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException ("ObscureType Invalid value - Reference_ID=291 - 904 - 944 - A44 - A04");
|
||||
throw new IllegalArgumentException ("ObscureType Invalid value - Reference_ID=291 - 904 - 944 - A44 - A04 - AA");
|
||||
} // setType
|
||||
|
||||
/**
|
||||
|
@ -143,6 +147,17 @@ public class Obscure extends Object
|
|||
m_obscuredValue = null;
|
||||
} // setClearValue
|
||||
|
||||
/**
|
||||
* Get Obscured Value
|
||||
* @param clearValue The clearValue to set.
|
||||
* @param maxlength maximum length of the obscured value
|
||||
* @return Returns the obscuredValue.
|
||||
*/
|
||||
public String getObscuredValue(String clearValue, int maxlength) {
|
||||
setClearValue(clearValue);
|
||||
return getObscuredValue(maxlength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Obscured Value
|
||||
* @param clearValue The clearValue to set.
|
||||
|
@ -154,6 +169,19 @@ public class Obscure extends Object
|
|||
return getObscuredValue();
|
||||
} // getObscuredValue
|
||||
|
||||
/**
|
||||
* Get Obscured Value with a max length
|
||||
* @param maxlength maximum length of the obscured value
|
||||
* @return Returns the obscuredValue.
|
||||
*/
|
||||
public String getObscuredValue(int maxlength) {
|
||||
String obs = getObscuredValue();
|
||||
if (maxlength > 0 && obs.length() > maxlength) {
|
||||
obs = obs.substring(0, maxlength);
|
||||
}
|
||||
return obs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Obscured Value
|
||||
* @return Returns the obscuredValue.
|
||||
|
@ -165,8 +193,8 @@ public class Obscure extends Object
|
|||
if (m_clearValue == null || m_clearValue.length() == 0)
|
||||
return m_clearValue;
|
||||
|
||||
if (OBSCURETYPE_ObscureAllAsterisk.equals(m_type)){
|
||||
return "*";
|
||||
if (OBSCURETYPE_ObscureMaskMax10Asterisk.equals(m_type)){
|
||||
return "**********";
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -206,5 +234,4 @@ public class Obscure extends Object
|
|||
System.out.println (Obscure.obscure("1a2b3c4d5e6f7g8h9"));
|
||||
} // main
|
||||
|
||||
|
||||
} // Obscrure
|
||||
} // Obscure
|
||||
|
|
|
@ -86,7 +86,7 @@ public class Textbox extends org.zkoss.zul.Textbox implements EventListener<Even
|
|||
String value = super.getValue();
|
||||
if (m_obscure != null && value != null && value.length() > 0)
|
||||
{
|
||||
if (!isReadonly() && value.equals(m_obscure.getObscuredValue()))
|
||||
if (!isReadonly() && value.equals(m_obscure.getObscuredValue(getMaxlength())))
|
||||
value = m_obscure.getClearValue();
|
||||
}
|
||||
return value;
|
||||
|
@ -96,7 +96,7 @@ public class Textbox extends org.zkoss.zul.Textbox implements EventListener<Even
|
|||
public void setValue(String value) throws WrongValueException {
|
||||
if (m_obscure != null && ("password".equals(getType()) || !m_infocus))
|
||||
{
|
||||
super.setValue(m_obscure.getObscuredValue(value));
|
||||
super.setValue(m_obscure.getObscuredValue(value, getMaxlength()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ public class Textbox extends org.zkoss.zul.Textbox implements EventListener<Even
|
|||
@Override
|
||||
public void setType(String type) throws WrongValueException {
|
||||
if ("password".equals(type))
|
||||
setObscureType(Obscure.OBSCURETYPE_ObscureAllAsterisk);
|
||||
setObscureType(Obscure.OBSCURETYPE_ObscureMaskMax10Asterisk);
|
||||
super.setType(type);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue