FileDocCategorySizeDatePackage
SecurityContextTokenImpl.javaAPI DocExample7223Tue May 29 16:56:54 BST 2007com.sun.xml.ws.security.secconv.impl.elements

SecurityContextTokenImpl

public class SecurityContextTokenImpl extends com.sun.xml.ws.security.secconv.impl.bindings.SecurityContextTokenType implements com.sun.xml.ws.security.SecurityContextToken
SecurityContextToken Implementation
author
Manveen Kaur manveen.kaur@sun.com

Fields Summary
private String
instance
private URI
identifier
private List
extElements
private static final Logger
log
Constructors Summary
public SecurityContextTokenImpl()

    
      
        // empty c'tor
    
public SecurityContextTokenImpl(URI identifier, String instance, String wsuId)

        if (identifier != null) {
            setIdentifier(identifier);
        }
        if (instance != null) {
            setInstance(instance);
        }
        
        if (wsuId != null){
            setWsuId(wsuId);
        }
    
public SecurityContextTokenImpl(com.sun.xml.ws.security.secconv.impl.bindings.SecurityContextTokenType sTokenType)

        final List<Object> list = sTokenType.getAny();
        for (int i = 0; i < list.size(); i++) {
            final Object object = list.get(i);
            if(object instanceof JAXBElement){
                final JAXBElement obj = (JAXBElement)object;
                
                final String local = obj.getName().getLocalPart();
                if (local.equalsIgnoreCase("Instance")) {
                    setInstance((String)obj.getValue());
                } else if (local.equalsIgnoreCase("Identifier")){
                    setIdentifier(URI.create((String)obj.getValue()));
                }
            }else{
                getAny().add(object);
                if(extElements == null){
                    extElements = new ArrayList<Object>();
                    extElements.add(object);
                }
            }
        }
        
        setWsuId(sTokenType.getId());
    
Methods Summary
public java.util.ListgetExtElements()

        return extElements;
    
public java.net.URIgetIdentifier()

        return identifier;
    
public java.lang.StringgetInstance()

        return instance;
    
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<SecurityContextTokenType> tElement =  (new ObjectFactory()).createSecurityContextToken((SecurityContextTokenType)this);
            marshaller.marshal(tElement, doc);
            return doc.getDocumentElement();
            
        } catch (Exception ex) {
            log.log(Level.SEVERE, 
                    LogStringsMessages.WSSC_0019_ERR_TOKEN_VALUE(), ex);
            throw new RuntimeException(LogStringsMessages.WSSC_0019_ERR_TOKEN_VALUE(), ex);
        }
    
public java.lang.StringgetType()

        return WSSCConstants.SECURITY_CONTEXT_TOKEN;
    
public java.lang.StringgetWsuId()

        return getId();
    
public final voidsetIdentifier(java.net.URI identifier)

        this.identifier = identifier;
        final JAXBElement<String> iElement =
                (new ObjectFactory()).createIdentifier(identifier.toString());
        getAny().add(iElement);
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE,
                    LogStringsMessages.WSSC_1004_SECCTX_TOKEN_ID_VALUE(identifier.toString()));
        }
    
public final voidsetInstance(java.lang.String instance)

        this.instance = instance;
        final JAXBElement<String> iElement =
                (new ObjectFactory()).createInstance(instance);
        getAny().add(iElement);
    
public final voidsetWsuId(java.lang.String wsuId)

        setId(wsuId);
        if (log.isLoggable(Level.FINE)) {
            log.log(Level.FINE,
                    LogStringsMessages.WSSC_1005_SECCTX_TOKEN_WSUID_VALUE(wsuId));
        }