我正在编写一个需要连接到SMTP服务器才能发送邮件的Perl脚本,但我真的不喜欢这样的东西:
my $pass = '123456';
Run Code Online (Sandbox Code Playgroud)
我找到了Data :: Encrypted,它应该允许用户第一次提示它然后加密存储它.
use Data::Encrypted file => ".passwd", qw(encrypted);
my $password = encrypted('password');
Run Code Online (Sandbox Code Playgroud)
但我无法使它工作,它会导致运行时错误:
/Library/Perl/5.12/Data/Encrypted.pm第78行的密钥文件格式错误
有人有同样的问题,或者知道隐藏/保护密码的其他方法吗?
嗨,我需要在Spring安全登录表单中添加一个新的异常,除了我想要自己的错误消息之外,一切都很完美(直到现在它显示"错误的登录/密码").
我从用户名密码验证过滤器覆盖默认尝试验证方法:
@Override
public Authentication attemptAuthentication(final HttpServletRequest request, final HttpServletResponse response)
{
if (!myTest()) {
throw new CustomAuthenticationException("custom message");
}
}
Run Code Online (Sandbox Code Playgroud)
我的例外:
public class CustomAuthenticationException extends AuthenticationException {
public CustomAuthenticationException(final String message)
{
super(message);
}
public CustomAuthenticationException(final String message, final Throwable cause)
{
super(message, cause);
}
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我在SPRING_SECURITY_LAST_EXCEPTION下看到了我的异常,但错误消息始终是来自坏凭证的消息,我怎么能改变它?
谢谢
我使用嵌套接口来存储String常量:
public interface Constants{
interface level1 {
interface level2 {
String CONSTANT = "constant";
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想将这些常量注入spring值字段,我试过:
<entry key="key" value="#{com.company.Constants.level1.level2.CONSTANT}"/>
<entry key="key" value="#{T(com.company.Constants.level1.level2).CONSTANT}"/>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,正确的方法是什么?
我知道他们已经有很多关于那个帖子,但我尝试了很多解决方案,我无法显示我的表格!
我想做一些非常简单的事情(我是一个Django初学者),我创建一个特定的UserProfile来扩展基本的,我想让用户编辑它:
这是我的模型:
class UserProfile(models.Model):
user = models.OneToOneField(User)
cc = models.CharField(max_length=400, blank=True)
lang = models.CharField(max_length=5, blank=True, )
def __unicode__(self):
return unicode(self.user.email)
class UserProfileForm(forms.ModelForm):
class meta:
model = UserProfile
def __init__(self,*args,**kwargs):
super(UserProfileForm, self).__init__(*args, **kwargs)
self.user = kwargs['instance']
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
Run Code Online (Sandbox Code Playgroud)
这是我的查看方法:
@login_required
def accountform(request):
data = {}
data.update(csrf(request))
user_profile = request.user.get_profile()
data['form'] = UserProfileForm(instance=user_profile)
print user_profile
return render(request, 'accountform.html', data)
Run Code Online (Sandbox Code Playgroud)
这是我的模板:
<form action="/contact/" method="post">
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
当我显示从我只看到提交按钮...
我有这样的字符串:
String strDateTimeStamp = "2016-02-29 18:31:51";
Run Code Online (Sandbox Code Playgroud)
现在我想提取它以获得以下格式的结果:
String strYear = "2016";
String strMonth = "02";
String strDate = "29";
String strHour = "18";
String strMinute = "31";
String strSecond = "51";
Run Code Online (Sandbox Code Playgroud) java ×3
spring ×2
date ×1
django ×1
django-forms ×1
django-users ×1
encryption ×1
extract ×1
java-ee ×1
passwords ×1
perl ×1
spring-el ×1
string ×1