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

RequestSecurityTokenImpl

public class RequestSecurityTokenImpl extends com.sun.xml.ws.security.trust.impl.bindings.RequestSecurityTokenType implements RequestSecurityToken
Implementation of the RequestSecurityToken interface.
author
Manveen Kaur

Fields Summary
private static final Logger
log
private com.sun.xml.ws.api.security.trust.Claims
claims
private Participants
participants
private URI
tokenType
private URI
requestType
private long
keySize
private URI
keyType
private URI
computedKeyAlgorithm
private URI
signWith
private URI
encryptWith
private URI
authenticationType
private URI
signatureAlgorithm
private URI
encryptionAlgorithm
private URI
canonAlgorithm
private Lifetime
lifetime
private Entropy
entropy
private com.sun.xml.ws.policy.impl.bindings.AppliesTo
appliesTo
private OnBehalfOf
obo
private SignChallenge
signChallenge
private Encryption
encryption
private UseKey
useKey
private DelegateTo
delegateTo
private RenewTarget
renewTarget
private CancelTarget
cancelTarget
private AllowPostdating
apd
private BinaryExchange
binaryExchange
private Issuer
issuer
private Renewing
renewable
private ProofEncryption
proofEncryption
private boolean
forwardable
private boolean
delegatable
private com.sun.xml.ws.policy.Policy
policy
private com.sun.xml.ws.policy.impl.bindings.PolicyReference
policyRef
Constructors Summary
public RequestSecurityTokenImpl()

    
      
        setRequestType(URI.create(WSTrustConstants.ISSUE_REQUEST));
    
public RequestSecurityTokenImpl(URI tokenType, URI requestType)

        setTokenType(tokenType);
        setRequestType(requestType);
    
public RequestSecurityTokenImpl(URI tokenType, URI requestType, URI context, com.sun.xml.ws.policy.impl.bindings.AppliesTo scopes, com.sun.xml.ws.api.security.trust.Claims claims, Entropy entropy, Lifetime lifetime, URI algorithm)

        setTokenType(tokenType);
        setRequestType(requestType);
        if (context != null) {
            setContext(context.toString());
        }
        if (scopes != null) {
            setAppliesTo(scopes);
        }
        if (claims != null) {
            setClaims(claims);
        }
        if (entropy !=null) {
            setEntropy(entropy);
        }
        if (lifetime!=null) {
            setLifetime(lifetime);
        }
        if (algorithm !=null) {
            setComputedKeyAlgorithm(algorithm);
        }
    
public RequestSecurityTokenImpl(URI tokenType, URI requestType, URI context, RenewTarget target, AllowPostdating apd, Renewing renewingInfo)

        setTokenType(tokenType);
        setRequestType(requestType);
        if (context != null) {
            setContext(context.toString());
        }
        if (context != null) {
            setContext(context.toString());
        }
        if (target != null) {
            setRenewTarget(target);
        }
        if (apd != null) {
            setAllowPostdating(apd);
        }
        if (renewingInfo != null) {
            setRenewable(renewingInfo);
        }
    
public RequestSecurityTokenImpl(URI tokenType, URI requestType, CancelTarget cancel)

        setTokenType(tokenType);
        setRequestType(requestType);
        setCancelTarget(cancel);
    
public RequestSecurityTokenImpl(com.sun.xml.ws.security.trust.impl.bindings.RequestSecurityTokenType rstType)

        this.context = rstType.getContext();
        final List<Object> list = rstType.getAny();
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i) instanceof AppliesTo){
                setAppliesTo((AppliesTo)list.get(i));
                continue;
            }
            if (list.get(i) instanceof JAXBElement){
                final JAXBElement obj = (JAXBElement)list.get(i);
                
                final String local = obj.getName().getLocalPart();
                if (local.equalsIgnoreCase("RequestType")) {
                    setRequestType(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("KeySize")) {
                    setKeySize((Long)obj.getValue());
                } else if (local.equalsIgnoreCase("KeyType")){
                    setKeyType(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("ComputedKeyAlgorithm")){
                    setComputedKeyAlgorithm(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("TokenType")){
                    setTokenType(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("AuthenticationType")){
                    setAuthenticationType(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("Lifetime")){
                    final LifetimeType ltType = (LifetimeType)obj.getValue();
                    setLifetime(new LifetimeImpl(ltType.getCreated(), ltType.getExpires()));
                } else if (local.equalsIgnoreCase("Entropy")){
                    final EntropyType eType = (EntropyType)obj.getValue();
                    setEntropy(new EntropyImpl(eType));
                } else if (local.equalsIgnoreCase("Forwardable")){
                    setForwardable((Boolean)obj.getValue());
                } else if (local.equalsIgnoreCase("Delegatable")){
                    setDelegatable((Boolean)obj.getValue());
                } else if (local.equalsIgnoreCase("SignWith")){
                    setSignWith(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("EncryptWith")){
                    setEncryptWith(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("SignatureAlgorithm")){
                    setSignatureAlgorithm(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("EncryptionAlgorithm")){
                    setEncryptionAlgorithm(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("CanonicalizationAlgorithm")){
                    setCanonicalizationAlgorithm(new URI((String)obj.getValue()));
                } else if (local.equalsIgnoreCase("AllowPostdating")){
                    setAllowPostdating(new AllowPostdatingImpl());
                }  else if (local.equalsIgnoreCase("SignChallenge")){
                    setSignChallenge(new SignChallengeImpl());
                }else if (local.equalsIgnoreCase("BinaryExchange")){
                    final BinaryExchangeType bcType = (BinaryExchangeType)obj.getValue();
                    setBinaryExchange(new BinaryExchangeImpl(bcType));
                } else if (local.equalsIgnoreCase("Issuer")){
                   // EndpointReferenceImpl isType = (EndpointReferenceImpl)obj.getValue();
                   // setIssuer(new IssuerImpl(isType));
                } else if (local.equalsIgnoreCase("Claims")){
                    final ClaimsType cType = (ClaimsType)obj.getValue();
                    setClaims(new ClaimsImpl(cType));
                } else if (local.equalsIgnoreCase("Participants")){
                    final ParticipantsType psType = (ParticipantsType)obj.getValue();
                    setParticipants(new ParticipantsImpl(psType));
                } else if (local.equalsIgnoreCase("Renewing")){
                    setRenewable(new RenewingImpl());
                } else if (local.equalsIgnoreCase("ProofEncryption")){
                    final ProofEncryptionType peType = (ProofEncryptionType)obj.getValue();
                    setProofEncryption(new ProofEncryptionImpl(peType));
                } else if (local.equalsIgnoreCase("Policy")){
                    setPolicy((Policy)obj.getValue());
                } else if (local.equalsIgnoreCase("PolicyReference")){
                    setPolicyReference((PolicyReference)obj.getValue());
                } else if (local.equalsIgnoreCase("AppliesTo")){
                    setAppliesTo((AppliesTo)obj.getValue());
                } else if (local.equalsIgnoreCase("OnBehalfOf")){
                    final OnBehalfOfType oboType = (OnBehalfOfType)obj.getValue();
                    setOnBehalfOf(new OnBehalfOfImpl(oboType));
                } else if (local.equalsIgnoreCase("Encryption")){
                    final EncryptionType encType = (EncryptionType)obj.getValue();
                    setEncryption(new EncryptionImpl(encType));
                } else if (local.equalsIgnoreCase("UseKey")){
                    final UseKeyType ukType = (UseKeyType)obj.getValue();
                    setUseKey(new UseKeyImpl(ukType));
                } else if (local.equalsIgnoreCase("DelegateTo")){
                    final DelegateToType dtType  = (DelegateToType)obj.getValue();
                    setDelegateTo(new DelegateToImpl(dtType));
                } else if (local.equalsIgnoreCase("RenewTarget")){
                    final RenewTargetType rtType = (RenewTargetType)obj.getValue();
                    setRenewTarget(new RenewTargetImpl(rtType));
                } else if (local.equalsIgnoreCase("CancelTarget")){
                    final CancelTargetType ctType = (CancelTargetType)obj.getValue();
                    setCancelTarget(new CancelTargetImpl(ctType));
                } else if (local.equalsIgnoreCase("AppliesTo")) {
                    setAppliesTo((AppliesTo)obj.getValue());
                }
            }
        }
    
Methods Summary
public AllowPostdatinggetAllowPostdating()

        return apd;
    
public com.sun.xml.ws.policy.impl.bindings.AppliesTogetAppliesTo()

        return appliesTo;
    
public java.net.URIgetAuthenticationType()

        return authenticationType;
    
public BinaryExchangegetBinaryExchange()

        return binaryExchange;
    
public CancelTargetgetCancelTarget()

        return cancelTarget;
    
public java.net.URIgetCanonicalizationAlgorithm()

        return canonAlgorithm;
    
public com.sun.xml.ws.api.security.trust.ClaimsgetClaims()

        return claims;
    
public java.net.URIgetComputedKeyAlgorithm()

        return computedKeyAlgorithm;
    
public booleangetDelegatable()

        return delegatable;
    
public DelegateTogetDelegateTo()

        return delegateTo;
    
public java.net.URIgetEncryptWith()

        return encryptWith;
    
public EncryptiongetEncryption()

        return encryption;
    
public java.net.URIgetEncryptionAlgorithm()

        return encryptionAlgorithm;
    
public EntropygetEntropy()

        return entropy;
    
public booleangetForwardable()

        return forwardable;
    
public IssuergetIssuer()

        return issuer;
    
public longgetKeySize()

        return keySize;
    
public java.net.URIgetKeyType()

        return keyType;
    
public LifetimegetLifetime()

        return lifetime;
    
public OnBehalfOfgetOnBehalfOf()

        return obo;
    
public ParticipantsgetParticipants()

        return participants;
    
public com.sun.xml.ws.policy.PolicygetPolicy()

        return policy;
    
public com.sun.xml.ws.policy.impl.bindings.PolicyReferencegetPolicyReference()

        return policyRef;
    
public ProofEncryptiongetProofEncryption()

        return proofEncryption;
    
public RenewTargetgetRenewTarget()

        return renewTarget;
    
public RenewinggetRenewable()

        return renewable;
    
public java.net.URIgetRequestType()

        return requestType;
    
public SignChallengegetSignChallenge()

        return signChallenge;
    
public java.net.URIgetSignWith()

        return signWith;
    
public java.net.URIgetSignatureAlgorithm()

        return signatureAlgorithm;
    
public java.net.URIgetTokenType()

        return tokenType;
    
public UseKeygetUseKey()

        return useKey;
    
public final voidsetAllowPostdating(AllowPostdating allowPostdating)

        apd = allowPostdating;
        final JAXBElement<AllowPostdatingType> allowPd =
                (new ObjectFactory()).createAllowPostdating((AllowPostdatingType)apd);
        getAny().add(allowPd);
    
public final voidsetAppliesTo(com.sun.xml.ws.policy.impl.bindings.AppliesTo appliesTo)

        getAny().add(appliesTo);
        this.appliesTo = appliesTo;
    
public final voidsetAuthenticationType(java.net.URI uri)

        this.authenticationType = uri;
        final JAXBElement<String> atElement =
                (new ObjectFactory()).createAuthenticationType(uri.toString());
        getAny().add(atElement);
    
public final voidsetBinaryExchange(BinaryExchange exchange)

        binaryExchange = exchange;
        final JAXBElement<BinaryExchangeType> exchangeType =
                (new ObjectFactory()).createBinaryExchange((BinaryExchangeType)exchange);
        getAny().add(exchangeType);
    
public final voidsetCancelTarget(CancelTarget cTarget)

        this.cancelTarget = cTarget;
        final JAXBElement<CancelTargetType> ctElement =
                (new ObjectFactory()).createCancelTarget((CancelTargetType)cTarget);
        getAny().add(ctElement);
    
public final voidsetCanonicalizationAlgorithm(java.net.URI algorithm)

        canonAlgorithm = algorithm;
        final JAXBElement<String> canonElement =
                (new ObjectFactory()).createCanonicalizationAlgorithm(algorithm.toString());
        getAny().add(canonElement);
    
public final voidsetClaims(com.sun.xml.ws.api.security.trust.Claims claims)

        this.claims = claims;
        final JAXBElement<ClaimsType> cElement =
                (new ObjectFactory()).createClaims((ClaimsType)claims);
        getAny().add(cElement);
    
public final voidsetComputedKeyAlgorithm(java.net.URI algorithm)

        
        if (algorithm != null) {
            final String ckaString = algorithm.toString();
            if (!ckaString.equalsIgnoreCase(WSTrustConstants.CK_HASH)
            && !ckaString.equalsIgnoreCase(WSTrustConstants.CK_PSHA1)) {
                log.log(Level.SEVERE,
                        LogStringsMessages.WST_0026_INVALID_CK_ALGORITHM(ckaString));
                throw new RuntimeException(LogStringsMessages.WST_0026_INVALID_CK_ALGORITHM(ckaString));
            }
            computedKeyAlgorithm = algorithm;
            final JAXBElement<String> ckaElement =
                    (new ObjectFactory()).createComputedKeyAlgorithm(ckaString);
            getAny().add(ckaElement);
        }
    
public final voidsetDelegatable(boolean flag)

        delegatable = flag;
        final JAXBElement<Boolean> del =
                (new ObjectFactory()).createDelegatable(flag);
        getAny().add(del);
    
public final voidsetDelegateTo(DelegateTo delegateTo)

        this.delegateTo = delegateTo;
        final JAXBElement<DelegateToType> dtElement =
                (new ObjectFactory()).createDelegateTo((DelegateToType)delegateTo);
        getAny().add(dtElement);
    
public final voidsetEncryptWith(java.net.URI algorithm)

        encryptWith = algorithm;
        final JAXBElement<String> sElement =  (new ObjectFactory()).createEncryptWith(algorithm.toString());
        getAny().add(sElement);
    
public final voidsetEncryption(Encryption enc)

        this.encryption = enc;
        final JAXBElement<EncryptionType> encElement =
                (new ObjectFactory()).createEncryption((EncryptionType)enc);
        getAny().add(encElement);
    
public final voidsetEncryptionAlgorithm(java.net.URI algorithm)

        encryptionAlgorithm = algorithm;
        final JAXBElement<String> encElement =
                (new ObjectFactory()).createEncryptionAlgorithm(algorithm.toString());
        getAny().add(encElement);
    
public final voidsetEntropy(Entropy entropy)

        this.entropy = entropy;
        final JAXBElement<EntropyType> etElement =
                (new ObjectFactory()).createEntropy((EntropyType)entropy);
        getAny().add(etElement);
    
public final voidsetForwardable(boolean flag)

        forwardable = flag;
        final JAXBElement<Boolean> forward =
                (new ObjectFactory()).createForwardable(flag);
        getAny().add(forward);
    
public final voidsetIssuer(Issuer issuer)

        this.issuer = issuer;
        /*JAXBElement<EndpointReferenceImpl> eprType =
                (new com.sun.xml.ws.security.trust.impl.bindings.ObjectFactory()).createIssuer((EndpointReferenceImpl)issuer);
        getAny().add(eprType);*/
    
public final voidsetKeySize(long size)

        keySize = size;
        final JAXBElement<Long> ksElement =  (new ObjectFactory()).createKeySize(size);
        getAny().add(ksElement);
    
public final voidsetKeyType(java.net.URI keytype)

        
        if (! (keytype.toString().equalsIgnoreCase(RequestSecurityToken.PUBLIC_KEY_TYPE)
        || keytype.toString().equalsIgnoreCase(RequestSecurityToken.SYMMETRIC_KEY_TYPE) )){
            log.log(Level.SEVERE,
                    LogStringsMessages.WST_0025_INVALID_KEY_TYPE(keytype.toString(), null));
            throw new WSTrustException(LogStringsMessages.WST_0025_INVALID_KEY_TYPE(keytype.toString(), null));
        } else {
            this.keyType = keytype;
            final JAXBElement<String> ktElement =
                    (new ObjectFactory()).createKeyType(keyType.toString());
            getAny().add(ktElement);
        }
    
public final voidsetLifetime(Lifetime lifetime)

        this.lifetime = lifetime;
        final JAXBElement<LifetimeType> ltElement =
                (new ObjectFactory()).createLifetime((LifetimeType)lifetime);
        getAny().add(ltElement);
    
public final voidsetOnBehalfOf(OnBehalfOf onBehalfOf)

        obo = onBehalfOf;
    
public final voidsetParticipants(Participants participants)

        this.participants = participants;
        final JAXBElement<ParticipantsType> rElement =
                (new ObjectFactory()).createParticipants((ParticipantsType)participants);
        getAny().add(rElement);
    
public final voidsetPolicy(com.sun.xml.ws.policy.Policy policy)

        this.policy = policy;
        getAny().add(policy);
    
public final voidsetPolicyReference(com.sun.xml.ws.policy.impl.bindings.PolicyReference policyRef)

        this.policyRef = policyRef;
        getAny().add(policyRef);
    
public final voidsetProofEncryption(ProofEncryption proofEncryption)

        this.proofEncryption = proofEncryption;
        final JAXBElement<ProofEncryptionType> proofElement =
                (new ObjectFactory()).createProofEncryption((ProofEncryptionType)proofEncryption);
        getAny().add(proofElement);
    
public final voidsetRenewTarget(RenewTarget target)

        this.renewTarget = target;
        final JAXBElement<RenewTargetType> rElement =
                (new ObjectFactory()).createRenewTarget((RenewTargetType)target);
        getAny().add(rElement);
    
public final voidsetRenewable(Renewing renew)

        renewable = renew;
        final JAXBElement<RenewingType> renewType =
                (new ObjectFactory()).createRenewing((RenewingType)renew);
        getAny().add(renewType);
    
public final voidsetRequestType(java.net.URI requestType)

        
        final String rtString = requestType.toString();
        if (!rtString.equalsIgnoreCase(WSTrustConstants.ISSUE_REQUEST)
        && !rtString.equalsIgnoreCase(WSTrustConstants.CANCEL_REQUEST)
        && !rtString.equalsIgnoreCase(WSTrustConstants.KEY_EXCHANGE_REQUEST)
        && !rtString.equalsIgnoreCase(WSTrustConstants.RENEW_REQUEST)
        && !rtString.equalsIgnoreCase(WSTrustConstants.VALIDATE_REQUEST)) {
            log.log(Level.SEVERE,
                    LogStringsMessages.WST_0024_INVALID_REQUEST_TYPE(rtString));
            throw new RuntimeException(LogStringsMessages.WST_0024_INVALID_REQUEST_TYPE(rtString));
        }
        this.requestType = requestType;
        final JAXBElement<String> rtElement =
                (new ObjectFactory()).createRequestType(rtString);
        getAny().add(rtElement);
    
public final voidsetSignChallenge(SignChallenge challenge)

        signChallenge = challenge;
        final JAXBElement<SignChallengeType> challengeType =
                (new ObjectFactory()).createSignChallenge((SignChallengeType)challenge);
        getAny().add(challengeType);
    
public final voidsetSignWith(java.net.URI algorithm)

        signWith = algorithm;
        final JAXBElement<String> sElement =  (new ObjectFactory()).createSignWith(algorithm.toString());
        getAny().add(sElement);
    
public final voidsetSignatureAlgorithm(java.net.URI algorithm)

        signatureAlgorithm = algorithm;
        final JAXBElement<String> signElement =
                (new ObjectFactory()).createSignatureAlgorithm(algorithm.toString());
        getAny().add(signElement);
    
public final voidsetTokenType(java.net.URI tokenType)

        if (tokenType != null) {
            this.tokenType = tokenType;
            final JAXBElement<String> ttElement =
                    (new ObjectFactory()).createTokenType(tokenType.toString());
            getAny().add(ttElement);
        }
    
public final voidsetUseKey(UseKey useKey)

        this.useKey = useKey;
        final JAXBElement<UseKeyType> ukElement =
                (new ObjectFactory()).createUseKey((UseKeyType)useKey);
        getAny().add(ukElement);