Browse Source

SEC-2690: Polish method modifiers

- Make methods final where possible
- Make methods private where possible
pull/117/head
Rob Winch 12 years ago
parent
commit
aac4ede3a4
  1. 4
      ldap/src/main/java/org/springframework/security/ldap/SpringSecurityLdapTemplate.java
  2. 44
      ldap/src/main/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulator.java
  3. 6
      ldap/src/main/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulator.java

4
ldap/src/main/java/org/springframework/security/ldap/SpringSecurityLdapTemplate.java

@ -233,7 +233,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate { @@ -233,7 +233,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
* @param adapter - the Context to extract the DN from
* @return - the String representing the full DN
*/
protected String getAdapterDN(DirContextAdapter adapter) {
private String getAdapterDN(DirContextAdapter adapter) {
//returns the full DN rather than the sub DN if a base is specified
return adapter.getNameInNamespace();
}
@ -246,7 +246,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate { @@ -246,7 +246,7 @@ public class SpringSecurityLdapTemplate extends LdapTemplate {
* @param record - the map holding the attribute names and values
* @param attributeName - the name for which to fetch the values from
*/
protected void extractStringAttributeValues(DirContextAdapter adapter, Map<String, List<String>> record, String attributeName) {
private void extractStringAttributeValues(DirContextAdapter adapter, Map<String, List<String>> record, String attributeName) {
Object[] values = adapter.getObjectAttributes(attributeName);
if (values == null || values.length == 0) {
logger.debug("No attribute value found for '" + attributeName + "'");

44
ldap/src/main/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulator.java

@ -320,32 +320,13 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator @@ -320,32 +320,13 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
return ldapTemplate;
}
/**
* Returns the default role
* Method available so that classes extending this can override
* @return the default role used
* @see {@link #setDefaultRole(String)}
*/
protected GrantedAuthority getDefaultRole() {
return defaultRole;
}
/**
* Returns the search controls
* Method available so that classes extending this can override the search controls used
* @return the search controls
*/
protected SearchControls getSearchControls() {
return searchControls;
}
/**
* Returns the attribute name of the LDAP attribute that will be mapped to the role name
* Method available so that classes extending this can override
* @return the attribute name used for role mapping
* @see {@link #setGroupRoleAttribute(String)}
*/
protected String getGroupRoleAttribute() {
protected final String getGroupRoleAttribute() {
return groupRoleAttribute;
}
@ -355,7 +336,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator @@ -355,7 +336,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
* @return the search filter
* @see {@link #setGroupSearchFilter(String)}
*/
protected String getGroupSearchFilter() {
protected final String getGroupSearchFilter() {
return groupSearchFilter;
}
@ -365,7 +346,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator @@ -365,7 +346,7 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
* @return the role prefix
* @see {@link #setRolePrefix(String)}
*/
protected String getRolePrefix() {
protected final String getRolePrefix() {
return rolePrefix;
}
@ -375,9 +356,26 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator @@ -375,9 +356,26 @@ public class DefaultLdapAuthoritiesPopulator implements LdapAuthoritiesPopulator
* @return true if role names are converted to uppercase.
* @see {@link #setConvertToUpperCase(boolean)}
*/
protected boolean isConvertToUpperCase() {
protected final boolean isConvertToUpperCase() {
return convertToUpperCase;
}
/**
* Returns the default role
* Method available so that classes extending this can override
* @return the default role used
* @see {@link #setDefaultRole(String)}
*/
private GrantedAuthority getDefaultRole() {
return defaultRole;
}
/**
* Returns the search controls
* Method available so that classes extending this can override the search controls used
* @return the search controls
*/
private SearchControls getSearchControls() {
return searchControls;
}
}

6
ldap/src/main/java/org/springframework/security/ldap/userdetails/NestedLdapAuthoritiesPopulator.java

@ -159,7 +159,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula @@ -159,7 +159,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
* @param authorities - the authorities set that will be populated, must not be null
* @param depth - the depth remaining, when 0 recursion will end
*/
protected void performNestedSearch(String userDn, String username, Set<GrantedAuthority> authorities, int depth) {
private void performNestedSearch(String userDn, String username, Set<GrantedAuthority> authorities, int depth) {
if (depth == 0) {
//back out of recursion
if (logger.isDebugEnabled()) {
@ -223,7 +223,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula @@ -223,7 +223,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
*
* @return the attribute names or null for all
*/
public Set<String> getAttributeNames() {
private Set<String> getAttributeNames() {
return attributeNames;
}
@ -241,7 +241,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula @@ -241,7 +241,7 @@ public class NestedLdapAuthoritiesPopulator extends DefaultLdapAuthoritiesPopula
*
* @return the max search depth, default is 10
*/
public int getMaxSearchDepth() {
private int getMaxSearchDepth() {
return maxSearchDepth;
}

Loading…
Cancel
Save