FileDocCategorySizeDatePackage
RequestedSecurityTokenImpl.javaAPI DocExample7478Tue May 29 16:57:00 BST 2007com.sun.xml.ws.security.trust.impl.elements

RequestedSecurityTokenImpl

public class RequestedSecurityTokenImpl extends com.sun.xml.ws.security.trust.impl.bindings.RequestedSecurityTokenType implements com.sun.xml.ws.security.trust.elements.RequestedSecurityToken
Implementation for the RequestedSecurityToken.
author
Manveen Kaur

Fields Summary
private static final Logger
log
com.sun.xml.ws.security.Token
containedToken
private static final QName
SCT_QNAME
Constructors Summary
public RequestedSecurityTokenImpl()
Empty default constructor.

    
    //private final static QName SAML11_Assertion_QNAME = 
      //      new QName("urn:oasis:names:tc:SAML:1.0:assertion", "Assertion");
    
    //private final static QName EncryptedData_QNAME = new QName("http://www.w3.org/2001/04/xmlenc#", "EncryptedData");
    
             
      
        //Empty default constructor.
    
public RequestedSecurityTokenImpl(com.sun.xml.ws.security.trust.impl.bindings.RequestedSecurityTokenType rdstType)

        final Object rdst = rdstType.getAny();
        if (rdst instanceof JAXBElement){
            final JAXBElement rdstEle = (JAXBElement)rdst; 
           final QName name = rdstEle.getName();
            if(SCT_QNAME.equals(name)){
                final SecurityContextTokenType sctType = (SecurityContextTokenType)rdstEle.getValue();
                setToken(new SecurityContextTokenImpl(sctType));
            }/*else if(EncryptedData_QNAME.equals(name)){
               EncryptedDataType edType = (EncryptedDataType)rdstEle.getValue();
               setToken(edType);  
            }else if(SAML11_Assertion_QNAME.equals(name)){
                AssertionType assertionType = (AssertionType)rdstEle.getValue();
                setToken(new Assertion(assertionType));
            }*/
            else{
                setAny(rdstEle);
                containedToken = new GenericToken((Element)rdstEle.getValue());
            }
        }
        else{
            setToken(new GenericToken((Element)rdst));
        }
    
public RequestedSecurityTokenImpl(com.sun.xml.ws.security.Token token)

        setToken(token);
    
Methods Summary
public static com.sun.xml.ws.security.trust.impl.bindings.RequestedSecurityTokenTypefromElement(org.w3c.dom.Element element)
Constructs a RequestedSecurityToken element from an existing XML block.

param
requestedSecurityTokenElement A org.w3c.dom.Element representing DOM tree for RequestedSecurityToken object.
exception
WSTrustException if it could not process the org.w3c.dom.Element properly, implying that there is an error in the sender or in the element definition.

        try {
            final JAXBContext context =
                WSTrustElementFactory.getContext();
            final javax.xml.bind.Unmarshaller unmarshaller = context.createUnmarshaller();
            
            return unmarshaller.unmarshal(element, RequestedSecurityTokenType.class).getValue();
        } catch (JAXBException ex) {
            log.log(Level.SEVERE,
                    LogStringsMessages.WST_0021_ERROR_UNMARSHAL_DOM_ELEMENT(), ex);                        
            throw new WSTrustException(LogStringsMessages.WST_0021_ERROR_UNMARSHAL_DOM_ELEMENT(), ex);
        }
    
public com.sun.xml.ws.security.TokengetToken()

        return containedToken;
    
public final voidsetToken(com.sun.xml.ws.security.Token token)

        if (token != null)  {
            final String tokenType = token.getType();
            if (WSSCConstants.SECURITY_CONTEXT_TOKEN.equals(tokenType)){
                final JAXBElement<SecurityContextTokenType> sctElement =
                (new com.sun.xml.ws.security.secconv.impl.bindings.ObjectFactory()).createSecurityContextToken((SecurityContextTokenType)token);
                setAny(sctElement);
            }else {
                final Element element = (Element)token.getTokenValue();
                setAny(element);
            }
        }
        containedToken = token;