Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > Flex

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему Ответ
Старый 20.11.2008, 16:49
Billy_bon вне форума Посмотреть профиль Отправить личное сообщение для Billy_bon Найти все сообщения от Billy_bon
  № 1  
Ответить с цитированием
Billy_bon

Регистрация: Nov 2008
Сообщений: 5
Question Проблемы с авторизацией. Собственный login.mxml

Народ, помогите, пожалуйста.
Хочу сделать логин форму с помощью Flex. Использую томкат.
есть login.mxml
Цитата:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Style source="css/loginComponentStyle.css"/>

<mx:Script>
<![CDATA[
import mx.managers.CursorManager;

private function submitLogin():void {
submitButton.enabled = false;
loginService.send();
submitButton.enabled = true;
}
]]>
</mx:Script>
<mx:HTTPService id="loginService" url="j_security_check" showBusyCursor="true" method="POST">
<mx:request>
<j_username>{userName.text}</j_username>
<j_password>{password.text}</j_password>
</mx:request>
</mx:HTTPService>
<mx:Form defaultButton="{submitButton}">
<mx:FormItem label="Username">
<mx:TextInput id="userName" name="j_username"/>
</mx:FormItem>
<mx:FormItem label="Password">
<mx:TextInput id="password" displayAsPassword="true" name="j_password"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button id="submitButton" label="submit" click="submitLogin()"/>
</mx:FormItem>
</mx:Form>
</mx:Application>
Написал также web.xml
Цитата:
<!-- Default login configuration uses form-based authentication -->
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.swf</form-login-page>
<form-error-page>/login.swf</form-error-page>
</form-login-config>
</login-config>
Однако, после нажатия на кнопку submit появлятся следующая ошибка:
Цитата:
[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:8080/blablabla/j_security_check"]. URL: j_security_check"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\Ab stractInvoker.as:216]
at mx.rpc::Responder/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\Re sponder.as:49]
at mx.rpc::AsyncRequest/fault()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\rpc\As yncRequest.as:103]
at DirectHTTPMessageResponder/errorHandler()[E:\dev\3.0.x\frameworks\projects\rpc\src\mx\messag ing\channels\DirectHTTPChannel.as:343]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/redirectEvent()

Старый 20.11.2008, 16:57
Alkaz вне форума Посмотреть профиль Отправить личное сообщение для Alkaz Найти все сообщения от Alkaz
  № 2  
Ответить с цитированием
Alkaz

Регистрация: May 2006
Адрес: Нск
Сообщений: 91
хм, мож я чего-то не понял, а это авторизация в чем?

Старый 20.11.2008, 17:12
wvxvw вне форума Посмотреть профиль Отправить личное сообщение для wvxvw Найти все сообщения от wvxvw
  № 3  
Ответить с цитированием
wvxvw
Modus ponens
 
Аватар для wvxvw

модератор форума
Регистрация: Jul 2006
Адрес: #1=(list #1#)
Сообщений: 8,049
Записей в блоге: 38
А что такое j_security_check или, вернее, http://localhost:8080/blablabla/j_security_check ?

EDIT: Упс, сорри, нашел, что это... тут: http://www.junlu.com/msg/4401.html
Ну, чесно, вряд ли смогу помочь... как предположение, а что вы получаете если пробуете авторизироваться с ХТМЛ страницы?
__________________
Hell is the possibility of sanity


Последний раз редактировалось wvxvw; 20.11.2008 в 17:20.
Старый 20.11.2008, 17:18
Billy_bon вне форума Посмотреть профиль Отправить личное сообщение для Billy_bon Найти все сообщения от Billy_bon
  № 4  
Ответить с цитированием
Billy_bon

Регистрация: Nov 2008
Сообщений: 5
Using authentication to control access to Flex applications

To use authentication to prevent unauthorized access to your Flex application, you typically use the container to set up constraints on resources. You then challenge the user who then submits credentials. These credentials determine the success or failure of the user's login attempt, as the container's authentication logic determines.

For example, you can protect the page that the Flex application is returned with, or protect the SWF file itself. You do this in the web.xml file by defining specific URL patterns, as the following example shows:

Код:
<web-app>
    <security-constraint> 
        <web-resource-collection> 
            <web-resource-name>Payroll Application</web-resource-name> 
                <url-pattern>/payroll/*</url-pattern> 
                <http-method>GET</http-method> 
                <http-method>POST</http-method> 
            </web-resource-collection> 
        <auth-constraint> 
            <role-name>manager</role-name> 
        </auth-constraint> 
    </security-constraint> 
</web-app>
When the browser tries to load a resource that is secured by constraints in the web.xml file, the browser either challenges the user (if you are using BASIC authentication) or forwards the user to a login page (with FORM authentication).

With BASIC authentication, the user enters a username and password in a popup box that the browser creates. To specify that an application uses BASIC authentication, you use the login-config element and its auth-method subelement in the web application's web.xml file, as the following example shows:

Код:
<web-app>
    <login-config> 
        <auth-method>BASIC</auth-method> 
        <realm-name>Managers</realm-name> 
    </login-config> 
    ...
</web-app>
With FORM authentication, you must code the page that accepts the username and password, and submit them as FORM variables named j_username and j_password. This form can be implemented in HTML or as a Flex application or anything that can submit a form.

When you configure FORM authentication, you can specify both a login form and an error form in the web.xml file, as the following example shows:

Код:
<web-app>
    <login-config> 
        <auth-method>FORM</auth-method> 
        <form-login-config> 
            <form-login-page>/login.htm</form-login-page> 
            <form-error-page>/loginerror.htm</form-error-page> 
        </form-login-config>
    </login-config> 
</web-app>
You submit the results of the form validation to the j_security_check action. The server executing the application recognizes this action and processes the form.

A simple HTML-based form might appears as follows:

Код:
<form method="POST" action="j_security_check"> 
    <table> 
        <tr><td>User</td><td><input type=text name="j_username"></tr> 
        <tr><td>Password</td><td><input type=password name="j_password"></tr> 
    </table> 
    <input type=submit> 
</form>
The results are submitted to the container's JAAS system with base-64 encoding, which means they can be read by anyone that can view the TCP/IP traffic. Use encryption to prevent these so-called "man-in-the-middle" attacks. In both BASIC and FORM authentication, if the user accessed the resource through SSL, the username and password submission are encrypted, as is all traffic during that exchange.

After it is complete, the container populates the browser's security context and provides or denies access to the resource. Flash Player inherits the security context of the underlying browser. As a result, when you make a data service call, the established credentials are used.

When a user fails an authentication attempt with invalid credentials, be sure not to return information about which item was incorrect. Instead, use a generic message such as "Your login information was invalid."

For application-server specific information about using custom authentication with LiveCycle Data Services, you can use the examples in flex_install_dir/resources/security.

Я написал свою логин-форму на флексе, но она не работает, если же использовать код, который написан в примере(написать например с логин форму с помощью html или jsp), все работает прекрасно. j_security_check - это стандартный экшин в томкате.


Последний раз редактировалось etc; 21.11.2008 в 22:38.
Старый 20.11.2008, 17:38
wvxvw вне форума Посмотреть профиль Отправить личное сообщение для wvxvw Найти все сообщения от wvxvw
  № 5  
Ответить с цитированием
wvxvw
Modus ponens
 
Аватар для wvxvw

модератор форума
Регистрация: Jul 2006
Адрес: #1=(list #1#)
Сообщений: 8,049
Записей в блоге: 38
Ну, единственное, чем могу помочь... в сообщении об ошибке сказано, что аддресс не найден.
__________________
Hell is the possibility of sanity

Старый 20.11.2008, 17:38
Billy_bon вне форума Посмотреть профиль Отправить личное сообщение для Billy_bon Найти все сообщения от Billy_bon
  № 6  
Ответить с цитированием
Billy_bon

Регистрация: Nov 2008
Сообщений: 5
или быть может кто-нить поможет, как перевесть на язык flex-а данный кусок кода:
Код:
<form method="POST" action="j_security_check">
<table>
<tr><td>User</td><td><input type=text name="j_username"></tr>
<tr><td>Password</td><td><input type=password name="j_password"></tr>
</table>
<input type=submit>
</form>


Последний раз редактировалось etc; 21.11.2008 в 22:38.
Старый 21.11.2008, 17:02
Alkaz вне форума Посмотреть профиль Отправить личное сообщение для Alkaz Найти все сообщения от Alkaz
  № 7  
Ответить с цитированием
Alkaz

Регистрация: May 2006
Адрес: Нск
Сообщений: 91
ну со спринг секьюрити такие манипуляции вроде нормально проходят, вот тут статейка , причем вроде код с вашим схож. я хз конечно, но в самом томкате (настройках и т.д.) проблем быть не может?

Старый 21.11.2008, 19:09
etc вне форума Посмотреть профиль Найти все сообщения от etc
  № 8  
Ответить с цитированием
etc
Et cetera
 
Аватар для etc

Регистрация: Sep 2002
Сообщений: 30,787
Billy_bon, в первом посте вы не поленились оформить код соответствующими тегами, а в последующих что-то с вами случилось. Почему?

Старый 21.11.2008, 20:37
Billy_bon вне форума Посмотреть профиль Отправить личное сообщение для Billy_bon Найти все сообщения от Billy_bon
  № 9  
Ответить с цитированием
Billy_bon

Регистрация: Nov 2008
Сообщений: 5
Вроде все настроил сам не знаю как, но вроде завелось. Теперь появилась следующая проблема.
web.xml
Код:
<!-- Default login configuration uses form-based authentication -->
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.swf</form-login-page>
<form-error-page>/errorLogin.html</form-error-page>
</form-login-config>
</login-config>
как видно я использую страницу login.swf - все прекрасно работает(открывается) в Mozilla, но в IE это не работает. IE выдает следующее он просит скачать или открыть этот swf файл, нажимаешь открыть, он пишет что не может быть скачан.
Пытался поправить web.xml(вместо login.swf написать login.html, который генерируется из swf html-wrapper-ом с помощью build.xml)
Код:
<!-- Default login configuration uses form-based authentication -->
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/errorLogin.html</form-error-page>
</form-login-config>
</login-config>
Однако при этом вообще ничего грузиться не хочет. Появляется пустая страница с ошибкой
Цитата:
Ошибка: missing } in XML expression
Источник: http://localhost:8080/blablabla/AC_OETags.js
Строка 19, символ 13
Исходный код:
body { margin: 0px; overflow:hidden }

и

Ошибка: DetectFlashVer is not defined
Источник: http://localhost:8080/blablabla/index.html
Строка: 40
Это и в IE и в Mozilla.

Повторюсь login.html - создался с помощью строчки в Build.xml
Цитата:
<html-wrapper height="100%" width="100%" application="${flex.src}/login.mxml" output="${web.dir}" swf="login" file="login.html"/>
Если же писать стандартную tomcat-овскую Basic авторизацию все работает нормально. Т.е.
Код:
	<login-config>
		<auth-method>BASIC</auth-method>
		<realm-name>Please, login</realm-name>
	</login-config>
Помогите, пожалуйста, а то я уже заапарился в инете сидеть
Заранее спасибо

Создать новую тему Ответ Часовой пояс GMT +4, время: 07:15.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


Часовой пояс GMT +4, время: 07:15.


Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.