From jbossws-commits at lists.jboss.org Tue Feb 16 08:00:09 2010
Content-Type: multipart/mixed; boundary="===============7184760401376582542=="
MIME-Version: 1.0
From: jbossws-commits at lists.jboss.org
To: jbossws-commits at lists.jboss.org
Subject: [jbossws-commits] JBossWS SVN: r11596 -
common/trunk/src/main/java/org/jboss/wsf/common/invocation.
Date: Tue, 16 Feb 2010 08:00:09 -0500
Message-ID: <201002161300.o1GD0983005929@svn01.web.mwc.hst.phx2.redhat.com>
--===============7184760401376582542==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: richard.opalka(a)jboss.com
Date: 2010-02-16 08:00:08 -0500 (Tue, 16 Feb 2010)
New Revision: 11596
Added:
common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServiceCon=
textEJB.java
common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServiceCon=
textJSE.java
Log:
[JBWS-2934] refactoring WebServiceContext implementation
Added: common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServic=
eContextEJB.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServiceCo=
ntextEJB.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServiceCo=
ntextEJB.java 2010-02-16 13:00:08 UTC (rev 11596)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.invocation;
+
+import java.security.Principal;
+
+import javax.ejb.EJBContext;
+import javax.xml.ws.WebServiceContext;
+
+import org.jboss.wsf.spi.invocation.WebServiceContextDelegate;
+
+/**
+ * EJB web service context which security related methods delegate to EJB =
container.
+ * =
+ * @author alessio.soldano(a)jboss.com
+ * @author Richard Opalka
+ */
+public class WebServiceContextEJB extends WebServiceContextDelegate
+{
+ public WebServiceContextEJB(final WebServiceContext ctx)
+ {
+ super(ctx);
+ }
+
+ public Principal getUserPrincipal()
+ {
+ final EJBContext ejbContext =3D getAttachment(EJBContext.class);
+ return ejbContext.getCallerPrincipal();
+ }
+
+ public boolean isUserInRole(String role)
+ {
+ final EJBContext ejbContext =3D getAttachment(EJBContext.class);
+ return ejbContext.isCallerInRole(role);
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServic=
eContextJSE.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServiceCo=
ntextJSE.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/common/invocation/WebServiceCo=
ntextJSE.java 2010-02-16 13:00:08 UTC (rev 11596)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.common.invocation;
+
+import java.security.Principal;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.wsf.spi.invocation.WebServiceContextDelegate;
+
+/**
+ * JSE web service context which security related methods delegate to serv=
let container.
+ * =
+ * @author alessio.soldano(a)jboss.com
+ * @author Richard Opalka
+ */
+public final class WebServiceContextJSE extends WebServiceContextDelegate
+{
+ private final HttpServletRequest httpRequest;
+ =
+ public WebServiceContextJSE(final WebServiceContext ctx)
+ {
+ super(ctx);
+ =
+ if (ctx.getMessageContext().get(MessageContext.SERVLET_REQUEST) =3D=
=3D null)
+ throw new IllegalStateException("Cannot obtain HttpServletRequest=
from message context");
+
+ this.httpRequest =3D (HttpServletRequest)ctx.getMessageContext().get=
(MessageContext.SERVLET_REQUEST);
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ return this.httpRequest.getUserPrincipal();
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ return this.httpRequest.isUserInRole(role);
+ }
+}
--===============7184760401376582542==--