/**
* 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: DiscoveryClient.java,v 1.5 2008/12/16 01:48:31 exu Exp $
*
*/
/**
* The class <code>DiscoveryClient</code> provides methods to send
* Discovery Service query and modify.
* Note: Current implementation uses <code>JAXB</code> objects and no wrapper
* classes are used.
* @supported.all.api
*/
public class DiscoveryClient {
private boolean clientAuth = false;
private boolean processed = true;
/**
* Constructor, connects to Discovery Service without web service security
* token.
*
* @param soapURI URI of the SOAP end point for this discovery
* service instance
* @param providerID ID of the web service client.
*/
this.providerID = providerID;
}
/**
* Constructor, connects to Discovery Service using <code>WSS</code> SAML
* Token.
*
* @param assertion <code>WSS</code> SAML Token
* @param soapURI URI of the SOAP end point for this discovery
* service instance
* @param providerID ID of the web service client.
*/
{
} else {
}
this.providerID = providerID;
}
/**
* Constructor, connects to Discovery 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 discovery
* service instance.
* @param providerID ID of the web service client.
*/
{
this.providerID = providerID;
}
/**
* Constructor, connects to Discovery Service specified by the resource
* <code>ResourceOffering</code> will be used.
*
* @param resourceOffering resource offering for this
* discovery service instance
* @param session session of the <code>WSC</code>
* @param providerID ID of the web service client.
*/
{
processed = false;
this.providerID = providerID;
}
/**
* Constructor, connects to Discovery Service specified by the resource
* <code>ResourceOffering</code> will be used.
*
* @param resourceOffering resource offering for this
* discovery service instance
* @param session session of the <code>WSC</code>
* @param providerID ID of the web service client.
* @param assertions List of assertions.
*/
{
processed = false;
this.providerID = providerID;
this.assertions = assertions;
}
"ServiceType in ResourceOffering is not discovery service type.");
throw new DiscoveryException(
}
/*
* Iterate through supported security profiles until we find one
* that we support (and we should always do so if the spec is
* being complied with). They should be in decreasing order of
* preference...
*/
// TODO: support wsdl form
while (i.hasNext()) {
while (j.hasNext()) {
{
clientAuth = true;
}
return;
{
} else {
}
try {
"com.sun.identity.liberty.ws.wsc.certalias");
}
} catch (Exception e) {
+ "Offering: couldn't generate X509 token: ", e);
throw new DiscoveryException(e.getMessage());
}
clientAuth = true;
}
return;
{
} else {
}
throw new DiscoveryException(
} else {
if (assertions == null) {
throw new DiscoveryException(
} else {
break;
}
}
throw new DiscoveryException(
}
}
}
clientAuth = true;
}
return;
{
} else {
}
throw new DiscoveryException(
} else {
throw new DiscoveryException(
} else {
break;
}
}
throw new DiscoveryException(
}
}
}
clientAuth = true;
}
return;
}
}
}
// still here? couldn't find supported mech id
"Couldn't find supported SecurityMechID from ResourceOffering.");
throw new DiscoveryException(
}
/**
* Sets the alias for the client certificate. If none is set, a default
* client certificate will be used.
* @param certAlias certificate alias name
*/
}
/**
* authentication. When this flag is set to true, the message will not be
* signed according to the spec. If you want to sign the message always,
* client authentication.
*
* @param value The flag value to be set
*/
clientAuth = value;
}
/**
* Sets the resource ID to be accessed.
* @param resourceID resource ID
*/
}
/**
* Sets the encrypted resource ID to be accessed.
*
* @param resourceID encrypted resource ID.
*/
}
/**
* Sets the provider ID.
*
* @param providerID ID of the web service client.
*/
this.providerID = providerID;
}
/**
* Queries discovery service for <code>ResourceOffering</code> given list of
* service types.
*
* @param serviceTypes List of <code>serviceTypes</code> as
* <code>java.lang.String</code> to be queried
* @return Query response Element corresponding to the query
* @exception DiscoveryException if error occurs
*/
throws DiscoveryException
{
if (!processed) {
processed = true;
}
while (i.hasNext()) {
}
} else {
}
return getResourceOffering(query);
}
/**
* Queries discovery service for resource offering.
* @param query discovery query object
* @return Query response Element corresponding to the query
* @exception DiscoveryException if error occurs
*/
throws DiscoveryException
{
}
if (!processed) {
processed = true;
}
// create new Message according to different secuMechID
if (providerID != null) {
try {
} catch (SOAPBindingException sbe) {
}
}
"DiscoveryClient.createRequest: mech=x509");
try {
} catch (SOAPBindingException sbe) {
}
+ "mech=saml or bearer");
}
try {
} catch (SOAPBindingException sbe) {
}
} else {
+ "mech=anon");
}
try {
} catch (SOAPBindingException sbe) {
}
}
if (clientAuth) {
}
return req;
}
try {
} catch (Exception e) {
throw new DiscoveryException(e.getMessage());
}
+ "didn't contain one SOAPBody.");
throw new DiscoveryException(
}
}
/**
* Modifies discovery resource offering.
* @param modify List of Modify object
* @return List of <code>ModifyResponse</code> object
* @exception DiscoveryException if error occurs
*/
throws DiscoveryException
{
}
/**
* Sets the web services version.
*
* @param wsfVersion the web services version that should be used.
*/
this.wsfVersion = wsfVersion;
}
}