You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ca...@apache.org on 2007/09/01 09:59:58 UTC
svn commit: r571740 - in /myfaces/tomahawk/trunk/sandbox:
core/src/main/java/org/apache/myfaces/custom/passwordStrength/
core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/
core/src/main/tld/ examples/src/main/webapp/
Author: cagatay
Date: Sat Sep 1 00:59:57 2007
New Revision: 571740
URL: http://svn.apache.org/viewvc?rev=571740&view=rev
Log:
Resolved TOMAHAWK-1101, Hazem's improvements on his component
Added:
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrengthAr.jsp
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js
myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrength.jsp
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java?rev=571740&r1=571739&r2=571740&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java Sat Sep 1 00:59:57 2007
@@ -36,7 +36,10 @@
private String _prefixText;
private String _showDetails;
private String _strengthIndicatorType;
-
+ private String _useCustomSecurity;
+ private String _customSecurityExpression;
+ private String _penaltyRatio;
+
public String getFamily() {
return "org.apache.myfaces.PasswordStrength";
}
@@ -85,7 +88,45 @@
ValueBinding vb = getValueBinding("textStrengthDescriptions");
return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb)
: null;
+ }
+
+
+ public String getCustomSecurityExpression() {
+ if (_customSecurityExpression != null)
+ return _customSecurityExpression;
+
+ ValueBinding vb = getValueBinding("customSecurityExpression");
+ return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb)
+ : null;
+ }
+
+
+ public String getUseCustomSecurity() {
+ if (_useCustomSecurity != null)
+ return _useCustomSecurity;
+
+ ValueBinding vb = getValueBinding("useCustomSecurity");
+ return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb)
+ : null;
+ }
+
+ public String getPenaltyRatio() {
+ if (_penaltyRatio != null)
+ return _penaltyRatio;
+
+ ValueBinding vb = getValueBinding("penaltyRatio");
+ return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb)
+ : null;
+ }
+
+
+ public void setCustomSecurityExpression(String securityExpression) {
+ _customSecurityExpression = securityExpression;
}
+
+ public void setUseCustomSecurity(String customSecurity) {
+ _useCustomSecurity = customSecurity;
+ }
public void setPreferredPasswordLength(String preferredPasswordLength) {
_preferredPasswordLength = preferredPasswordLength;
@@ -107,15 +148,22 @@
public void setStrengthIndicatorType(String strengthIndicatorType) {
_strengthIndicatorType = strengthIndicatorType;
}
+
+ public void setPenaltyRatio(String penaltyRatio) {
+ this._penaltyRatio = penaltyRatio;
+ }
public Object saveState(FacesContext context) {
- Object values[] = new Object[6];
+ Object values[] = new Object[9];
values[0] = super.saveState(context);
values[1] = _preferredPasswordLength;
values[2] = _prefixText;
values[3] = _textStrengthDescriptions;
values[4] = _showDetails;
- values[5] = _strengthIndicatorType;
+ values[5] = _strengthIndicatorType;
+ values[6] = _useCustomSecurity;
+ values[7] = _customSecurityExpression;
+ values[8] = _penaltyRatio;
return ((Object) (values));
}
@@ -127,5 +175,8 @@
_textStrengthDescriptions = (String) values[3];
_showDetails = (String) values[4];
_strengthIndicatorType = (String) values[5];
+ _useCustomSecurity = (String) values[6];
+ _customSecurityExpression = (String) values[7];
+ _penaltyRatio = (String) values[8];
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java?rev=571740&r1=571739&r2=571740&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java Sat Sep 1 00:59:57 2007
@@ -137,6 +137,18 @@
return "true";
}
+ private String getDefaultUseCustomSecurity() {
+ return "false";
+ }
+
+ private String getDefaultCustomSecurityRule() {
+ return "A1";
+ }
+
+ private String getDefaultPenaltyRatio() {
+ return "50";
+ }
+
private String getDefaultPrefix() {
return MessageUtils.getMessage(BUNDLE_BASE_NAME,
MessageUtils.getCurrentLocale(),
@@ -169,7 +181,23 @@
String textID = "'" + clientID + "'";
String showDetails = (passwordStrength.getShowDetails() == null) ? "'"
+ getDefaultShowDetails() + "'" : "'"
- + passwordStrength.getShowDetails() + "'";
+ + passwordStrength.getShowDetails().toLowerCase() + "'";
+
+ String useCustomSecurity = (passwordStrength.getUseCustomSecurity() == null) ? "'"
+ + getDefaultUseCustomSecurity() + "'"
+ : "'" + passwordStrength.getUseCustomSecurity().toLowerCase()
+ + "'";
+
+ String customSecurityExpression = (passwordStrength
+ .getCustomSecurityExpression() == null) ? "'"
+ + getDefaultCustomSecurityRule() + "'" : "'"
+ + passwordStrength.getCustomSecurityExpression() + "'";
+
+
+ String penaltyRatio = (passwordStrength
+ .getPenaltyRatio() == null) ? "'"
+ + getDefaultPenaltyRatio() + "'" : "'"
+ + passwordStrength.getPenaltyRatio() + "'";
writer.startElement(HTML.SPAN_ELEM, passwordStrength);
@@ -187,7 +215,8 @@
writer.writeAttribute("onkeyup", createOnKeyUpString(context,
passwordStrength, textID, preferredLength, prefixText,
- textStrengthDescriptions, true, showDetails), "onkeyup");
+ textStrengthDescriptions, true, showDetails, useCustomSecurity,
+ customSecurityExpression, penaltyRatio), "onkeyup");
writer.writeAttribute("onblur", getOnBlurString(context, passwordStrength), "onblur");
writer.endElement(HTML.INPUT_ELEM);
@@ -328,9 +357,12 @@
private String createOnKeyUpString(FacesContext context,
UIComponent component, String textID, String preferredLength,
String prefix, String textStrengthDescriptions,
- boolean showMessageIndicator, String showDetails) {
- PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
+ boolean showMessageIndicator, String showDetails,
+ String useCustomSecurity, String customSecurityExpression,
+ String penaltyRatio) {
+ PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
+
String clientID = component.getClientId(context);
String showMessageIndicatorString = "";
String strengthIndicatorType = getStrengthIndicatorType(passwordStrength);
@@ -342,13 +374,13 @@
showMessageIndicatorString = "show('"
+ getMessageID(context, passwordStrength) + "');";
}
-
- return updateStatusValue(textID, preferredLength,
- prefix, textStrengthDescriptions,
- indicatorMessageID, leftCharsMessageID,
- showMessageIndicatorString,
- strengthIndicatorType, progressBarId,
- showDetails, getLeftCharactersString());
+
+ return updateStatusValue(textID, preferredLength, prefix,
+ textStrengthDescriptions, indicatorMessageID,
+ leftCharsMessageID, showMessageIndicatorString,
+ strengthIndicatorType, progressBarId, showDetails,
+ getLeftCharactersString(), useCustomSecurity,
+ customSecurityExpression, penaltyRatio);
}
private String updateStatusValue(String textID, String preferredLength,
@@ -356,14 +388,18 @@
String indicatorMessageID, String leftCharsMessageID,
String showMessageIndicatorString,
String strengthIndicatorType, String progressBarId,
- String showDetails, String leftCharactersString) {
+ String showDetails, String leftCharactersString,
+ String useCustomSecurity, String customSecurityExpression,
+ String penaltyRatio) {
return "updateStatusValue("
+ textID + "," + preferredLength + ", "
+ prefix + ", " + textStrengthDescriptions + ", "
+ indicatorMessageID + ", " + leftCharsMessageID + ", "
+ strengthIndicatorType + ", " + progressBarId + ", "
- + showDetails + ", "
- + leftCharactersString + ");"
+ + showDetails + ", " + leftCharactersString + ", "
+ + useCustomSecurity + ", " + customSecurityExpression + ", "
+ + penaltyRatio
+ + ");"
+ showMessageIndicatorString;
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java?rev=571740&r1=571739&r2=571740&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java Sat Sep 1 00:59:57 2007
@@ -48,6 +48,9 @@
_textStrengthDescriptions = null;
_showDetails = null;
_strengthIndicatorType = null;
+ _useCustomSecurity = null;
+ _customSecurityExpression = null;
+ _penaltyRatio = null;
}
protected void setProperties(UIComponent component) {
@@ -58,7 +61,10 @@
_textStrengthDescriptions);
setStringProperty(component, "prefixText", _prefixText);
setStringProperty(component, "showDetails", _showDetails);
- setStringProperty(component, "strengthIndicatorType", _strengthIndicatorType);
+ setStringProperty(component, "strengthIndicatorType", _strengthIndicatorType);
+ setStringProperty(component, "useCustomSecurity", _useCustomSecurity);
+ setStringProperty(component, "customSecurityExpression", _customSecurityExpression);
+ setStringProperty(component, "penaltyRatio", _penaltyRatio);
}
//Getters & Setters ...
@@ -103,10 +109,38 @@
this._strengthIndicatorType = strengthIndicatorType;
}
+ public String getCustomSecurityExpression() {
+ return _customSecurityExpression;
+ }
+
+ public void setCustomSecurityExpression(String securityExpression) {
+ _customSecurityExpression = securityExpression;
+ }
+
+ public String getUseCustomSecurity() {
+ return _useCustomSecurity;
+ }
+
+ public void setUseCustomSecurity(String customSecurity) {
+ _useCustomSecurity = customSecurity;
+ }
+
+
+ public String getPenaltyRatio() {
+ return _penaltyRatio;
+ }
+
+ public void setPenaltyRatio(String penaltyRatio) {
+ this._penaltyRatio = penaltyRatio;
+ }
+
//Attributes ...
private String _preferredPasswordLength;
private String _textStrengthDescriptions;
private String _prefixText;
private String _showDetails;
private String _strengthIndicatorType;
+ private String _useCustomSecurity;
+ private String _customSecurityExpression;
+ private String _penaltyRatio;
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js?rev=571740&r1=571739&r2=571740&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js Sat Sep 1 00:59:57 2007
@@ -15,48 +15,304 @@
hide(objID);
}
-function increaseProgressBar(progressBarID, maxValue, currentValue){
- dojo.widget.byId(progressBarID).setMaxProgressValue(maxValue, true);
+function increaseProgressBar(progressBarID, degree){
+ var currentValue = degree * 10;
+ dojo.widget.byId(progressBarID).setMaxProgressValue(10, true);
dojo.widget.byId(progressBarID).setProgressValue(currentValue, true);
dojo.widget.byId(progressBarID).render();
}
+function getPasswordStrengthText(degree, tokens) {
+ var index = Math.round( degree * tokens.length ) - 1;
+ if(index <= 0) return tokens[0];
+ return tokens[ index ];
+}
+
+function isAlpha(sText) {
+ for ( c=0; c < sText.length; c ++ ) {
+ alpha = ( sText.charCodeAt ( c ) >= 65 &&
+ sText.charCodeAt ( c ) <=90 ) ||
+ ( sText.charCodeAt ( c ) >= 97 &&
+ sText.charCodeAt ( c ) <=122 )
+ if ( !alpha ) {
+ return false;
+ }
+ }
+ return true;
+}
+
+function isNumeric(sText) {
+ var ValidChars = "0123456789";
+ var IsNumber=true;
+ var Char;
+
+ for (i = 0; i < sText.length && IsNumber == true; i++) {
+ Char = sText.charAt(i);
+ if (ValidChars.indexOf(Char) == -1) {
+ IsNumber = false;
+ }
+ }
+ return IsNumber;
+}
+
+
+function isSymbol(sText) {
+ var iChars = "!@#$%^&*()+=-[]\';,./{}|\":<>? ";
+ for (var i = 0; i < sText.length; i++) {
+ if (iChars.indexOf(sText.charAt(i)) != -1) {
+ return true;
+ }
+ }
+ return false;
+}
+
+function trimString(s) {
+ var l=0; var r=s.length -1;
+ while(l < s.length && s[l] == ' ')
+ { l++; }
+ while(r > l && s[r] == ' ')
+ { r-=1; }
+ return s.substring(l, r+1);
+}
+
+/**
+* This method checks whether the character is a valid password Strength
+* character pattern ...
+*/
+function isValidCharacterPattern(character) {
+ if(character != 'S' && character != 's' &&
+ character != 'A' && character != 'a' &&
+ character != 'N' && character != 'n' ) {
+ return false;
+ }
+ return true;
+}
+
+function isSymbolCharacterPattern(character) {
+ if(character == 'S' || character == 's')
+ return true;
+ return false;
+}
+
+
+function isNumberCharacterPattern(character) {
+ if(character == 'N' || character == 'n')
+ return true;
+ return false;
+}
+
+
+function isAlphaCharacterPattern(character) {
+ if(character == 'A' || character == 'a')
+ return true;
+ return false;
+}
+
+/**
+* This function checks whether the index is a valid index of
+* the password string ...
+*/
+function isValidRange(passwordString, index) {
+ if(index >= passwordString.length) {
+ return false;
+ }
+ return true;
+}
+
+
+/**
+* This function check whether the password string has a valid
+* sequence of symbols ...
+* count :- is the number of expected symbols.
+* passwordString :- the src password string.
+* currentCharacterIndex :- the current character index of the password string.
+* Return the current password string character index if succeeded else
+* return -1.
+*/
+function validSymbolSequence(count, passwordString, currentCharacterIndex) {
+ //Consume symbol characters ...
+ for(j = 0; j < count; ++j) {
+ if(!isValidRange(passwordString, currentCharacterIndex)) {return -1;}
+ if(!isSymbol( passwordString[currentCharacterIndex++] ))
+ return -1;
+ }
+ //Check whether there are more character of this type ...
+ while(currentCharacterIndex < passwordString.length) {
+ if(isSymbol( passwordString[currentCharacterIndex] ) ) {
+ currentCharacterIndex++;
+ } else {
+ break;
+ }
+ }
+ return currentCharacterIndex;
+}
+
+
+/**
+* This function check whether the password string has a valid
+* sequence of numbers ...
+* count :- is the number of expected numbers.
+* passwordString :- the src password string.
+* currentCharacterIndex :- the current character index of the password string.
+* Return the current password string character index if succeeded else
+* return -1.
+*/
+function validNumberSequence(count, passwordString, currentCharacterIndex) {
+ for(j = 0; j < count; ++j) {
+ if(!isValidRange(passwordString, currentCharacterIndex)) {return -1;}
+ if(!isNumeric( passwordString[currentCharacterIndex++] ))
+ return -1;
+ }
+ //Check whether there are more character of this type ...
+ while(currentCharacterIndex < passwordString.length) {
+ if(isNumeric( passwordString[currentCharacterIndex] ) ) {
+ currentCharacterIndex++;
+ } else {
+ break;
+ }
+ }
+ return currentCharacterIndex;
+}
+
+
+/**
+* This function check whether the password string has a valid
+* sequence of alphabets ...
+* count :- is the number of expected alphabets.
+* passwordString :- the src password string.
+* currentCharacterIndex :- the current character index of the password string.
+* Return the current password string character index if succeeded else
+* return -1.
+*/
+function validAlphaSequence(count, passwordString, currentCharacterIndex) {
+ for(j = 0; j < count; ++j) {
+ if(!isValidRange(passwordString, currentCharacterIndex)) {return -1;}
+ if(!isAlpha( passwordString[currentCharacterIndex++] ))
+ return -1;
+ }
+ //Check whether there are more character of this type ...
+ while(currentCharacterIndex < passwordString.length) {
+ if(isAlpha( passwordString[currentCharacterIndex] ) ) {
+ currentCharacterIndex++;
+ } else {
+ break;
+ }
+ }
+ return currentCharacterIndex;
+}
+
+
+/**
+* This method check whether the password string complies
+* with the pattern specified ...
+* Note that the pattern has the following format :
+* S <<Number>> N <<Number>> A<<Number>>
+* Where S stands for Symbols
+* Where N stands for Numbers
+* Where A stands for Alphabets
+****************************************************
+* For example) A4N2S3A2
+* Means that the password will be as following :
+* 4 or more Alphabets followed by
+* 2 or more Numbers followed by
+* 3 or more Symbols followed by
+* 2 or more Alphabets
+****************************************************
+*/
+function checkPattern(passwordString, patternString) {
+
+ var INVALID_PATTERN = "Invalid pattern";
+ var INVALID_PATTERN_LENGTH = "Invalid pattern length";
+ var currentCharacterIndex = 0;
+ var patternLength = patternString.length;
+
+ if(trimString( patternString ).length % 2 != 0) {
+ alert(INVALID_PATTERN_LENGTH);
+ return false;
+ }
+
+ for(var i = 0; i < patternLength; i += 2) {
+ var character = patternString[i];
+ var count = patternString[i+1];
+ var retval;
+
+ //Check pattern format ...
+ if(!isNumeric(count)) {
+ alert(INVALID_PATTERN);
+ return false;
+ }
+ if(!isValidCharacterPattern(character)) {
+ alert(INVALID_PATTERN);
+ return false;
+ }
+
+ //Validate the pattern ...
+ if(isSymbolCharacterPattern( character )) {
+ retval = validSymbolSequence(count, passwordString, currentCharacterIndex);
+ if(retval == -1) {
+ return false;
+ }
+ }
+ else if(isNumberCharacterPattern( character )) {
+ retval = validNumberSequence(count, passwordString, currentCharacterIndex);
+ if(retval == -1) {
+ return false;
+ }
+ }
+ else if(isAlphaCharacterPattern( character )) {
+ retval = validAlphaSequence(count, passwordString, currentCharacterIndex);
+ if(retval == -1) {
+ return false;
+ }
+ }
+
+ currentCharacterIndex = retval;
+ }
+
+ //The pattern is valid ...
+ return true;
+}
+
+function calculatePasswordStrengthDegree(passwordString, patternString,
+ preferredLength, useCustomSecurity,
+ penaltyRatio){
+ currentLength = passwordString.length;
+ var strength = (currentLength / preferredLength);
+ if(strength > 1) strength=1;
+ if(useCustomSecurity == "true") {
+ //If the pattern is not satisified decrease the power by the penalty ...
+ if(!checkPattern(passwordString, patternString)){
+ return strength * (penaltyRatio/100);
+ }
+ }
+ return strength;
+}
+
+
//This method is used for online updating the status of the textbox ...
function updateStatusValue(textID, preferredLength,
prefixText, passwordDesc,
indicatorMessageID, leftCharsMessageID,
strengthIndicatorType, progressBarId,
- showDetails, leftCharactersString) {
+ showDetails, leftCharactersString,
+ useCustomSecurity, patternString,
+ penaltyRatio) {
//Get the current message content ...
var content = document.getElementById(textID).value;
- var currentStatus = prefixText;
- var diff = 0;
+ var currentStatus = prefixText;
+ var degree = calculatePasswordStrengthDegree(content, patternString,
+ preferredLength, useCustomSecurity,
+ penaltyRatio);
/**
* Check whether to display the strength indicator as a text or as bar ...
*/
if(strengthIndicatorType == "text") {
- //Check the contents ...
+
var tokens = passwordDesc.split(";");
- var length = tokens.length;
- //Here we will calc the password strength ratio based on length + custom rule work ...
- //Calc the delta of char changes : diff = preferredLength / tokens;
- var delta = preferredLength / length;
- var change = delta;
- //Segmentize it ...
- for(i = 0; i < length; ++i) {
- //Get the correct tokenizer ...
- if(content.length <= delta) {
- currentStatus += tokens[i];
- break;
- }
- //If we reached the last character then always display the last value ...
- if(i == length - 1) {
- currentStatus += tokens[length-1];
- break;
- }
- delta = change * (i + 2);
- }
+
+ currentStatus += getPasswordStrengthText(degree, tokens);
+
if(document.all){
document.getElementById(indicatorMessageID).innerText = currentStatus;
} else {
@@ -65,8 +321,11 @@
}
else { /*Here we are dealing with bar*/
- increaseProgressBar(progressBarId, preferredLength, content.length);
+
+ increaseProgressBar(progressBarId, degree);
}
+
+
/**
* Here display the left characters message part ...
*/
@@ -85,5 +344,6 @@
hide(leftCharsMessageID);
}
}
+
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld?rev=571740&r1=571739&r2=571740&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/tld/myfaces_sandbox.tld Sat Sep 1 00:59:57 2007
@@ -1729,6 +1729,59 @@
<rtexprvalue>true</rtexprvalue>
<type>java.lang.String</type>
<description>This flag determines the indicator type. It can be {text or bar}. Default is text</description>
- </attribute>
+ </attribute>
+
+
+ <attribute>
+ <name>useCustomSecurity</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>
+ This flag determines whether to user custom security rules instead
+ of just depending on the password length. The default is false.
+ </description>
+ </attribute>
+
+ <attribute>
+ <name>customSecurityExpression</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>
+ This string determines the expression of the custom security rule of the password
+ Note that the expression has the following format :
+ *******************************************************
+ S (Number) N (Number) A (Number)
+ Where S stands for Symbols
+ Where N stands for Numbers
+ Where A stands for Alphabets
+ *******************************************************
+ For example) A4N2S3A2
+ Means that the password will be as following :
+ 4 or more Alphabets followed by
+ 2 or more Numbers followed by
+ 3 or more Symbols followed by
+ 2 or more Alphabets
+ *******************************************************
+ Note also that the useCustomSecurity should be set to true.
+ </description>
+ </attribute>
+
+
+ <attribute>
+ <name>penaltyRatio</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>
+ This attribute determines the penalty ratio that will decrease the password
+ Strength if the custom security expression is not met.
+ Note also that the useCustomSecurity should be set to true to apply this flag.
+ Possible values from 0 to 100.
+ Default value is 50.
+ </description>
+ </attribute>
+
</tag>
</taglib>
Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrength.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrength.jsp?rev=571740&r1=571739&r2=571740&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrength.jsp (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrength.jsp Sat Sep 1 00:59:57 2007
@@ -38,7 +38,11 @@
<tr><td>
<h:outputText
value="Enter your password" />
- </td></tr>
+ </td>
+ <td>
+ [Preferred password length is 10 Without custom rules]
+ </td>
+ </tr>
<tr><td>
<h:outputText value="Text Mode" />
@@ -57,6 +61,49 @@
</td></tr>
</table>
+
+ <br/><br/><br/>
+
+
+ <table>
+
+ <tr><td>
+ <h:outputText
+ value="Enter your password" />
+ </td>
+ <td>
+ [Preferred password length is 10 With custom rules (A3S2N3A2)] <br/>
+ Note that (A3S2N3A2) means the password should be : <br/>
+ 3 or more Alphabets followed by <br/>
+ 2 or more Symbols followed by <br/>
+ 3 or more Numbers followed by <br/>
+ 2 or more Alphabets followed by <br/>
+ </td>
+ </tr>
+
+ <tr><td>
+ <h:outputText value="Text Mode" />
+ </td><td>
+ <s:passwordStrength id="txtCustomPwdText" preferredPasswordLength="10"
+ value="#{passwordStrengthBean.password}" prefixText="Strength : "
+ textStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
+ strengthIndicatorType="text" useCustomSecurity="true"
+ customSecurityExpression="A3S2N3A2" penaltyRatio="50"/>
+ </td></tr>
+
+ <tr><td>
+ <h:outputText value="ProgressBar Mode" />
+ </td><td>
+ <s:passwordStrength id="txtCustomPrgBarText" preferredPasswordLength="10"
+ value="#{passwordStrengthBean.password}" prefixText="Strength : "
+ textStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
+ strengthIndicatorType="bar" useCustomSecurity="true"
+ customSecurityExpression="A3S2N3A2" penaltyRatio="50"/>
+ </td></tr>
+
+ </table>
+
+
</h:form>
<%@include file="inc/page_footer.jsp"%>
@@ -66,5 +113,6 @@
</body>
</html>
+
Added: myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrengthAr.jsp
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrengthAr.jsp?rev=571740&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrengthAr.jsp (added)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/webapp/passwordStrengthAr.jsp Sat Sep 1 00:59:57 2007
@@ -0,0 +1,68 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s"%>
+<html>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+//-->
+
+<%@include file="inc/head.inc"%>
+
+<body>
+
+<f:view locale="ar">
+
+ <h:form>
+
+ <table>
+
+ <tr><td>
+ <h:outputText
+ value="Enter your password" />
+ </td></tr>
+
+ <tr><td>
+ <h:outputText value="Text Mode" />
+ </td><td>
+ <s:passwordStrength id="txtPwdText" preferredPasswordLength="10"
+ value="#{passwordStrengthBean.password}" strengthIndicatorType="text"/>
+ </td></tr>
+
+ <tr><td>
+ <h:outputText value="ProgressBar Mode" />
+ </td><td>
+ <s:passwordStrength id="txtPrgBarText" preferredPasswordLength="10"
+ value="#{passwordStrengthBean.password}" strengthIndicatorType="bar"/>
+ </td></tr>
+
+ </table>
+ </h:form>
+
+ <%@include file="inc/page_footer.jsp"%>
+
+</f:view>
+
+</body>
+
+</html>
+
+