FileDocCategorySizeDatePackage
SecurityTokenReferenceImpl.javaAPI DocExample5573Tue May 29 16:57:02 BST 2007com.sun.xml.ws.security.trust.impl.elements.str

SecurityTokenReferenceImpl

public class SecurityTokenReferenceImpl extends com.sun.xml.ws.security.secext10.SecurityTokenReferenceType implements com.sun.xml.ws.security.trust.elements.str.SecurityTokenReference
SecurityTokenReference implementation

Fields Summary
Constructors Summary
public SecurityTokenReferenceImpl(com.sun.xml.ws.security.trust.elements.str.Reference ref)

        setReference(ref);
    
public SecurityTokenReferenceImpl(com.sun.xml.ws.security.secext10.SecurityTokenReferenceType strType)

        final Reference ref = getReference(strType);
        setReference(ref);
    
Methods Summary
public com.sun.xml.ws.security.trust.elements.str.ReferencegetReference()

        return getReference((SecurityTokenReferenceType)this);
    
private com.sun.xml.ws.security.trust.elements.str.ReferencegetReference(com.sun.xml.ws.security.secext10.SecurityTokenReferenceType strType)

        final List<Object> list = strType.getAny();
        final JAXBElement obj = (JAXBElement)list.get(0);
        final String local = obj.getName().getLocalPart();
        //final Reference ref = null;
        if (REFERENCE.equals(local)) {
            return new DirectReferenceImpl((ReferenceType)obj.getValue());
        }
            
        if (KEYIDENTIFIER.equalsIgnoreCase(local)) {
            return new KeyIdentifierImpl((KeyIdentifierType)obj.getValue());
        }
            
        //ToDo
        return null;       
    
public java.lang.ObjectgetTokenValue()

        try {
            final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            final DocumentBuilder builder = dbf.newDocumentBuilder();
            final Document doc = builder.newDocument();
            
            final javax.xml.bind.Marshaller marshaller = WSTrustElementFactory.getContext().createMarshaller();
            final JAXBElement<SecurityTokenReferenceType> rstElement =  (new ObjectFactory()).createSecurityTokenReference((SecurityTokenReferenceType)this);
            marshaller.marshal(rstElement, doc);
            return doc.getDocumentElement();
            
        } catch (Exception ex) {
            throw new RuntimeException(ex.getMessage(), ex);
        }
    
public java.lang.StringgetType()

        return WSTrustConstants.STR_TYPE;
    
public final voidsetReference(com.sun.xml.ws.security.trust.elements.str.Reference ref)

        
        JAXBElement rElement = null;
        final String type = ref.getType();
        final ObjectFactory objFac = new ObjectFactory();
        if (KEYIDENTIFIER.equals(type)){
            rElement = objFac.createKeyIdentifier((KeyIdentifierType)ref);
        }
        else if (REFERENCE.equals(type)){
            rElement = objFac.createReference((ReferenceType)ref);
        }else{
            //ToDo
        }
        
        if (rElement != null){
            getAny().clear();
            getAny().add(rElement);
        }