001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.datadictionary.mask;
017
018import org.kuali.rice.krad.datadictionary.parse.BeanTag;
019import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
020
021/**
022 * The maskLiteral element is used to completely hide the field value for
023 * unauthorized users. The specified literal will be shown instead of the field
024 * value.
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028@BeanTag(name = "maskFormatterLiteral")
029public class MaskFormatterLiteral implements MaskFormatter {
030    private static final long serialVersionUID = 3368293409242411693L;
031
032    protected String literal = "********";
033
034    @Override
035    public String maskValue(Object value) {
036        return literal;
037    }
038
039    /**
040     * Gets the literalString attribute.
041     *
042     * @return Returns the literal String.
043     */
044    @BeanTagAttribute(name = "literal")
045    public String getLiteral() {
046        return literal;
047    }
048
049    /**
050     * Specify the string that will be shown instead of the actual value when masked.
051     */
052    public void setLiteral(String literal) {
053        this.literal = literal;
054    }
055
056    @Override
057    public String toString() {
058        StringBuilder builder = new StringBuilder();
059        builder.append("MaskFormatterLiteral [");
060        if (literal != null) {
061            builder.append("literal=").append(literal);
062        }
063        builder.append("]");
064        return builder.toString();
065    }
066
067}