[JBossWS] - Re: Basic Authentication with WSSecureEndpoint on JBoss 4.2.
by ejb3workshop
I think in the end I had to make changes in my LoginModule for it to work. This is my complete login module.
Hope it helps
Alex
/*
| * SimpleLoginModule.java
| *
| * Created on 24 June 2005, 10:45
| *
| */
| package com.thunderhead.backend.security;
| import java.io.IOException;
| import java.security.acl.Group;
| import java.util.Map;
| import javax.security.auth.Subject;
| import javax.security.auth.callback.Callback;
| import javax.security.auth.callback.CallbackHandler;
| import javax.security.auth.callback.NameCallback;
| import javax.security.auth.callback.PasswordCallback;
| import javax.security.auth.callback.UnsupportedCallbackException;
| import javax.security.auth.login.LoginException;
| import javax.security.auth.spi.LoginModule;
|
| /**
| *
| * <p>Copyright: Copyright (c) 2007</p>
| * <p>Company: Thunderhead</p>
| * @author ahartner
| * @version 1
| */
| public class SimpleLoginModule implements LoginModule {
| private Subject m_subject;
| private CallbackHandler m_callbackHandler;
| private String m_userid;
| private String m_password;
|
| /**
| * Creates a new instance of SimpleLoginModule
| */
| public SimpleLoginModule() {
| }
|
| public boolean abort() throws LoginException {
| return true;
| }
|
| public boolean commit() throws LoginException {
| JAASUser user = new JAASUser(1,m_userid);
|
| Group grp = new JAASGroup("Roles");
| grp.addMember(new JAASRole("friend"));
| grp.addMember(new JAASRole("friends"));
|
| m_subject.getPrincipals().add(user);
| m_subject.getPrincipals().add(grp);
| return true;
| }
|
| public void initialize(Subject subject, CallbackHandler callbackHandler, Map state, Map options) {
| m_subject = subject;
| m_callbackHandler=callbackHandler;
| }
|
| public boolean login() throws LoginException {
| NameCallback nameCallback = new NameCallback("User Name");
| PasswordCallback passwordCallback = new PasswordCallback("User Password", false);
| Callback[] callbacks = new Callback[2];
| callbacks[0] = nameCallback;
| callbacks[1] = passwordCallback;
| try {
| m_callbackHandler.handle(callbacks);
| } catch (UnsupportedCallbackException ex) {
| ex.printStackTrace();
| } catch (IOException ex) {
| ex.printStackTrace();
| }
| try {
| if (nameCallback.getName() != null) {
| m_userid = nameCallback.getName();
| }
| if (passwordCallback.getPassword() != null) {
| m_password = new String(passwordCallback.getPassword());
| }
| passwordCallback.clearPassword();
| } catch (Exception e) {
| e.printStackTrace();
| }
| if (!m_userid.equals("user") || !m_password.equals("password"))
| {
| return false;
| }
| else
| {
| return true;
| }
| }
|
| public boolean logout() throws LoginException {
| m_subject.getPrincipals().clear();
| return true;
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110914#4110914
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110914
17 years
[JBossWS] - Re: ArrayList or Set as return type in a web method ?
by shoeb1981
You can return any object of any complex data structure, as long as you can write an xml schema for that.
However, rather than returning the Set object, you could return an array, which could further be cast down to a set by the client application.
The purpose of web services is to have a standard interface that both parties agree with (the provider of the service and the client). You should keep your interface simple so that you can write a simple schema for that. That will be easier for you to manage and simple for your client to understand.
If you want to re-use the component in your application that you want to expose as web service, you can write an adapter class to your business method. And expose that adapter's interface to client. So in future if you change the original method's signature your clients will still get benefit.
Hope that helps.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110802#4110802
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110802
17 years
[JBossWS] - My WS doesn't send any attachment... why?
by cdc08x
Hi all!
I'm using the EJB3.0 spec. with JBoss AS 4.2.2 (and the related JBossWS version inside, of course), in order to create a Web Service using a Stateless Session Bean instead of a Servlet.
I'd like to send an attachment from within a Web Service method.
Here I explain my problem.
I programmed as follows my Stateless Session Bean:
| ...
| @Stateless(name="PortalInfoExchangeServiceEJB")
| @WebService(
| name="PortalInfoExchange",
| serviceName="PortalInfoExchange",
| targetNamespace="http://www.provincia.latina.it/servizi/ws/portal/PortalInfoExchange",
| endpointInterface = "servizi.it.latina.provincia.portal.ws.PortalInfoExchangeWS")
| @Remote(PortalInfoExchangeWS.class)
| public class PortalInfoExchangeBean implements PortalInfoExchangeWS {
| @Resource WebServiceContext context;
| ...
| public String interact(
| String xmlData
| ) throws IllegalArgumentException {
|
| // Start-up
| String pdfFilePath = "/var/www/SOAPprova/prova.pdf";
| ...
| // Attachment
| SOAPMessageContext msgContext = (SOAPMessageContext)context.getMessageContext();
| SOAPMessage soapMessage = msgContext.getMessage();
| DataHandler dh = new DataHandler(new FileDataSource(pdfFilePath));
| AttachmentPart attachment = soapMessage.createAttachmentPart(dh);
|
| soapMessage.addAttachmentPart(attachment);
| ...
| // Return
| return "Ciao " + xQueryResult + "! [ xQuery: \"for $nome in doc('/home/cdc/workspace/LTPortalWS/build/classes/servizi/it/latina/provincia/portal/ws/tmp.xml')/dataWrapper/dati/nome return data($nome)\" ]";
| }
|
But when I call this service from a PHP Client, sniffing the SOAP response packet I see this:
| HTTP/1.1 200 OK
| Server: Apache-Coyote/1.1
| X-Powered-By: Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)/Tomcat-5.5
| Content-Type: text/xml;charset=UTF-8
| Date: Thu, 06 Dec 2007 09:56:13 GMT
| Connection: close
|
| <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
| <env:Header>
| </env:Header>
| <env:Body>
| <ns2:interactResponse xmlns:ns2="http://www.provincia.latina.it/servizi/ws/portal/PortalInfoExchange">
| <xmlData>Ciao Claudio! [ xQuery: "for $nome in doc('/home/cdc/workspace/LTPortalWS/build/classes/servizi/it/latina/provincia/portal/ws/tmp.xml')/dataWrapper/dati/nome return data($nome)" ]</xmlData>
|
| </ns2:interactResponse>
| </env:Body>
| </env:Envelope>
|
Please, could anyone suggest me why there's no attachment?
Have I got to change somehow manually the WSDL to specify that there will be an attachment?
Did I make something wrong into the code?
I searched a lot around the web, but found nothing...
Any help will be very appreciated!
Claudio Di Ciccio
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4110782#4110782
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4110782
17 years