com.sun.xml.ws.security.opt.impl.keyinfo.SecurityTokenReference Maven / Gradle / Ivy
/*
* Copyright (c) 2010, 2022 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
*/
/*
* SecurityTokenReference.java
*
* Created on August 2, 2006, 5:15 PM
*/
package com.sun.xml.ws.security.opt.impl.keyinfo;
import com.sun.istack.NotNull;
import com.sun.xml.ws.api.SOAPVersion;
import com.sun.xml.ws.security.Token;
import com.sun.xml.ws.security.opt.api.SecurityElementWriter;
import com.sun.xml.ws.security.opt.api.reference.Reference;
import com.sun.xml.ws.security.opt.api.SecurityHeaderElement;
import com.sun.xml.ws.security.opt.impl.reference.X509Data;
import com.sun.xml.wss.impl.c14n.AttributeNS;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import com.sun.xml.ws.security.opt.impl.util.JAXBUtil;
import com.sun.xml.ws.security.secext10.SecurityTokenReferenceType;
import com.sun.xml.stream.buffer.XMLStreamBufferResult;
import com.sun.xml.wss.impl.MessageConstants;
import com.sun.xml.ws.security.opt.impl.reference.DirectReference;
import com.sun.xml.ws.security.opt.impl.reference.KeyIdentifier;
import com.sun.xml.ws.security.secext10.ObjectFactory;
import java.util.Map;
import java.io.OutputStream;
/**
*
* @author [email protected]
*/
public class SecurityTokenReference extends SecurityTokenReferenceType
implements com.sun.xml.ws.security.opt.api.keyinfo.SecurityTokenReference,
SecurityHeaderElement, SecurityElementWriter, Token {
//private SecurityTokenReferenceType str = null;
private boolean isCanonicalized = false;
SOAPVersion sv = SOAPVersion.SOAP_11;
/** Creates a new instance of SecurityTokenReference */
public SecurityTokenReference(SOAPVersion soapVersion) {
this.sv = soapVersion;
}
/**
* sets the reference element into the security token reference
* @param ref Reference
*/
@Override
public void setReference(Reference ref) {
JAXBElement refElem = null;
String type = ref.getType();
ObjectFactory objFac = new ObjectFactory();
if (KEYIDENTIFIER.equals(type)){
refElem = objFac.createKeyIdentifier((KeyIdentifier)ref);
} else if (REFERENCE.equals(type) || DIRECT_REFERENCE.equals(type)){
refElem = objFac.createReference((DirectReference)ref);
} else if(X509DATA_ISSUERSERIAL.equals(type)){
refElem = new com.sun.xml.security.core.dsig.ObjectFactory().createX509Data((X509Data)ref);
}
if(refElem != null){
List