-
1. Re: Login from another Web-Host with known Credentials
matthias Oct 22, 2002 6:23 AM (in response to matthias)Hi,
i have found two solutions for my Problem
first:
The quotation-Marks in the link are wrong and the reason was
a null Pointer-Exception on working.
The redirect works as follows:
<%
String address = response.encodeURL("j_security_check") + "?j_username=Willi2&j_password=WilliPass";
response.sendRedirect(address);
%>
this works.
second:
another solution is to consult the security-Manager. With this help
i can set new credentials and work on.
-----Code-Snippet-----------------------------------
<%@ page
session="false"
isThreadSafe="true"
isErrorPage="false"
import="javax.naming.*,
test.interfaces.*,
java.math.BigDecimal, java.security.Principal,
org.jboss.security.* "
%>
.....
javax.naming.InitialContext iniCtx = new javax.naming.InitialContext();
AuthenticationManager securityMgr = (AuthenticationManager)
iniCtx.lookup("java:comp/env/security/securityMgr");
SimplePrincipal principal = new SimplePrincipal("Willi2");
String sPassword = "WilliPass";
%>
<%
if ( securityMgr.isValid(principal, sPassword) ) {
SecurityAssociation.setPrincipal(principal);
SecurityAssociation.setCredential(sPassword.toCharArray());
out.println("Access allowed !");
} else {
out.println("Access denied !");
}
%>
-----Code-Snippet-----------------------------------
Thanks to the Documentation of JBoss (JBossBook_30x page 316...)
Regards Matthias Lakämper