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

EntropyImpl

public class EntropyImpl extends com.sun.xml.ws.security.trust.impl.bindings.EntropyType implements com.sun.xml.ws.security.trust.elements.Entropy
Implementation of Entropy Interface.
author
Manveen Kaur

Fields Summary
private static final Logger
log
private String
entropyType
private static final QName
_EntropyType_QNAME
private com.sun.xml.ws.security.trust.elements.BinarySecret
binarySecret
private com.sun.xml.ws.security.EncryptedKey
encryptedKey
Constructors Summary
public EntropyImpl()

    
      
        //default constructor
    
public EntropyImpl(com.sun.xml.ws.security.trust.elements.BinarySecret binarySecret)

        setEntropyType(Entropy.BINARY_SECRET_TYPE);
        setBinarySecret(binarySecret);
    
public EntropyImpl(com.sun.xml.ws.security.EncryptedKey encryptedKey)

        setEntropyType(Entropy.ENCRYPTED_KEY_TYPE);
        setEncryptedKey(encryptedKey);
    
public EntropyImpl(com.sun.xml.ws.security.trust.impl.bindings.EntropyType etype)

        entropyType = etype.getOtherAttributes().get(_EntropyType_QNAME);
        final List list = etype.getAny();
        for (int i = 0; i < list.size(); i++) {
            final JAXBElement obj = (JAXBElement)list.get(i);
            final String local = obj.getName().getLocalPart();
            if (local.equalsIgnoreCase("BinarySecret")) {
                final BinarySecretType bst = (BinarySecretType) obj.getValue();
                setBinarySecret(new BinarySecretImpl(bst));
            }
        }
    
Methods Summary
public static com.sun.xml.ws.security.trust.impl.bindings.EntropyTypefromElement(org.w3c.dom.Element element)
Constructs a Entropy element from an existing XML block.

param
element A org.w3c.dom.Element representing DOM tree for Entropy 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 javax.xml.bind.Unmarshaller unmarshaller = WSTrustElementFactory.getContext().createUnmarshaller();
            return (EntropyType)unmarshaller.unmarshal(element);
        } 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.trust.elements.BinarySecretgetBinarySecret()
Gets the BinarySecret (if any) inside this Entropy

return
BinarySecret if set, null otherwise

        return binarySecret;
    
public com.sun.xml.ws.security.EncryptedKeygetEncryptedKey()
Gets the xenc:EncryptedKey set inside this Entropy instance

return
xenc:EncryptedKey if set, null otherwise

        return encryptedKey;
    
public java.lang.StringgetEntropyType()
Gets the type of the Entropy contents

        return entropyType;
    
public final voidsetBinarySecret(com.sun.xml.ws.security.trust.elements.BinarySecret binarySecret)
Sets the BinarySecret (if any) inside this Entropy

        if (binarySecret != null) {
            this.binarySecret = binarySecret;
            final JAXBElement<BinarySecretType> bsElement =
                    (new ObjectFactory()).createBinarySecret((BinarySecretType)binarySecret);
            getAny().add(bsElement);
        }
    
public final voidsetEncryptedKey(com.sun.xml.ws.security.EncryptedKey encryptedKey)
Sets the xenc:EncryptedKey set inside this Entropy instance

        if (encryptedKey != null) {
            this.encryptedKey = encryptedKey;
            getAny().add(encryptedKey);
        }
    
public final voidsetEntropyType(java.lang.String type)
Sets the type of the Entropy contents

        if (!(type.equalsIgnoreCase(this.BINARY_SECRET_TYPE)  ||
                type.equalsIgnoreCase(this.CUSTOM_TYPE)
                || type.equalsIgnoreCase(this.ENCRYPTED_KEY_TYPE))) {
            log.log(Level.SEVERE,
                    LogStringsMessages.WST_0022_INVALID_ENTROPY(type));
            throw new RuntimeException(LogStringsMessages.WST_0022_INVALID_ENTROPY(type));
        }
        entropyType = type;
        getOtherAttributes().put(_EntropyType_QNAME,type);