public virtual Net.Vpc.Upa.Types.DataTypeTransform CreateSecretTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.Types.SecretTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.Types.SecretTransformConfig(); } object s = p.GetSecretStrategy(); if (s == null) { s = Net.Vpc.Upa.SecretStrategyType.DEFAULT; } if (s is Net.Vpc.Upa.SecretStrategyType) { switch (((Net.Vpc.Upa.SecretStrategyType)s)) { case Net.Vpc.Upa.SecretStrategyType.BASE64: { s = Net.Vpc.Upa.Impl.Transform.Base64SecretStrategy.INSTANCE; break; } case Net.Vpc.Upa.SecretStrategyType.DEFAULT: { s = new Net.Vpc.Upa.Impl.Transform.DefaultSecretStrategy(); break; } default: { throw new Net.Vpc.Upa.Exceptions.UPAException("Unsupported", s); } } } else if (s is string) { string ss = (string)s; if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty(ss)) { s = (Net.Vpc.Upa.SecretStrategy)pu.GetFactory().CreateObject <T>((string)s); } else { //use default s = new Net.Vpc.Upa.Impl.Transform.DefaultSecretStrategy(); } } else if (s is System.Type) { s = (Net.Vpc.Upa.SecretStrategy)pu.GetFactory().CreateObject <object>((System.Type)s); } else if (s is Net.Vpc.Upa.SecretStrategy) { s = (Net.Vpc.Upa.SecretStrategy)s; } else { throw new System.ArgumentException("Unsupported SecretStrategy " + s); } Net.Vpc.Upa.SecretStrategy st = (Net.Vpc.Upa.SecretStrategy)s; st.Init(pu, p.GetEncodeKey(), p.GetDecodeKey()); p.SetSecretStrategy(st); if (!(source is Net.Vpc.Upa.Types.ByteArrayType)) { Net.Vpc.Upa.Types.DataTypeTransform t = null; t = CreateByteArrayEncoderTransform(pu, source, null); Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform t2 = new Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform(st, t.GetTargetType(), p.GetSize()); return(t.Chain(t2)); } return(new Net.Vpc.Upa.Impl.Transform.SecretDataTypeTransform(st, source, p.GetSize())); }
public virtual Net.Vpc.Upa.Types.DataTypeTransform CreatePasswordTransform(Net.Vpc.Upa.PersistenceUnit pu, Net.Vpc.Upa.Types.DataType source, Net.Vpc.Upa.PasswordTransformConfig p) { if (p == null) { p = new Net.Vpc.Upa.PasswordTransformConfig(); } object s = p.GetCipherStrategy(); if (s == null) { s = Net.Vpc.Upa.PasswordStrategyType.DEFAULT; } if (s is Net.Vpc.Upa.PasswordStrategyType) { switch (((Net.Vpc.Upa.PasswordStrategyType)s)) { case Net.Vpc.Upa.PasswordStrategyType.SHA1: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.SHA1; break; } case Net.Vpc.Upa.PasswordStrategyType.SHA256: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.SHA256; break; } case Net.Vpc.Upa.PasswordStrategyType.MD5: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.MD5; break; } case Net.Vpc.Upa.PasswordStrategyType.DEFAULT: { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.MD5; break; } default: { throw new System.ArgumentException("Unsupported CipherStrategy " + s); } } } else if (s is string) { if (!Net.Vpc.Upa.Impl.Util.StringUtils.IsNullOrEmpty((string)s)) { s = (Net.Vpc.Upa.PasswordStrategy)pu.GetFactory().CreateObject <T>((string)s); } else { s = Net.Vpc.Upa.Impl.Transform.DefaultPasswordStrategy.MD5; } } else if (s is System.Type) { s = (Net.Vpc.Upa.PasswordStrategy)pu.GetFactory().CreateObject <object>((System.Type)s); } else if (s is Net.Vpc.Upa.PasswordStrategy) { s = (Net.Vpc.Upa.PasswordStrategy)s; } else { throw new System.ArgumentException("Unsupported CipherStrategy " + s); } p.SetCipherStrategy((Net.Vpc.Upa.PasswordStrategy)s); Net.Vpc.Upa.Types.DataTypeTransform t = null; object cipherValue = p.GetCipherValue(); if (!(source is Net.Vpc.Upa.Types.StringType)) { t = CreateStringEncoderTransform(pu, source, null); Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform t2 = new Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform((Net.Vpc.Upa.PasswordStrategy)p.GetCipherStrategy(), cipherValue, t.GetTargetType()); return(t.Chain(t2)); } return(new Net.Vpc.Upa.Impl.Transform.PasswordDataTypeTransform((Net.Vpc.Upa.PasswordStrategy)p.GetCipherStrategy(), cipherValue, source)); }