小编Ale*_*exG的帖子

亚马逊简单电子邮件服务(SES) - 我应该使用SMTP接口还是SES API?

我是Amazon SES的新手,我发现有两种方法可以通过编程方式发送电子邮件:

  1. SES API(http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-email-api.html)
  2. SES SMTP接口(http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-java.html)

每种方法的优缺点是什么?它们似乎可以互换,但我想听听那些有过SES经验的人.

根据我自己的要求,我将向用户发送交易电子邮件(即收据,帐户确认等)和通知电子邮件(即"您有新消息",状态更改等)我的网络和移动应用程序.如果可能的话,我想保留所有这些外发电子邮件的历史记录.

email smtp jakarta-mail amazon-web-services amazon-ses

16
推荐指数
4
解决办法
8276
查看次数

Facebook使用现有用户访问令牌登录Spring Social

这是我现在拥有的:

  • Spring REST服务,其中许多API要求用户进行身份验证
  • '注册'API(/ api/v1/register)
  • 采用用户名/密码的"登录"API(/ api/v1/login)
  • 'Facebook Login'API依赖Spring Social和Spring Security创建用户连接并在(/ auth/facebook)中记录我的用户

我的问题是我希望这些API被多个客户端使用,但Facebook登录的方式现在,它在移动设备上运行不佳(在网站上运行良好).

这是移动方案:

  • 我使用Facebook的iOS SDK来请求用户的许可
  • Facebook返回用户访问令牌
  • 我想发送我的后端服务此令牌并让Spring Social接受它,创建用户连接等.

可以这样做吗?或者我是否必须编写自己的API来持久保存用户连接?

感谢任何帮助!

rest spring-security ios spring-social spring-social-facebook

15
推荐指数
1
解决办法
3337
查看次数

Spring Rest Service - 尝试登录时无效的CSRF令牌

我有一个Spring MVC REST服务,启用了Spring Security(3.2.5.RELEASE).当我打开@EnableWebMvcSecurity时,会在http:// localhost:8080/login为我自动生成一个登录表单.如果我使用此表单登录,一切正常.

当我尝试通过直接发送POST请求登录时,会发生此问题.在我的帖子请求中,我提供了用户名和密码.我还包括http标头'X-CSRF-TOKEN',对于标头值,我使用我看到的JSESSIONID已在cookie中生成.但是,当我发送此POST请求时,我得到以下结果:

HTTP Status 403 - Invalid CSRF Token '29F5E49EFE8D758D4903C0491D56433E' 
was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我提供了错误的令牌价值吗?这是什么JSESSIONID?如果我没有为此标题输入值,或者一起省略标题,则会告诉我"找到空的CSRF标记".

以下是我的Spring Security配置:

@Configuration
@EnableWebMvcSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
            .withUser("user").password("password").roles("USER");
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .antMatchers("/secure/**").authenticated()
                .and()
            .formLogin()
                .usernameParameter("username")
                .passwordParameter("password")        
                .and()
            .logout()
                .and()
            .httpBasic()
                .and()
            .csrf(); 
    }
}
Run Code Online (Sandbox Code Playgroud)

我真的很感激任何帮助!提前致谢!

rest spring spring-mvc spring-security http-authentication

7
推荐指数
2
解决办法
1万
查看次数

无法从Angular ui-view中访问Javascript

我有一个带有Angular ui-view的主模板(index.html).在这个主模板中,我导入了一堆Javascript文件.我希望这些文件可用于将在ui-view中加载的html模板内的内容,但JS函数似乎无法访问.

/sample-app/index.html:

<html ng-app="otr">
<head></head>
<body>
    <div ui-view></div>

    <!-- JS imports -->
    <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

    <!-- Angular Dependencies -->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0-rc.1/angular.min.js"></script>
    <script src="https://code.angularjs.org/1.4.0-rc.1/angular-route.min.js"></script>
    <script src="https://code.angularjs.org/1.4.0-rc.1/angular-cookies.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.14/angular-ui-router.min.js"></script>

    <!-- Custom scripts -->
    <script src="/sample-app/js/login.js"></script>

    <!-- Angular app scripts -->
    <script src="app/app.js"></script>
    <script src="app/services/authentication.service.js"></script>
    <script src="app/services/flash.service.js"></script>
    <script src="app/common/cases-model.js"></script>

    <script src="app/home/home.controller.js"></script>
    <script src="app/login/login.controller.js"></script>
    <script src="app/register/register.controller.js"></script>        

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

/sample-app/js/login.js

$(function() {

    $('#login-form-link').click(function(e) {
        $("#login-form").delay(100).fadeIn(100);
        $("#register-form").fadeOut(100);
        $('#register-form-link').removeClass('active');
        $(this).addClass('active');
        e.preventDefault();
    });
    $('#register-form-link').click(function(e) {
        console.log('Inside login.js REGISTER');
        $("#register-form").delay(100).fadeIn(100);
        $("#login-form").fadeOut(100);
        $('#login-form-link').removeClass('active');
        $(this).addClass('active');
        e.preventDefault();
    });

});
Run Code Online (Sandbox Code Playgroud)

/sample-app/app/app.js: …

html javascript jquery angularjs

5
推荐指数
1
解决办法
4242
查看次数

momentJS默认语言环境是zh-tw,似乎无法覆盖它

我在我的Angular应用程序中从CDN中提取了momentJS库:

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

默认语言环境应该是英语('en').但由于某种原因,我的应用程序中的默认语言环境是'zh-tw'.我看到这曾经是一个问题(见这里这里),但它应该是固定的.

即使我手动设置全局语言环境,也会被忽略:

在我的index.html文件中:

<script>
    moment.locale('en');
</script>
Run Code Online (Sandbox Code Playgroud)

在我的Angular控制器中:

moment.locale('en');
Run Code Online (Sandbox Code Playgroud)

现在唯一可行的是,如果我在每个时刻实例上设置区域设置:

var moment1 = moment(myDate);
moment1.locale('en');
var moment2 = moment(moment1).add(24, 'h');
moment2.locale('en');
Run Code Online (Sandbox Code Playgroud)

javascript angularjs momentjs angular-moment

5
推荐指数
1
解决办法
1150
查看次数

在Angular控制器中使用moment-duration-format插件

我正在尝试使用moment-duration-format插件格式化MomentJS持续时间。我将如何在Angular控制器中使用此插件?似乎一旦导入JS,它就应该开箱即用,但事实并非如此。

我已经在index.html中导入了momentJS和MDF JS文件:

// MomentJS
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
// moment-duration-format plugin
<script src="bower_components/moment-duration-format/lib/moment-duration-format.js"></script>
Run Code Online (Sandbox Code Playgroud)

但是,当我在控制器中调用以下行时,出现错误:

console.log( moment.duration(123, "minutes").format("h:mm") );
Run Code Online (Sandbox Code Playgroud)

错误:

TypeError: moment.duration(...).format is not a function...
Run Code Online (Sandbox Code Playgroud)

javascript angularjs momentjs

5
推荐指数
1
解决办法
568
查看次数

如何让 Hibernate 忽略不在实体中的表列?

我在 Spring MVC 和 Hibernate 中使用 Java。我有一堆实体,一切正常。但是,如果我将一列添加到我的数据库列之一,我的服务将开始崩溃,直到我还使用新列更新相关的 java 实体类。

有没有办法告诉 Hibernate 忽略它无法识别的数据库列?如果您希望实体中有一个不在您的数据库表中的字段,您可以在该字段上使用 @Transient。我想要相反的。

如果这是不可能的,那么在必须进行数据库更新时如何部署 Hibernate 服务?

java spring entity-framework hibernate hibernate-mapping

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

从Web上的Branch.io检索深层链接数据

我创建了一个Branch.io链接:fight.offtherecord.com/alexg.例如,该链接具有与其相关联的深度数据(即,别名= Alexg,userId = 375等).Branch.io将这些数据存储在最后.

当我在浏览器中从桌面加载此链接时,我最终在地址栏中显示以下内容:" https://offtherecord.com/?_branch_match_id=224695141967923130 ".

如何访问链接旁边存储的数据?我没有看到任何API可用.我确实看到了这个GET API:https: //api.branch.io/v1/url? branch_key =&url = http://fight.offtherecord.com/alexg 但是这需要输入原始链接,而不是我在地址栏中最终得到的结果.

我查看了他们的Web SDK,但是空洞了.

api deep-linking branch.io deeplink

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