小编Fre*_*37b的帖子

如何从数据库中存储和使用shiro的盐

我在申请认证时使用shiro.我使用散列密码和盐,我将它们存储在我的数据库中,如下所示:

    private User createUserWithHashedPassword(String inName, String inFirstName, String inLastName, String inPassword){

    ByteSource salt  = randomNumberGenerator.nextBytes(32);

    byte[] byteTabSalt  = salt.getBytes();

    String strSalt = byteArrayToHexString(byteTabSalt);

    String hashedPasswordBase64 = new Sha256Hash(inPassword, salt, 1024).toBase64();

    return new User(inName,inFirstName,inLastName,hashedPasswordBase64,strSalt);
}
Run Code Online (Sandbox Code Playgroud)

我在我的数据库中使用String存储salt.现在在我的领域我想从数据库中获取我的数据,我使用了一个transactionnal服务.但是我的salt是一个Strong,所以我希望它以静态方法转回ByteSource类型:

ByteSource byteSourceSalt = Util.bytes(salt); //where the salt is a String
Run Code Online (Sandbox Code Playgroud)

但是当我创建我的SaltedAuthenticationInfo时,它不会授权.

我认为我的问题来自我的转换方法:

private String byteArrayToHexString(byte[] bArray){

        StringBuffer buffer = new StringBuffer();

        for(byte b : bArray) {
            buffer.append(Integer.toHexString(b));
            buffer.append(" ");
        }

 return buffer.toString().toUpperCase();    
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

java database salt shiro

8
推荐指数
1
解决办法
5934
查看次数

如何使用Shiro的SaltedAuthenticationInfo?

我为我的应用程序处理身份验证组件.我正在使用带有盐渍密码的Apache Shiro API.

我在这个示例中使用salt创建了一个新用户:

ByteSource salt = randomNumberGenerator.nextBytes(32);      
byte[] byteTabSalt = salt.getBytes();   
String strSalt = byteArrayToHexString(byteTabSalt);         
String hashedPasswordBase64 = new Sha256Hash(inPassword, salt, 512).toBase64();
Run Code Online (Sandbox Code Playgroud)

但我不明白我是如何在doGetAuthenticationInfo方法中使用salt来验证用户的.我的方法必须返回SaltedAuthenticatedInfo,但我不明白我是如何创建它的.

我不明白Credential Matcher和SaltedAuthenticateInfo之间的联系.

创建密码盐时,是否必须通知凭据匹配器?

谢谢你的帮助.

java salt shiro

6
推荐指数
1
解决办法
5385
查看次数

angular 运行时、样式和 polyfiles 在我的 Web 服务器上收到 404 错误

我做了一个小 Angular 应用程序,我已经在我的计算机上构建了它,但是当我尝试打开 index.html 文件时出现 404 错误,我尝试将它部署在 Web 服务器上,但它是相同的:

获取http://www.valhatech.com/runtime-es2015.edb2fcf2778e7bf1d426.js net::ERR_ABORTED 404(未找到)

获取http://www.valhatech.com/styles.365933d9cb35ac99c497.css net::ERR_ABORTED 404(未找到)

获取http://www.valhatech.com/polyfills-es2015.2987770fde9daa1d8a2e.js net::ERR_ABORTED 404(未找到)

我的 index.html 文件是:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>McKenzieEquation</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <script src="assets/js/app.js"></script>
</head>
<body>
  <app-root></app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我的 app.module.ts 的内容是:

const routes: Routes = [

  { path: 'home', component: AppComponent },
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: '**', redirectTo: 'home' }
];

@NgModule({
  declarations: …
Run Code Online (Sandbox Code Playgroud)

javascript http-status-code-404 angular

3
推荐指数
1
解决办法
6565
查看次数