FileDocCategorySizeDatePackage
WSTrustUtil.javaAPI DocExample9130Tue May 29 16:57:04 BST 2007com.sun.xml.ws.security.trust.util

WSTrustUtil

public class WSTrustUtil extends Object
author
ws-trust-implementation-team

Fields Summary
public static final String
MEX_NS
public static final String
Metadata
public static final String
MetadataSection
public static final String
MetadataReference
Constructors Summary
private WSTrustUtil()

        //private constructor
    
Methods Summary
public static com.sun.xml.ws.policy.impl.bindings.AppliesTocreateAppliesTo(java.lang.String appliesTo)

       final AttributedURI uri = new AttributedURI();
       uri.setValue(appliesTo);
       final EndpointReference epr = new EndpointReference();
       epr.setAddress(uri);
       final AppliesTo applTo = (new com.sun.xml.ws.policy.impl.bindings.ObjectFactory()).createAppliesTo();
       applTo.getAny().add((new com.sun.xml.ws.security.trust.impl.bindings.ObjectFactory()).createEndpointReference(epr));
       
       return applTo;
   
public static javax.xml.soap.SOAPFaultcreateSOAP11Fault(com.sun.xml.ws.security.trust.WSTrustSOAPFaultException sfex)
create and return a SOAP 1.1 Fault corresponding to this exception

        
        throw new UnsupportedOperationException("To Do");
    
public static javax.xml.soap.SOAPFaultcreateSOAP12Fault(com.sun.xml.ws.security.trust.WSTrustSOAPFaultException sfex)
create and return a SOAP 1.2 Fault corresponding to this exception

        
        throw new UnsupportedOperationException("To Do");
    
public static com.sun.xml.ws.security.SecurityContextTokencreateSecurityContextToken(com.sun.xml.ws.security.secconv.WSSCElementFactory eleFac)

       final String identifier = "urn:uuid:" + UUID.randomUUID().toString();
       URI idURI;
       try{
           idURI = new URI(identifier);
       }catch (URISyntaxException ex){
           throw new WSSecureConversationException(ex.getMessage(), ex);
       }
       final String wsuId = "uuid-" + UUID.randomUUID().toString();
       
       return eleFac.createSecurityContextToken(idURI, null, wsuId);
   
public static byte[]generateRandomSecret(int keySize)

        
        // Create binary secret
        final SecureRandom random = new SecureRandom();
        final byte[] secret = new byte[(int)keySize];
        random.nextBytes(secret);
        return secret;
    
public static java.lang.StringgetAppliesToURI(com.sun.xml.ws.policy.impl.bindings.AppliesTo appliesTo)

       final List list = appliesTo.getAny();
       EndpointReference epr = null;
       if (!list.isEmpty()){
            for (int i = 0; i < list.size(); i++) {
                final Object obj = list.get(i);
                if (obj instanceof EndpointReference){
                    epr = (EndpointReference)obj;
                } else if (obj instanceof JAXBElement){
                    final JAXBElement ele = (JAXBElement)obj;    
                    final String local = ele.getName().getLocalPart();
                    if (local.equalsIgnoreCase("EndpointReference")) {
                        epr = (EndpointReference)ele.getValue();
                    }
                }
                
                if (epr != null){
                    final AttributedURI uri = epr.getAddress();
                    if (uri != null){
                        return uri.getValue();
                    }
                }
            }
        }
        return null;
    
public static booleanisAddressingMetadata(com.sun.xml.ws.policy.PolicyAssertion assertion)

        if ( !PolicyUtil.isAddressingNS(assertion)) {
            return false;
        }
        
        if ( assertion.getName().getLocalPart().equals(Metadata)) {
            return true;
        }        
        return false;
    
public static booleanisMEXNS(com.sun.xml.ws.policy.PolicyAssertion assertion)

    
          
        if ( MEX_NS.equals(assertion.getName().getNamespaceURI()) ) {
            return true;
        }
        return false;
    
public static booleanisMetadata(com.sun.xml.ws.policy.PolicyAssertion assertion)

        if ( !isMEXNS(assertion)) {
            return false;
        }
        
        if ( assertion.getName().getLocalPart().equals(Metadata)) {
            return true;
        }
        
        return false;
    
public static booleanisMetadataReference(com.sun.xml.ws.policy.PolicyAssertion assertion)

        if ( !isMEXNS(assertion)) {
            return false;
        }
        
        if ( assertion.getName().getLocalPart().equals(MetadataReference)) {
            return true;
        }
        
        return false;
    
public static booleanisMetadataSection(com.sun.xml.ws.policy.PolicyAssertion assertion)

        if ( !isMEXNS(assertion)) {
            return false;
        }
        
        if ( assertion.getName().getLocalPart().equals(MetadataSection)) {
            return true;
        }
        
        return false;