将XML安全配置转换为Java配置

时间:2016-05-31 20:52:59

标签: spring-security

我最终试图将以下基于XML的配置转换为基于POJO的配置:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCellWithIdentifier("SecondCell") as! ContactCell
    let item = contacts[indexPath.row]
    cell.meetupLabel?.text = item.fullName
    return cell
}

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = self.tableView.dequeueReusableCellWithIdentifier("FirstCell") as! ContactCell
    let item = contacts[indexPath.row]
    cell.label?.text = item.fullName
    return cell
}

目前,我有这样的事情:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-4.0.xsd">

<bean id="auth0EntryPoint" class="com.auth0.spring.security.auth0.Auth0AuthenticationEntryPoint" />

<!-- all urls starting with unsecured are -->
<security:http pattern="${auth0.securedRoute}" create-session="stateless"  entry-point-ref="auth0EntryPoint" use-expressions="false">
    <security:intercept-url pattern="${auth0.securedRoute}" access="ROLE_USER" />
    <security:custom-filter ref="auth0Filter" after="SECURITY_CONTEXT_FILTER" ></security:custom-filter>
    <security:csrf disabled="true"></security:csrf> 
</security:http>

<!-- Otherwise by default everything is secured -->
<security:http auto-config="true" use-expressions="true"  pattern="/**" create-session="stateless"  entry-point-ref="auth0EntryPoint">
    <security:intercept-url pattern="/**" access='permitAll' />
    <security:csrf disabled="true"></security:csrf>
</security:http>

<bean id="auth0Filter" class="com.auth0.spring.security.auth0.Auth0AuthenticationFilter">
    <property name="entryPoint" ref="auth0EntryPoint"></property>
</bean>

<bean id="auth0AuthenticationProvider" class="com.auth0.spring.security.auth0.Auth0AuthenticationProvider">
    <property name="clientSecret" value="${auth0.clientSecret}" ></property>
    <property name="clientId" value="${auth0.clientId}" ></property>
    <property name="securedRoute" value="${auth0.securedRoute}" ></property>
</bean>

<security:authentication-manager alias="authenticationManager">
    <security:authentication-provider ref="auth0AuthenticationProvider" />
</security:authentication-manager>

但它经历了数十次迭代,我只是没有得到任何需要排队的东西。目前我正在处理一个问题,即它声称过滤器链已经是一个已定义的bean,因此没有请求通过。任何帮助或提示都是巨大的,我还没有找到spring-security-4的参考书,所以我只是想凑齐代码样本。

1 个答案:

答案 0 :(得分:0)

我确信,在发布问题后,我注定只会获得相关的搜索结果:Why isn’t this Spring Security AuthenticationProvider found after being Java configured?