package security.test;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.annotation.Resource;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import org.jboss.ejb3.annotation.SecurityDomain;
import org.jboss.util.Base64;
import org.jboss.wsf.spi.annotation.WebContext;
/**
* Session Bean implementation class ServiceCall
*/
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
@WebService(name="MetaDataRegistry",
targetNamespace = "http://csiro.au/webservice/registry",
serviceName = "RegistrationService")
@SecurityDomain(value = "JBossWS")
@WebContext(contextRoot = "/MetaDataRegistry", transportGuarantee="NONE", authMethod="BASIC", secureWSDLAccess=false)
@Remote(ServiceCallRemote.class)
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT)
public class ServiceCall implements ServiceCallRemote, ServiceCallLocal {
@Resource
WebServiceContext wsContext;
/**
* Default constructor.
*/
public ServiceCall() {
// TODO Auto-generated constructor stub
}
@Override
@RolesAllowed("Guest")
@WebMethod()
public void CallService1(String username) throws UnsupportedEncodingException
{
MessageContext context = wsContext.getMessageContext();
Map requestHeaders = (Map) context.get(MessageContext.HTTP_REQUEST_HEADERS) ;
Object obj = requestHeaders.get("Authorization");
String output = obj.toString();
String result = output.replace("Basic ", "");
result = result.replace("[", "");
result = result.replace("]", "");
byte[] p = Base64.decode(result);
String f = new String(p, 0, p.length, "UTF-8" );
System.out.println(f);
}
}
Safe, High performance, reuseable
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment