1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.objects.meta

File PasswordMetaClass.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
17
2
1
103
44
2
0.12
8.5
2
1

Classes

Class Line # Actions
PasswordMetaClass 40 17 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.objects.meta;
21   
22    import javax.inject.Named;
23    import javax.inject.Singleton;
24   
25    import org.xwiki.component.annotation.Component;
26   
27    import com.xpn.xwiki.objects.classes.PasswordClass;
28    import com.xpn.xwiki.objects.classes.PropertyClassInterface;
29    import com.xpn.xwiki.objects.classes.StaticListClass;
30    import com.xpn.xwiki.objects.classes.StringClass;
31   
32    /**
33    * Defines the meta properties of a boolean XClass property.
34    *
35    * @version $Id: 4a260dc8a27991ba2b7d76b865680c4c3447bd14 $
36    */
37    @Component
38    @Named("Password")
39    @Singleton
 
40    public class PasswordMetaClass extends StringMetaClass
41    {
42    /**
43    * The name of the meta property that specifies how the password is stored.
44    */
45    public static final String STORAGE_TYPE = "storageType";
46   
47    /**
48    * Indicates that the password should be stored in clean.
49    */
50    public static final String CLEAR = "Clear";
51   
52    /**
53    * Indicates that the password should be stored encrypted.
54    */
55    public static final String ENCRYPTED = "Encrypted";
56   
57    /**
58    * Indicates that the password hash should be store instead of the pass itself.
59    */
60    public static final String HASH = "Hash";
61   
62    /**
63    * The string used to separate the possible values of a static list. It is used for instance to separate the various
64    * storage types for {@link #ALGORITHM_KEY}.
65    */
66    public static final String SEPARATOR = "|";
67   
68    /**
69    * The name of the meta property that specifies which algorithm should be used for password storage.
70    */
71    public static final String ALGORITHM_KEY = "algorithm";
72   
73    /**
74    * Default constructor. Initializes the default meta properties of a Password XClass property.
75    */
 
76  60 toggle public PasswordMetaClass()
77    {
78  60 setPrettyName("Password");
79  60 setName(getClass().getAnnotation(Named.class).value());
80   
81  60 StaticListClass storageTypeClass = new StaticListClass(this);
82  60 storageTypeClass.setName(STORAGE_TYPE);
83  60 storageTypeClass.setPrettyName("Storage type");
84  60 storageTypeClass.setValues(HASH + SEPARATOR + CLEAR);
85  60 storageTypeClass.setRelationalStorage(false);
86  60 storageTypeClass.setDisplayType("select");
87  60 storageTypeClass.setMultiSelect(false);
88  60 storageTypeClass.setSize(1);
89  60 safeput(storageTypeClass.getName(), storageTypeClass);
90   
91  60 StringClass encryptAlgorithmClass = new StringClass(this);
92  60 encryptAlgorithmClass.setName(ALGORITHM_KEY);
93  60 encryptAlgorithmClass.setPrettyName("Encryption/hash algorithm");
94  60 encryptAlgorithmClass.setSize(20);
95  60 safeput(encryptAlgorithmClass.getName(), encryptAlgorithmClass);
96    }
97   
 
98  157 toggle @Override
99    public PropertyClassInterface getInstance()
100    {
101  157 return new PasswordClass();
102    }
103    }