Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

cvs commit: ws-fx/wss4j/src/org/apache/ws/axis/security/trust STSAgent.java: msg#00220

apache.webservices.fx.devel

Subject: cvs commit: ws-fx/wss4j/src/org/apache/ws/axis/security/trust STSAgent.java

muthulee 2004/08/27 21:47:24

Added: wss4j/src/org/apache/ws/axis/security/trust STSAgent.java
Log:
Kaushalye's code for STSAgent

Revision Changes Path
1.1
ws-fx/wss4j/src/org/apache/ws/axis/security/trust/STSAgent.java

Index: STSAgent.java
===================================================================
/*
* Created on Aug 18, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.apache.ws.axis.security.trust;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Hashtable;

import javax.xml.rpc.ServiceException;

import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.axis.security.WSDoAllReceiver;
import org.apache.ws.axis.security.WSDoAllSender;
import org.apache.ws.security.conversation.message.token.RequestSecurityToken;
import org.apache.ws.security.trust.message.token.RequestType;
import org.apache.ws.security.trust.message.token.TokenType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

/**
* @author Malinda Kaushalye
*
* STSAgent is an axis specific component resides in the client side to
request a token.
* The main task is to act as an Agent on behalf of the STS.
*
*
*/
public class STSAgent {
static Log log = LogFactory.getLog(STSAgent.class.getName());
String url;
RequestSecurityToken reqSecTok;
Document doc;
SOAPEnvelope env;
Call call;

/**
* Agent initialization
* @param url Endpoint Address
* @param senderOptions WSDoAllSender options
* @param recieverOptions WSDoAllReceiver options
* @throws ServiceException
* @throws MalformedURLException
* @throws Exception
*
* @see org.apache.ws.axis.security.WSDoAllReceiver
* @see org.apache.ws.axis.security.WSDoAllSender
*/
public STSAgent(String url,Hashtable senderOptions,Hashtable
recieverOptions)throws ServiceException,MalformedURLException,Exception{
Service service = new Service();
call = (Call) service.createCall();
//--

WSDoAllSender doAllSender=new WSDoAllSender();
WSDoAllReceiver doAllReciever=new WSDoAllReceiver();

// if there are options to encrypt and sign hand them over to
WSDoAllSender/Reciever
if(senderOptions !=null){
log.debug("WSDoAllSender options are null");
doAllSender.setOptions(senderOptions);

}
if(recieverOptions !=null){
log.debug("WSDoAllReceiver options are null");
doAllReciever.setOptions(recieverOptions);
}
call.setClientHandlers(doAllSender,doAllReciever);
//--
this.url=url;
call.setTargetEndpointAddress(new URL(url));
log.debug("Endpoint Address : "+url);
env = new SOAPEnvelope();
doc = env.getAsDocument();
reqSecTok=new RequestSecurityToken(doc);
}

/**
* Sets token type element
* @param value
*/
public void setTokenTypeElement(String value){
TokenType tokenType=new TokenType(this.doc);
tokenType.setValue(value);
reqSecTok.addToken(tokenType.getElement());
}
/**
* Sets request type element
* @param value
*/
public void setRequestTypeElement(String value){
RequestType requestType=new RequestType(this.doc);
requestType.setValue(value);
reqSecTok.addToken(requestType.getElement());
}
/**
* Use this method to add any element to the request
* @param element
*/
public void setAnyElement(Element element){
reqSecTok.addToken(element);
}


/**
* request call
* Thank goes to David Del Vecchio for giving his code(=>idea)
*
* @return
* @throws AxisFault
* @throws Exception
*/
public Element request()throws AxisFault,Exception{
SOAPBodyElement sbe = new
SOAPBodyElement(reqSecTok.getElement());
env.addBodyElement(sbe);
log.debug("Invoke");
SOAPEnvelope response = call.invoke(env);
Element responseElement =response.getAsDOM();
return responseElement;
}


public Document getDoc() {
return doc;
}
public SOAPEnvelope getEnv() {
return env;
}
public RequestSecurityToken getReqSecTok() {
return reqSecTok;
}
public void setReqSecTok(RequestSecurityToken reqSecTok) {
this.reqSecTok = reqSecTok;
}
/**
* to retrieve the endpoint url of the agent
* @return
*/
public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
hardware.arm.at...    cms.citadel.dev...    video.gstreamer...    java.facelets.u...    misc.basics.qna...    web.wiki.instik...    network.uip.use...    xdg.devel/2003-...    tex.bibtex.bibd...    finance.quotesp...    ietf.zeroconf/2...    redhat.blinux.g...    suse.db2/2003-0...    php.phpesp/2004...    uml.devel/2003-...    gnome.labyrinth...    qnx.openqnx.dev...    boot-loaders.gr...    db.dataperfect....    audio.audacity....    linux.uclinux.m...    editors.j.devel...    os.openbsd.tech...    kde.users.multi...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation