/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: DSTClient.java,v 1.5 2008/12/16 01:48:32 exu Exp $
*
*/
/**
* The class <code>DSTClient</code> provides methods for Liberty
* Data Service Template.
*
* @supported.all.api
*/
public class DSTClient {
private boolean isEncryptedResourceID = false;
// default to anonymous
private boolean clientAuthEnabled = false;
/**
* Constructor
* The constructor connects to Data Service without <code>WSS</code> token
* @param soapURI URI of the SOAP end point for this Data service
* instance
* @param providerID ID of service provider.
*/
this.providerID = providerID;
}
/**
* Constructor
* The constructor connects to Data Service using <code>WSS</code>
* SAML Token
* @param assertion <code>WSS</code> SAML Token
* @param soapURI URI of the SOAP end point for this data
* service instance
* @param providerID ID of service provider.
*/
String providerID) {
this.providerID = providerID;
} else {
}
}
/**
* Constructor
* The constructor connects to the data Service using <code>WSS X509</code>
* Token.
*
* @param token <code>WSS X.509</code> Certificate Token
* @param soapURI URI of the SOAP end point for this Data
* service instance
* @param providerID ID of service provider.
*/
String providerID) {
this.providerID = providerID;
}
/**
* Constructor
* The constructor connects to Data Service without <code>WSS</code> token,
* the <code>HttpServletRequest</code> and <code>HttpServletResponse</code>
* object of the current request agent will be used for resource owner
* interactions if needed.
*
* @param soapURI URI of the SOAP end point for this Data
* service instance
* @param providerID ID of service provider.
* @param httpRequest <code>HttpServletRequest</code> object of current
* user agent request.
* @param httpResponse <code>HttpServletResponse</code> object of current
* user agent request.
*/
this.httpRequest = httpRequest;
this.httpResponse = httpResponse;
this.providerID = providerID;
}
/**
* Constructor
* The constructor connects to Data Service with <code>WSS</code>
* SAML token, the <code>HttpServletRequest</code> and
* <code>HttpServletResponse</code> object of the current request
* agent will be used for resource owner interactions if needed.
* @param assertion <code>WSS</code> SAML Token.
* @param soapURI URI of the SOAP end point for this Data service instance.
* @param providerID ID of service provider.
* @param httpRequest <code>HttpServletRequest</code> object of current
* user agent request.
* @param httpResponse <code>HttpServletResponse</code> object of current
* user agent request.
*/
this.httpRequest = httpRequest;
this.httpResponse = httpResponse;
this.providerID = providerID;
}
/**
* Constructor
* The constructor connects to Data Service with <code>WSS</code>
* SAML token, the <code>HttpServletRequest</code> and
* <code>HttpServletResponse</code> object of the current request
* agent will be used for resource owner interactions if needed.
* @param token <code>WSS X.509</code> Certificate Token
* @param soapURI URI of the SOAP end point for this Data
* service instance
* @param providerID ID of service provider.
* @param httpRequest <code>HttpServletRequest</code> object of current
* user agent request.
* @param httpResponse <code>HttpServletResponse</code> object of current
* user agent.
*/
this.httpRequest = httpRequest;
this.httpResponse = httpResponse;
this.providerID = providerID;
}
/**
* Contructor
* Creates a data service template client instance.
* Connects to data Service specified by the resource offering.
* <code>resourceID</code>, security mechanism and SOAP endpoint defined
* in the <code>ResourceOffering</code> will be used.
*
* @param resourceOffering resource offering for this
* discovery service instance
* @param providerID ID of this service provider.
* @param credential Credential of <code>WSC</code>
* @param httpRequest <code>HttpServletRequest</code> object of current
* user agent request.
* @param httpResponse <code>HttpServletResponse</code> object of current
* user agent.
* @exception DSTException if the <code>resourceOffering</code> is not valid
*/
public DSTClient(
) throws DSTException {
if(resourceOffering == null) {
throw new DSTException(
}
}
this.httpRequest = httpRequest;
this.httpResponse = httpResponse;
this.providerID = providerID;
}
/**
* Constructor
* Creates a data service template client instance.
* Connects to data Service specified by the resource offering.
* <code>resourceID</code>, security mechanism and SOAP endpoint defined
* in the <code>ResourceOffering</code> will be used.
*
* @param resourceOffering resource offering for this
* discovery service instance
* @param providerID ID of this service provider.
* @param credential Credential of <code>WSC</code>
* @exception DSTException if the <code>resourceOffering</code> is not valid
*/
throws DSTException {
if(resourceOffering == null) {
}
}
this.providerID = providerID;
}
/**
* Parses the given discovery resource offering for the Data service.
* @param offering ResourceOffering
* @exception DSTException.
*/
throws DSTException {
//Try for the encrypted resource offering first;
if(encryptedResourceID != null) {
isEncryptedResourceID = true;
} else {
"No ResourceID");
}
}
// providerID = serviceInstance.getProviderID();
if(serviceInstance == null) {
"No service instance.");
throw new DSTException(
}
if(serviceType == null) {
"service type is null.");
}
"descriptions are null.");
}
// A service instance can have mutiple descriptions. In this case,
// we will try to use a valid description.
continue;
}
continue;
}
boolean foundProfile = false;
for(int i=0; i < size; i++) {
clientAuthEnabled = true;
}
foundProfile = true;
break;
} else {
}
clientAuthEnabled = true;
}
foundProfile = true;
break;
} else {
}
clientAuthEnabled = true;
}
foundProfile = true;
break;
} else {
}
clientAuthEnabled = true;
}
foundProfile = true;
break;
}
}
if(foundProfile) {
break;
}
}
"SOAP Endpoint or security profile is null");
throw new DSTException(
}
"securityProfile = " + securityProfile);
}
}
/**
* Generates X509 security token for the WSC.
* @param credential Credential of WSC
* @exception DSTException
*/
throws DSTException {
try {
"com.sun.identity.liberty.ws.wsc.certalias");
}
} catch (Exception e) {
"Error in generating binary security token.", e);
throw new DSTException(e);
}
}
/**
* Sets the resource ID to be accessed
* @param resourceID resource ID String
*/
this.resourceID = resourceID;
isEncryptedResourceID = false;
}
/**
* Sets the encrypted resource ID to be accessed
* @param encResourceID encrypted resource ID
*/
this.encryptedResourceID = encResourceID;
isEncryptedResourceID = true;
}
/**
* Sets the provider ID.
* @param providerID Provider ID.
*/
this.providerID = providerID;
}
/**
* with client authentication.
*
* @param certAlias certificate alias name
*/
}
/**
* Sets SOAP Action such as query or modify
* @param action action for this soap request
*/
this.soapAction = action;
}
/**
* Sets the client authentication.
*
* @param value true value to enable client authentication.
*/
this.clientAuthEnabled = value;
}
/**
* Sets the SOAP Endpoint.
* @param endpoint SOAP Endpoint.
*/
}
/**
* Sets the Security Assertion.
* @param secAssertion Security Assertion.
*/
this.assertion = secAssertion;
}
/**
* Sets the binary security token.
* @param binaryToken Binary Security Token.
*/
this.token = binaryToken;
}
/**
* Sets the security mechanism.
* @param secMech security mechanism.
*/
}
}
/**
* Gets data for the specified query items.
* @param items list of <code>DSTQueryItem</code> object
* @return List of <code>DSTData</code> objects which have one-to-one
* correspondence to the list of query items. If no response for
* one of the query item, the corresponding return
* <code>DSTData</code> object will be null.
* @exception DSTException if error occurs when trying to get data
* @exception InteractionRedirectException if user agent is redirected to
* Web Service Provider (<code>WSP</code>) for resource owner
* interactions
*/
{
}
if(isEncryptedResourceID) {
} else {
}
return null;
}
return queryResponse.getData();
}
/**
* Gets <code>QueryResponse</code> for the specified query.
* @param query <code>DSTQuery</code> object.
* @return <code>DSTDQueryResponse</code> Object.
* @exception DSTException if error occurs when trying to get data
* @exception InteractionRedirectException if user agent is redirected to
* Web Service Provider (<code>WSP</code>) for resource owner
* interactions
*/
throws DSTException, InteractionRedirectException {
}
return new DSTQueryResponse(queryResponse);
}
/**
* Gets response for a list of <code>DST</code> Modifications.
* @param items List of <code>DSTModification</code> objects.
* @return <code>DSTModifyResponse</code>.
* @exception DSTException if error occurs when trying to modify data
* @exception InteractionRedirectException if user agent is redirected to
* Web Service Provider (<code>WSP</code>) for resource owner
* interactions.
*/
throws DSTException, InteractionRedirectException {
}
if(isEncryptedResourceID) {
} else {
}
return null;
}
}
/**
* Gets modify response for the specified modify.
* @param modify <code>DSTModify</code> object.
* @return <code>DSTModifyResponse</code> object.
* @exception DSTException if error occurs when trying to modify data
* @exception InteractionRedirectException if user agent is redirected to
* Web Service Provider (<code>WSP</code>) for resource owner
* interactions
*/
throws DSTException, InteractionRedirectException {
}
}
/**
* Gets query responses for a list of <code>DST</code> queries
* @param queries list of <code>DSTQuery</code> objects
* @return List of <code>DSTQueryResponse</code> objects, corresponding
* to each <code>DSTQuery</code> object.
* @exception DSTException if error occurs when trying to get data
* @exception InteractionRedirectException if interaction is required.
*/
{
}
}
}
}
return queryResponses;
}
/**
* Performs a list of modifications specified by a list of
* <code>DSTModify</code> objects (possible on different resource ID).
*
* @param modifies list of <code>DSTModify</code> objects specifying
* resource and modifications to be made.
* @return List of <code>DSTModifyResponse</code> object corresponding
* to each <code>DSTModify</code>.
* @exception DSTException if error occurs when trying to modify data
* @exception InteractionRedirectException if interaction is required.
*/
throws DSTException , InteractionRedirectException
{
}
}
}
}
return modifyResponses;
}
/**
* Sends the SOAP Message to the data service.
* @param List of Request Objects.
* @return List of Response Objects.
* @exception DSTException for failure.
*/
throws DSTException, InteractionRedirectException {
}
try {
if(providerID != null) {
}
throw new DSTException(
}
} else {
throw new DSTException(
}
if(clientAuthEnabled) {
}
}
if(httpRequest != null) {
} else {
}
}
} catch(SOAPBindingException sbe) {
throw new DSTException(sbe);
} catch(SOAPFaultException sfe) {
throw new DSTException(sfe);
}
}
/**
* Handles interaction request processing.
* When the interaction is required, it throws and InteractRedirect
* Exception, and redirect to the caller application(servlet).
*/
throws DSTException, SOAPFaultException,
throw new DSTException(
}
try {
//If the interaction is not required, this will send a
// original response.
} else {
}
return response;
} catch (InteractionRedirectException ire) {
"Redirection happened.");
throw ire;
} catch (InteractionException ie) {
" Error occured.", ie);
throw new DSTException(ie);
}
}
/**
* Gets the <code>serviceInstanceUpdate</code> header from the SOAP
* response message.
* Applications can make use of this method to check if there is an
* alternate endpoint or credential available for the service requests.
*
* @return <code>ServiceInstanceUpdateHeader</code> from the response
* message.
*/
return serviceInstanceUpdateHeader;
}
/**
* Sets the web services version.
*
* @param wsfVersion the web services version that needs to be set.
*/
this.wsfVersion = wsfVersion;
}
}