Clover coverage report - Acegi Security System for Spring - 1.0.0-RC1
Coverage timestamp: Mon Dec 5 2005 09:05:15 EST
file stats: LOC: 65   Methods: 1
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UserAttributeEditor.java 100% 100% 100% 100%
coverage
 1    /* Copyright 2004, 2005 Acegi Technology Pty Limited
 2    *
 3    * Licensed under the Apache License, Version 2.0 (the "License");
 4    * you may not use this file except in compliance with the License.
 5    * You may obtain a copy of the License at
 6    *
 7    * http://www.apache.org/licenses/LICENSE-2.0
 8    *
 9    * Unless required by applicable law or agreed to in writing, software
 10    * distributed under the License is distributed on an "AS IS" BASIS,
 11    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    * See the License for the specific language governing permissions and
 13    * limitations under the License.
 14    */
 15   
 16    package org.acegisecurity.userdetails.memory;
 17   
 18    import java.beans.PropertyEditorSupport;
 19   
 20    import org.acegisecurity.GrantedAuthorityImpl;
 21    import org.springframework.util.StringUtils;
 22   
 23   
 24    /**
 25    * Property editor that creates a {@link UserAttribute} from a comma separated
 26    * list of values.
 27    *
 28    * @author Ben Alex
 29    * @version $Id: UserAttributeEditor.java,v 1.6 2005/11/29 13:10:09 benalex Exp $
 30    */
 31    public class UserAttributeEditor extends PropertyEditorSupport {
 32    //~ Methods ================================================================
 33   
 34  160 public void setAsText(String s) throws IllegalArgumentException {
 35  160 if (StringUtils.hasText(s)) {
 36  157 String[] tokens = StringUtils.commaDelimitedListToStringArray(s);
 37  157 UserAttribute userAttrib = new UserAttribute();
 38   
 39  157 for (int i = 0; i < tokens.length; i++) {
 40  413 String currentToken = tokens[i].trim();
 41   
 42  413 if (i == 0) {
 43  157 userAttrib.setPassword(currentToken);
 44    } else {
 45  256 if (currentToken.toLowerCase().equals("enabled")) {
 46  14 userAttrib.setEnabled(true);
 47  242 } else if (currentToken.toLowerCase().equals("disabled")) {
 48  36 userAttrib.setEnabled(false);
 49    } else {
 50  206 userAttrib.addAuthority(new GrantedAuthorityImpl(
 51    currentToken));
 52    }
 53    }
 54    }
 55   
 56  157 if (userAttrib.isValid()) {
 57  154 setValue(userAttrib);
 58    } else {
 59  3 setValue(null);
 60    }
 61    } else {
 62  3 setValue(null);
 63    }
 64    }
 65    }