com.sun.xml.ws.security.trust.impl.elements.RequestSecurityTokenResponseImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of webservices-osgi Show documentation
Show all versions of webservices-osgi Show documentation
Metro Web Services Runtime OSGi Bundle
/*
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/*
* $Id: RequestSecurityTokenResponseImpl.java,v 1.2 2010-10-21 15:36:55 snajper Exp $
*/
package com.sun.xml.ws.security.trust.impl.elements;
import java.net.URISyntaxException;
import java.util.List;
import java.net.URI;
import com.sun.xml.ws.policy.impl.bindings.AppliesTo;
import com.sun.xml.ws.policy.Policy;
import com.sun.xml.ws.policy.impl.bindings.PolicyReference;
import jakarta.xml.bind.JAXBElement;
import com.sun.xml.ws.api.security.trust.WSTrustException;
import com.sun.xml.ws.security.trust.elements.*;
import com.sun.xml.ws.api.security.trust.Status;
import com.sun.xml.ws.security.trust.impl.bindings.AllowPostdatingType;
import com.sun.xml.ws.security.trust.impl.bindings.AuthenticatorType;
import com.sun.xml.ws.security.trust.impl.bindings.BinaryExchangeType;
import com.sun.xml.ws.security.trust.impl.bindings.DelegateToType;
import com.sun.xml.ws.security.trust.impl.bindings.EncryptionType;
import com.sun.xml.ws.security.trust.impl.bindings.RequestSecurityTokenResponseType;
import com.sun.xml.ws.security.trust.impl.bindings.EntropyType;
import com.sun.xml.ws.security.trust.impl.bindings.LifetimeType;
import com.sun.xml.ws.security.trust.impl.bindings.RequestedReferenceType;
import com.sun.xml.ws.security.trust.impl.bindings.RequestedProofTokenType;
import com.sun.xml.ws.security.trust.impl.bindings.RequestedSecurityTokenType;
import com.sun.xml.ws.security.trust.impl.bindings.RequestedTokenCancelledType;
import com.sun.xml.ws.security.trust.impl.bindings.ObjectFactory;
import com.sun.xml.ws.security.trust.impl.bindings.ProofEncryptionType;
import com.sun.xml.ws.security.trust.impl.bindings.RenewingType;
import com.sun.xml.ws.security.trust.impl.bindings.SignChallengeType;
import com.sun.xml.ws.security.trust.impl.bindings.StatusType;
import com.sun.xml.ws.security.trust.impl.bindings.UseKeyType;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.xml.ws.security.trust.logging.LogDomainConstants;
import com.sun.istack.NotNull;
import com.sun.xml.ws.security.trust.WSTrustVersion;
import com.sun.xml.ws.security.trust.impl.WSTrustVersion10;
import com.sun.xml.ws.security.trust.logging.LogStringsMessages;
/**
* Implementation of a RequestSecurityTokenResponse.
*
* @author Manveen Kaur
*/
public class RequestSecurityTokenResponseImpl extends RequestSecurityTokenResponseType implements RequestSecurityTokenResponse {
private static final Logger log =
Logger.getLogger(
LogDomainConstants.TRUST_IMPL_DOMAIN,
LogDomainConstants.TRUST_IMPL_DOMAIN_BUNDLE);
private URI tokenType = null;
private long keySize = 0;
private URI keyType = null;
private URI computedKeyAlgorithm = null;
private URI signatureAlgorithm = null;
private URI encryptionAlgorithm = null;
private URI canonAlgorithm = null;
private Lifetime lifetime = null;
private Entropy entropy = null;
private AppliesTo appliesTo = null;
private Authenticator authenticator = null;
private UseKey useKey = null;
private ProofEncryption proofEncryption = null;
private Encryption encryption = null;
private DelegateTo delegateTo = null;
private OnBehalfOf obo = null;
private RequestedSecurityToken requestedSecToken = null;
private RequestedProofToken requestedProofToken = null;
private RequestedAttachedReference requestedAttachedReference = null;
private RequestedUnattachedReference requestedUnattachedReference = null;
private URI signWith = null;
private URI encryptWith = null;
private URI authenticationType = null;
private SignChallenge signChallenge = null;
private SignChallengeResponse signChallengeRes = null;
private boolean forwardable = true;
private boolean delegatable = false;
private Issuer issuer = null;
private Renewing renewable = null;
private BinaryExchange binaryExchange = null;
private AllowPostdating apd = null;
private Status status = null;
private Policy policy = null;
private PolicyReference policyRef = null;
private RequestedTokenCancelled rtc = null;
public RequestSecurityTokenResponseImpl() {
// default empty constructor
}
public RequestSecurityTokenResponseImpl(URI tokenType,
URI context,
RequestedSecurityToken token,
AppliesTo scopes,
RequestedAttachedReference attached,
RequestedUnattachedReference unattached,
RequestedProofToken proofToken,
Entropy entropy,
Lifetime lifetime,
Status status) {
setTokenType(tokenType);
if (context != null) { setContext(context.toString()); }
if (token != null) { setRequestedSecurityToken(token); }
if (attached!= null) { setRequestedAttachedReference(attached); }
if (unattached!= null) { setRequestedUnattachedReference(unattached); }
if (scopes != null) { setAppliesTo(scopes); }
if (proofToken != null) { setRequestedProofToken(proofToken); }
if (entropy != null) { setEntropy(entropy); }
if (lifetime != null) { setLifetime(lifetime); }
if (status != null) { setStatus(status); }
}
public URI getTokenType() {
return tokenType;
}
public final void setTokenType(final URI tokenType) {
if (tokenType != null) {
this.tokenType = tokenType;
final JAXBElement ttElement =
(new ObjectFactory()).createTokenType(tokenType.toString());
getAny().add(ttElement);
}
}
public Lifetime getLifetime() {
return lifetime;
}
public final void setLifetime(final Lifetime lifetime) {
this.lifetime = lifetime;
final JAXBElement ltElement =
(new ObjectFactory()).createLifetime((LifetimeType)lifetime);
getAny().add(ltElement);
}
public RequestedTokenCancelled getRequestedTokenCancelled() {
return this.rtc;
}
public final void setRequestedTokenCancelled(final RequestedTokenCancelled rtc) {
this.rtc = rtc;
final JAXBElement rtcElement =
(new ObjectFactory()).createRequestedTokenCancelled((RequestedTokenCancelledType)rtc);
getAny().add(rtcElement);
}
public Status getStatus() {
return status;
}
public final void setStatus(final Status status) {
this.status = status;
final JAXBElement sElement =
(new ObjectFactory()).createStatus((StatusType)status);
getAny().add(sElement);
}
public Entropy getEntropy() {
return entropy;
}
public final void setEntropy(final Entropy entropy) {
this.entropy = entropy;
final JAXBElement etElement =
(new ObjectFactory()).createEntropy((EntropyType)entropy);
getAny().add(etElement);
}
public final void setAppliesTo(final AppliesTo appliesTo) {
getAny().add(appliesTo);
this.appliesTo = appliesTo;
}
public AppliesTo getAppliesTo() {
return appliesTo;
}
public final void setOnBehalfOf(final OnBehalfOf onBehalfOf) {
obo = onBehalfOf;
}
public OnBehalfOf getOnBehalfOf() {
return obo;
}
public final void setIssuer(final Issuer issuer) {
this.issuer = issuer;
/* JAXBElement eprType =
(new com.sun.xml.ws.security.trust.impl.bindings.ObjectFactory()).createIssuer((EndpointReferenceImpl)issuer);
getAny().add(eprType);*/
}
public Issuer getIssuer() {
return issuer;
}
public final void setRenewable(final Renewing renew) {
renewable = renew;
final JAXBElement renewType =
(new ObjectFactory()).createRenewing((RenewingType)renew);
getAny().add(renewType);
}
public Renewing getRenewable() {
return renewable;
}
public final void setSignChallenge(final SignChallenge challenge) {
signChallenge = challenge;
final JAXBElement challengeType =
(new ObjectFactory()).createSignChallenge((SignChallengeType)challenge);
getAny().add(challengeType);
}
public SignChallenge getSignChallenge() {
return signChallenge;
}
public final void setBinaryExchange(final BinaryExchange exchange) {
binaryExchange = exchange;
final JAXBElement exchangeType =
(new ObjectFactory()).createBinaryExchange((BinaryExchangeType)exchange);
getAny().add(exchangeType);
}
public BinaryExchange getBinaryExchange() {
return binaryExchange;
}
public final void setAuthenticationType(final URI uri) {
this.authenticationType = uri;
final JAXBElement atElement =
(new ObjectFactory()).createAuthenticationType(uri.toString());
getAny().add(atElement);
}
public URI getAuthenticationType() {
return authenticationType;
}
public final void setKeyType(@NotNull final URI keytype) throws WSTrustException {
WSTrustVersion wstVer = new WSTrustVersion10();
if (! (keytype.toString().equalsIgnoreCase(wstVer.getSymmetricKeyTypeURI())
|| keytype.toString().equalsIgnoreCase(wstVer.getPublicKeyTypeURI())
|| keytype.toString().equalsIgnoreCase(wstVer.getBearerKeyTypeURI()) )){
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 ktElement =
(new ObjectFactory()).createKeyType(keyType.toString());
getAny().add(ktElement);
}
}
public URI getKeyType() {
return keyType;
}
public final void setKeySize(@NotNull final long size) {
keySize = size;
final JAXBElement ksElement = (new ObjectFactory()).createKeySize(size);
getAny().add(ksElement);
}
public long getKeySize() {
return keySize;
}
public final void setSignatureAlgorithm(@NotNull final URI algorithm) {
signatureAlgorithm = algorithm;
final JAXBElement signElement =
(new ObjectFactory()).createSignatureAlgorithm(algorithm.toString());
getAny().add(signElement);
}
public URI getSignatureAlgorithm() {
return signatureAlgorithm;
}
public final void setEncryptionAlgorithm(@NotNull final URI algorithm) {
encryptionAlgorithm = algorithm;
final JAXBElement encElement =
(new ObjectFactory()).createEncryptionAlgorithm(algorithm.toString());
getAny().add(encElement);
}
public URI getEncryptionAlgorithm() {
return encryptionAlgorithm;
}
public final void setCanonicalizationAlgorithm(@NotNull final URI algorithm) {
canonAlgorithm = algorithm;
final JAXBElement canonElement =
(new ObjectFactory()).createCanonicalizationAlgorithm(algorithm.toString());
getAny().add(canonElement);
}
public URI getCanonicalizationAlgorithm() {
return canonAlgorithm;
}
public final void setUseKey(final UseKey useKey) {
this.useKey = useKey;
final JAXBElement ukElement =
(new ObjectFactory()).createUseKey((UseKeyType)useKey);
getAny().add(ukElement);
}
public UseKey getUseKey() {
return useKey;
}
public final void setProofEncryption(final ProofEncryption proofEncryption) {
this.proofEncryption = proofEncryption;
final JAXBElement proofElement =
(new ObjectFactory()).createProofEncryption((ProofEncryptionType)proofEncryption);
getAny().add(proofElement);
}
public ProofEncryption getProofEncryption() {
return proofEncryption;
}
public final void setComputedKeyAlgorithm(@NotNull final URI algorithm) {
if (algorithm != null) {
final String ckaString = algorithm.toString();
if (!ckaString.equalsIgnoreCase(WSTrustVersion.WS_TRUST_10.getCKHASHalgorithmURI())
&& !ckaString.equalsIgnoreCase(WSTrustVersion.WS_TRUST_10.getCKPSHA1algorithmURI())) {
throw new RuntimeException("Invalid Computed Key Algorithm specified");
}
computedKeyAlgorithm = algorithm;
final JAXBElement ckaElement =
(new ObjectFactory()).createComputedKeyAlgorithm(ckaString);
getAny().add(ckaElement);
}
}
public URI getComputedKeyAlgorithm() {
return computedKeyAlgorithm;
}
public final void setEncryption(final Encryption enc) {
this.encryption = enc;
final JAXBElement encElement =
(new ObjectFactory()).createEncryption((EncryptionType)enc);
getAny().add(encElement);
}
public Encryption getEncryption() {
return encryption;
}
public final void setSignWith(final URI algorithm) {
signWith = algorithm;
final JAXBElement sElement = (new ObjectFactory()).createSignWith(algorithm.toString());
getAny().add(sElement);
}
public URI getSignWith() {
return signWith;
}
public final void setEncryptWith(@NotNull final URI algorithm) {
encryptWith = algorithm;
final JAXBElement sElement = (new ObjectFactory()).createEncryptWith(algorithm.toString());
getAny().add(sElement);
}
public URI getEncryptWith() {
return encryptWith;
}
public void setKeyWrapAlgorithm(URI algorithm) {
throw new UnsupportedOperationException("KeyWrapAlgorithm element in WS-Trust Standard version(1.0) is not supported");
}
public URI getKeyWrapAlgorithm() {
throw new UnsupportedOperationException("KeyWrapAlgorithm element in WS-Trust Standard version(1.0) is not supported");
}
public final void setDelegateTo(final DelegateTo to) {
this.delegateTo = to;
final JAXBElement dtElement =
(new ObjectFactory()).createDelegateTo((DelegateToType)to);
getAny().add(dtElement);
}
public DelegateTo getDelegateTo() {
return delegateTo;
}
public final void setForwardable(final boolean flag) {
forwardable = flag;
final JAXBElement forward =
(new ObjectFactory()).createForwardable(flag);
getAny().add(forward);
}
public boolean getForwardable() {
return forwardable;
}
public final void setDelegatable(final boolean flag) {
this.delegatable = flag;
final JAXBElement del =
(new ObjectFactory()).createDelegatable(flag);
getAny().add(del);
}
public boolean getDelegatable() {
return delegatable;
}
public final void setPolicy(final Policy policy) {
this.policy = policy;
getAny().add(policy);
}
public Policy getPolicy() {
return policy;
}
public final void setPolicyReference(final PolicyReference policyRef) {
this.policyRef = policyRef;
getAny().add(policyRef);
}
public PolicyReference getPolicyReference() {
return policyRef;
}
public AllowPostdating getAllowPostdating() {
return apd;
}
public final void setAllowPostdating(final AllowPostdating allowPostdating) {
apd = allowPostdating;
final JAXBElement allowPd =
(new ObjectFactory()).createAllowPostdating((AllowPostdatingType)apd);
getAny().add(allowPd);
}
public final void setSignChallengeResponse(final SignChallengeResponse challenge) {
signChallengeRes = challenge;
final JAXBElement challengeType =
(new ObjectFactory()).createSignChallengeResponse((SignChallengeType)challenge);
getAny().add(challengeType);
}
public SignChallengeResponse getSignChallengeResponse() {
return signChallengeRes;
}
public final void setAuthenticator(final Authenticator authenticator) {
this.authenticator = authenticator;
final JAXBElement authType =
(new ObjectFactory()).createAuthenticator((AuthenticatorType)authenticator);
getAny().add(authType);
}
public Authenticator getAuthenticator() {
return authenticator;
}
public final void setRequestedProofToken(final RequestedProofToken proofToken) {
requestedProofToken = proofToken;
final JAXBElement pElement = (new ObjectFactory()).
createRequestedProofToken((RequestedProofTokenType)proofToken);
getAny().add(pElement);
}
public RequestedProofToken getRequestedProofToken() {
return requestedProofToken;
}
public final void setRequestedSecurityToken(final RequestedSecurityToken securityToken) {
requestedSecToken = securityToken;
final JAXBElement rstElement = (new ObjectFactory()).
createRequestedSecurityToken((RequestedSecurityTokenType)securityToken);
getAny().add(rstElement);
}
public RequestedSecurityToken getRequestedSecurityToken() {
return requestedSecToken;
}
public final void setRequestedAttachedReference(final RequestedAttachedReference reference) {
requestedAttachedReference = reference;
final JAXBElement raElement = (new ObjectFactory()).
createRequestedAttachedReference((RequestedReferenceType)reference);
getAny().add(raElement);
}
public RequestedAttachedReference getRequestedAttachedReference() {
return requestedAttachedReference;
}
public final void setRequestedUnattachedReference(final RequestedUnattachedReference reference) {
requestedUnattachedReference = reference;
final JAXBElement raElement = (new ObjectFactory()).
createRequestedUnattachedReference((RequestedReferenceType)reference);
getAny().add(raElement);
}
public RequestedUnattachedReference getRequestedUnattachedReference() {
return requestedUnattachedReference;
}
public RequestSecurityTokenResponseImpl(RequestSecurityTokenResponseType rstrType)
throws URISyntaxException,WSTrustException {
this.context = rstrType.getContext();
final List