Wie fügen Sie MD5-oder SHA-hash zu spring security?

Arbeite ich an einer Anwendung, die mit Java EE, das Spring security-framework und einer Oracle 11g Datenbank. Ich muss hinzufügen, ein MD5-hash in Spring security, und ich habe nicht gelungen, mit diesem.

Was ich bisher getan habe:

1-In den ersten Wochen habe ich versucht, um dem md5-hash, um meine Anwendung ohne code springsecuritycontext.xml und das habe ich geschafft.

Dies ist, was ich getan habe:

Im Paket, genannt ma.dyaralmansour.zkgui.Politik gibt es zwei Klassen.Die erste heißt " PolicyManager und implementiert diese Klasse die spring-security UserDetailService. Der zweite ist genannt LoginLoggingPolicyService und diese Klasse wird aufgerufen von Spring AOP als einem Aspekt und ist für die Protokollierung.

Also das ist, was ich getan habe:

       *** I added an MD5Password class to the ma.dyaralmansour.zkgui.policy and I added some code to the PolicyManager class to activate the hash and it's working.

Mein problem ist jetzt:

Alle meine Passwörter gehasht werden mit einem MD5-hash, aber ich kann keinen Zugriff auf die Anwendung nicht mehr, wenn ich das normale Passwort.

Nun habe ich 2 Optionen, aber ich habe keine Ahnung wie Sie umzusetzen:

1 - in der MD5password Klasse gibt es eine Methode mit dem Namen testkennwort(String clearTextTestPassword,String encodedActualPassword)

Vergleicht es die normalen Passwort mit dem Hash gespeichert in der Datenbank, aber ich konnte nicht verstehen, wie Sie es hinzufügen, in meinem policymanager-Klasse.

2 -, um vollständig zu entfernen alles, was ich getan hatte, und sich nur auf die Konfiguration von Spring security, um hash das Passwort und den Zugriff auf die Anwendung, wenn ich ein normales Passwort.

Oder gibt es eine andere Lösung??

http://www.mediafire.com/download/gxgda63wyhkpehn/DamPromoZK4.rar

<!-- Spring namespace-based configuration -->

<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:zksp="http://www.zkoss.org/2008/zkspring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd
                    http://www.springframework.org/schema/aop   
                    http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">



<!-- Enable the @Secured annotation to secure service layer methods -->
<global-method-security secured-annotations="enabled" />

<http auto-config="true">

    <!-- ###  If we have our own LoginPage. So we must    ### -->
    <!-- ###     tell Spring the name and the place.      ### -->
    <!-- ###     In our case we take the same page        ### -->
    <!-- ###     for a error message by a failure.        ### -->
    <!-- ### Further the page after a successfully login. ### -->
    <form-login login-page="/index.zul" 

        authentication-failure-url="/index.zul?login_error=1"
        default-target-url="/AccueilIntranet.zul" />

    <!-- ###   Tell Spring where it goes after logout.    ### -->
    <!-- ###          logout-url is a action url.         ### -->
    <logout logout-url="/j_spring_logout" logout-success-url="/index.zul" />

    <!-- ### Define the pages that are to be intercepted  ### -->
    <!-- ### It is parsed from top to bottom. Means that  ### -->
    <!-- ### the most specific pattern is standing on TOP ### -->
    <!-- ###         and the CATCH ALL is on BOTTOM!      ### -->
    <intercept-url pattern="/pages/**" access="IS_AUTHENTICATED_REMEMBERED" filters="none" />
    <intercept-url pattern="/WEB-INF/pages/**" access="IS_AUTHENTICATED_REMEMBERED" filters="none"/>

    <!-- ### The root page is accessible by everyone but  ### -->
    <!-- ###    internally spring makes a login and       ### -->
    <!-- ###     this user becames a UserDetails          ### -->
    <!-- ###   (in there are the ip-address and others)   ### -->
    <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" filters="none"/>

    <!-- ###           Per user one session !!            ### -->
    <concurrent-session-control max-sessions="1" />
</http>

<!-- ###   We define the kind of authentification with a  ### -->
<!-- ###          so called authentication-provider       ### -->
<!-- ###   So we have our users stored in a DB we use     ### -->
<!-- ###   our own user-service class and point to her.   ### -->
<authentication-provider user-service-ref="myUserDetailsService">
</authentication-provider>




<!-- ###   The Implementation of the Interface            ### -->
<!-- ###      UserDetailService for the logged in         ### -->
<!-- ###              user and his rights                 ### -->
<beans:bean id="myUserDetailsService" class="ma.dyaralmansour.zkgui.policy.PolicyManager">
    <beans:property name="userService" ref="userService" />
</beans:bean>



<authentication-provider user-service-ref="myUserDetailsService">
<password-encoder hash="md5"/>
</authentication-provider>




    <!-- ###   This aspect call automatically the methode     ### -->
    <!-- ###   'loginLogging' which is for writing a log for  ### -->
    <!-- ###   all successfully and failed logins, if a       ### -->
    <!-- ###   methode is called that handles the             ### -->
    <!-- ###    Authentication.                               ### -->
    <beans:bean id="LoginLoggingPolicyService"
        class="ma.dyaralmansour.zkgui.policy.LoginLoggingPolicyService">
        <beans:property name="loginLoggingService" ref="loginLoggingService" />
    </beans:bean>






    <aop:config>
        <aop:aspect id="LoginLoggingAspect" ref="LoginLoggingPolicyService">
            <aop:pointcut id="authPointcut"
                expression="execution(public org.springframework.security.Authentication org.springframework.security.providers.AuthenticationProvider.authenticate(org.springframework.security.Authentication))" />
            <aop:around pointcut-ref="authPointcut" method="loginLogging" />
        </aop:aspect>
    </aop:config>

</beans:beans>
InformationsquelleAutor user2644068 | 2013-09-02
Schreibe einen Kommentar