1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 module hunt.shiro.crypto.hash.format.ProvidedHashFormat; 20 21 //import java.util.Locale; 22 23 import hunt.Exceptions; 24 25 /** 26 * An enum representing Shiro's default provided {@link HashFormat} implementations. 27 * 28 */ 29 public enum ProvidedHashFormat { 30 31 /** 32 * Value representing the {@link HexFormat} implementation. 33 */ 34 HEX, 35 36 /** 37 * Value representing the {@link Base64Format} implementation. 38 */ 39 BASE64, 40 41 /** 42 * Value representing the {@link Shiro1CryptFormat} implementation. 43 */ 44 SHIRO1 45 46 } 47 48 class ProvidedHashFormatHelper { 49 /** 50 * Value representing the {@link HexFormat} implementation. 51 */ 52 // HEX(HexFormat.class), 53 54 TypeInfo getProvided(ProvidedHashFormat format) 55 { 56 // switch(format) 57 // { 58 // case ProvidedHashFormat.HEX: 59 // return typeid(HexFormat); 60 // case ProvidedHashFormat.BASE64: 61 // return typeid(Base64Format); 62 // case ProvidedHashFormat.SHIRO1: 63 // return typeid(Shiro1CryptFormat); 64 // default: 65 // throw new Exception("format error"); 66 // } 67 implementationMissing(false); 68 return null; 69 } 70 // /** 71 // * Value representing the {@link Base64Format} implementation. 72 // */ 73 // BASE64(Base64Format.class), 74 75 // /** 76 // * Value representing the {@link Shiro1CryptFormat} implementation. 77 // */ 78 // SHIRO1(Shiro1CryptFormat.class); 79 80 // private final Class<? extends HashFormat> clazz; 81 82 // private ProvidedHashFormat(Class<? extends HashFormat> clazz) { 83 // this.clazz = clazz; 84 // } 85 86 // Class<? extends HashFormat> getHashFormatClass() { 87 // return this.clazz; 88 // } 89 90 // static ProvidedHashFormat byId(string id) { 91 // if (id is null) { 92 // return null; 93 // } 94 // try { 95 // // Use English Locale, some Locales handle uppercase/lower differently. i.e. Turkish and upper case 'i' 96 // // is not 'I'. And 'SHIRO1' would be 'SHİRO1' 97 // return valueOf(id.toUpperCase(Locale.ENGLISH)); 98 // } catch (IllegalArgumentException ignored) { 99 // return null; 100 // } 101 // } 102 103 }