View Javadoc

1   /* Copyright 2004 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.providers.encoding;
17  
18  /***
19   * <p>
20   * Convenience base for digest password encoders.
21   * </p>
22   *
23   * @author colin sampaleanu
24   * @version $Id: BaseDigestPasswordEncoder.java,v 1.5 2005/11/17 00:55:49 benalex Exp $
25   */
26  public abstract class BaseDigestPasswordEncoder extends BasePasswordEncoder {
27      //~ Instance fields ========================================================
28  
29      private boolean encodeHashAsBase64 = false;
30  
31      //~ Methods ================================================================
32  
33      /***
34       * The encoded password is normally returned as Hex (32 char) version of
35       * the hash bytes. Setting this property to true will cause the encoded
36       * pass to be returned as Base64 text, which will consume 24 characters.
37       *
38       * @param encodeHashAsBase64 set to true for Base64 output
39       */
40      public void setEncodeHashAsBase64(boolean encodeHashAsBase64) {
41          this.encodeHashAsBase64 = encodeHashAsBase64;
42      }
43  
44      public boolean getEncodeHashAsBase64() {
45          return encodeHashAsBase64;
46      }
47  }