users@glassfish.java.net

Re: Install new SAM

From: <forums_at_java.net>
Date: Thu, 15 Nov 2012 11:37:55 -0600 (CST)

With multiple GF reboots it's work now, probably I made some
mistakes...sorry. So my SAM is found by my application now but I don't
understand this GF error :
[#|2012-11-15T15:58:10.578+0100|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=92;_ThreadName=Thread-2;|PWC4011:
Unable to set request character encoding to UTF-8 from context /web, because
request parameters have already been read, or ServletRequest.getReader() has
already been called|#]
[#|2012-11-15T15:58:10.578+0100|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=91;_ThreadName=Thread-2;|PWC4011:
Unable to set request character encoding to UTF-8 from context /web, because
request parameters have already been read, or ServletRequest.getReader() has
already been called|#]
[#|2012-11-15T15:58:10.593+0100|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=89;_ThreadName=Thread-2;|PWC4011:
Unable to set request character encoding to UTF-8 from context /web, because
request parameters have already been read, or ServletRequest.getReader() has
already been called|#]
[#|2012-11-15T15:58:10.640+0100|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=88;_ThreadName=Thread-2;|PWC4011:
Unable to set request character encoding to UTF-8 from context /web, because
request parameters have already been read, or ServletRequest.getReader() has
already been called|#]
[#|2012-11-15T15:58:10.765+0100|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=90;_ThreadName=Thread-2;|PWC4011:
Unable to set request character encoding to UTF-8 from context /web, because
request parameters have already been read, or ServletRequest.getReader() has
already been called|#]
[#|2012-11-15T15:58:10.781+0100|WARNING|glassfish3.1.2|org.apache.catalina.connector.Request|_ThreadID=89;_ThreadName=Thread-2;|PWC4011:
Unable to set request character encoding to UTF-8 from context /web, because
request parameters have already been read, or ServletRequest.getReader() has
already been called|#]
[#|2012-11-15T15:58:10.796+0100|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=90;_ThreadName=Thread-2;|StandardWrapperValve[default]:
PWC1406: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException: PWC3990: getWriter() has already been called
for this response at
org.apache.catalina.connector.Response.getOutputStream(Response.java:674) at
org.apache.catalina.connector.ResponseFacade.getOutputStream(ResponseFacade.java:206)
at
org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:981)
at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:466)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:770) at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at
com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757) at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056) at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722) |#] My custom SAM can't be more
simpliest : public class CustomServerAuthModule implements ServerAuthModule {
private static Logger logger =
Logger.getLogger(CustomServerAuthModule.class); MessagePolicy requestPolicy,
responsePolicy; CallbackHandler callBackHandler; Map<?, ?> options;
@SuppressWarnings("rawtypes") public void initialize(MessagePolicy reqPolicy,
MessagePolicy resPolicy, CallbackHandler cb, Map opts) throws AuthException {
logger.log(Level.INFO, "SIMSAM->initialize()"); requestPolicy = reqPolicy;
responsePolicy = resPolicy; callBackHandler = cb; options = opts; } public
Class<?>[] getSupportedMessageTypes() { return new
Class[]{HttpServletRequest.class, HttpServletResponse.class}; } public
AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject,
Subject serviceSubject) throws AuthException { logger.log(Level.INFO,
"SIMSAM->validateRequest()"); return AuthStatus.SUCCESS; } public AuthStatus
secureResponse(MessageInfo arg0, Subject arg1) throws AuthException {
logger.log(Level.INFO, "SIMSAM->secureResponse"); return AuthStatus.SUCCESS;
} public void cleanSubject(MessageInfo arg0, Subject arg1) throws
AuthException { // TODO Auto-generated method stub } } glassfish-web.xml
contains this : <glassfish-web-app httpservlet-security-provider="SIMSAM">
<context-root>web</context-root> <security-role-mapping> Employee</role-name>
Employee</group-name> </security-role-mapping> </glassfish-web-app> and my
web.xml : <?xml version="1.0" encoding="ISO-8859-1"?> <web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<welcome-file-list> <welcome-file>/index.xhtml</welcome-file>
</welcome-file-list> <servlet> <servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup> 1 </load-on-startup> </servlet> <servlet-mapping>
<servlet-name>Faces Servlet</servlet-name> <url-pattern>*.xhtml</url-pattern>
</servlet-mapping> <security-constraint> <display-name>Restricted GET To
Employees</display-name> <web-resource-collection>
<web-resource-name>Restricted Access - Get Only</web-resource-name>
<url-pattern>*.xhtml</url-pattern> <http-method>GET</http-method>
<http-method>POST</http-method> <auth-constraint>
<role-name>Employee</role-name> </auth-constraint> <user-data-constraint>
<transport-guarantee>NONE</transport-guarantee> </user-data-constraint>
</security-constraint> <security-role> <role-name>Employee</role-name>
</security-role> <login-config> <auth-method>FORM</auth-method>
<realm-name>sim-realm2</realm-name> </login-config> </web-app> Any help for
my error ? Goal is to provide custom realm with username, password AND some
string to authenticate users. Good way to do this is to use SAM...no ? Thanks

--
[Message sent by forum member 'olivierJ']
View Post: http://forums.java.net/node/892251