List of usage examples for javax.xml.bind JAXBElement getName
public QName getName()
From source file:org.apache.axis2.datasource.jaxb.JAXBDSContext.java
/** * Marshal array objects by type/*from w w w . j a va 2s .c om*/ * * Invoke marshalByType for each element in the array * * @param jaxb_in JAXBElement containing a value that is a List or array * @param m_in Marshaller * @param writer_in XMLStreamWriter */ private void marshalOccurrenceArray(final JAXBElement jbe_in, final Marshaller m_in, final XMLStreamWriter writer_in) { if (log.isDebugEnabled()) { log.debug("Enter marshalOccurrenceArray"); log.debug(" Marshaller = " + JavaUtils.getObjectIdentity(m_in)); } AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { Marshaller m = m_in; JAXBContext newJBC = null; if (getConstructionType() != JAXBUtils.CONSTRUCTION_TYPE.BY_CLASS_ARRAY_PLUS_ARRAYS) { // Rebuild JAXBContext // There may be a preferred classloader that should be used if (log.isDebugEnabled()) { log.debug("Building a JAXBContext with array capability"); } ClassLoader cl = getClassLoader(); newJBC = getJAXBContext(cl, true); m = JAXBUtils.getJAXBMarshaller(newJBC); if (log.isDebugEnabled()) { log.debug("The new JAXBContext was constructed with " + getConstructionType()); } } OccurrenceArray occurArray = (OccurrenceArray) jbe_in.getValue(); // Create a new JAXBElement. // The name is the name of the individual occurence elements // Type type is Object[] // The value is the array of Object[] representing each element JAXBElement jbe = new JAXBElement(jbe_in.getName(), Object[].class, occurArray.getAsArray()); // The jaxb marshal command cannot write out a list/array // of occurence elements. So we marshal it as a single // element containing items...and then put a filter on the // writer to transform it into a stream of occurence elements XMLStreamWriterArrayFilter writer = new XMLStreamWriterArrayFilter(writer_in); m.marshal(jbe, writer); if (newJBC != null) { JAXBUtils.releaseJAXBMarshaller(newJBC, m); } return null; } catch (OMException e) { throw e; } catch (Throwable t) { throw new OMException(t); } } }); if (log.isDebugEnabled()) { log.debug("Exit marshalOccurrenceArray"); } }
From source file:org.apache.axis2.jaxws.marshaller.impl.alt.DocLitWrappedMinimalMethodMarshaller.java
/** * If the PDElement represents an array or List, * a new PDElement is returned that models the * the array or List as a series of elements. * @param pde//from www . ja v a2 s.c o m * @return new PDElement or same PDElement */ private static PDElement processOccurrence(PDElement pde) { // All arrays and lists should be marshaled as // separate (occurrence) elements Element element = pde.getElement(); if (element != null) { Object elementValue = element.getElementValue(); if (elementValue instanceof JAXBElement) { JAXBElement jaxb = (JAXBElement) elementValue; Object value = jaxb.getValue(); if (representAsOccurrence(value, jaxb.getDeclaredType())) { if (log.isDebugEnabled()) { log.debug("Build OccurrentArray"); } OccurrenceArray occurrenceArray = new OccurrenceArray(value); JAXBElement newJAXBElement = new JAXBElement(jaxb.getName(), jaxb.getDeclaredType(), occurrenceArray); element = new Element(newJAXBElement, jaxb.getName()); pde = new PDElement(pde.getParam(), element, null); } } } return pde; }
From source file:org.apache.cxf.ws.security.sts.provider.operation.IssueDelegate.java
@Override public RequestSecurityTokenResponseCollectionType issue(RequestSecurityTokenType request) { String tokenType = SAMLConstants.SAML20_NS; X509Certificate certificate = null; String username = null;//from ww w . ja v a2 s . co m // parse input arguments for (Object requestObject : request.getAny()) { // certificate try { if (certificate == null) { certificate = getCertificateFromRequest(requestObject); } } catch (CertificateException e) { throw new STSException("Can't extract X509 certificate from request", e); } // TokenType if (requestObject instanceof JAXBElement) { JAXBElement<?> jaxbElement = (JAXBElement<?>) requestObject; if (QNAME_WST_TOKEN_TYPE.equals(jaxbElement.getName())) { tokenType = (String) jaxbElement.getValue(); } } } // check input arguments if (certificate != null) { // certificate try { verifyCertificate(certificate); } catch (Exception e) { throw new STSException("Can't verify X509 certificate from request", e); } } else { // username username = passwordCallback.resetUsername(); if (username == null) { throw new STSException("No credentials provided"); } authenticate(username, passwordCallback.resetPassword()); } // create token TokenProvider tokenProvider = null; for (TokenProvider tp : tokenProviders) { if (tokenType.equals(tp.getTokenType())) { tokenProvider = tp; break; } } if (tokenProvider == null) { throw new STSException("No token provider found for requested token type: " + tokenType); } Element elementToken = null; if (certificate != null) { elementToken = tokenProvider.createToken(certificate); } else { elementToken = tokenProvider.createToken(username); } String tokenId = tokenProvider.getTokenId(elementToken); signSAML(elementToken, tokenId); // prepare response RequestSecurityTokenResponseType response = wrapAssertionToResponse(tokenType, elementToken, tokenId); RequestSecurityTokenResponseCollectionType responseCollection = WS_TRUST_FACTORY .createRequestSecurityTokenResponseCollectionType(); responseCollection.getRequestSecurityTokenResponse().add(response); return responseCollection; }
From source file:org.apache.hise.runtime.TaskEvaluator.java
public Set<TaskOrgEntity> evaluatePeopleAssignments() { Set<TaskOrgEntity> result = new HashSet<TaskOrgEntity>(); TPeopleAssignments p = task.getTaskDefinition().getPeopleAssignments(); for (JAXBElement<TGenericHumanRole> r : p.getGenericHumanRole()) { GenericHumanRole assignmentRole = GenericHumanRole.valueOf(r.getName().getLocalPart().toUpperCase()); Set<TaskOrgEntity> result2 = evaluateGenericHumanRole(r.getValue(), assignmentRole); result.addAll(result2);/*from w ww .ja v a2 s .c o m*/ } if (__log.isDebugEnabled()) { __log.debug("evaluated people assignments " + task.getTaskDefinition().getTaskName() + " " + result); } return result; }
From source file:org.apache.juddi.mapping.MappingApiToModel.java
private static List<Signature> mapApiSignaturesToModelSignatures( List<org.w3._2000._09.xmldsig_.SignatureType> apiSignatures) throws DispositionReportFaultMessage { List<Signature> modelSignatures = new ArrayList<Signature>(); modelSignatures.clear();/*from ww w . jav a2 s. c om*/ for (org.w3._2000._09.xmldsig_.SignatureType signatureType : apiSignatures) { Signature modelSignature = new Signature(); org.w3._2000._09.xmldsig_.SignedInfoType apiSignedInfo = signatureType.getSignedInfo(); SignedInfo modelSignedInfo = new SignedInfo(); modelSignature.setSignedInfo(modelSignedInfo); String canonicalizationAlgMethod = apiSignedInfo.getCanonicalizationMethod().getAlgorithm(); CanonicalizationMethod modelCanonMethod = new CanonicalizationMethod(); modelSignedInfo.setCanonicalizationMethod(modelCanonMethod); modelCanonMethod.setAlgorithm(canonicalizationAlgMethod); SignatureMethod modelSigMethod = new SignatureMethod(); modelSignedInfo.setSignatureMethod(modelSigMethod); String sigMethod = apiSignedInfo.getSignatureMethod().getAlgorithm(); modelSigMethod.setAlgorithm(sigMethod); List<org.w3._2000._09.xmldsig_.ReferenceType> apiReferenceList = apiSignedInfo.getReference(); for (org.w3._2000._09.xmldsig_.ReferenceType apiReference : apiReferenceList) { Reference ref = mapReference(modelSignedInfo, apiReference); modelSignedInfo.getReference().add(ref); } modelSignedInfo.setCanonicalizationMethod(modelCanonMethod); org.w3._2000._09.xmldsig_.SignatureValueType apiSignatureValue = signatureType.getSignatureValue(); SignatureValue modelSignatureValue = new SignatureValue(); byte[] signatureValueBytes = apiSignatureValue.getValue(); String signatureValueXmlID = apiSignatureValue.getId(); modelSignatureValue.setValue(signatureValueBytes); modelSignatureValue.setXmlID(signatureValueXmlID); modelSignature.setSignatureValue(modelSignatureValue); org.w3._2000._09.xmldsig_.KeyInfoType apiKeyInfo = signatureType.getKeyInfo(); String apiKeyInfoXmlID = apiKeyInfo.getId(); KeyInfo modelKeyInfo = new KeyInfo(); modelSignature.setKeyInfo(modelKeyInfo); modelKeyInfo.setXmlID(apiKeyInfoXmlID); List<Object> apiKeyInfoContentList = apiKeyInfo.getContent(); List<KeyDataValue> keyInfoDataValues = modelKeyInfo.getKeyDataValue(); for (Object apiKeyInfoContentObj : apiKeyInfoContentList) { if (apiKeyInfoContentObj instanceof JAXBElement) { JAXBElement apiKeyInfoContentJAXB = (JAXBElement) apiKeyInfoContentObj; String apiKeyInfoContentTagName = apiKeyInfoContentJAXB.getName().getLocalPart(); if (apiKeyInfoContentJAXB.getValue() instanceof X509DataType) { KeyDataValue modelX509KeyData = mapX509DataType(apiKeyInfoContentJAXB, modelKeyInfo); keyInfoDataValues.add(modelX509KeyData); } else if (apiKeyInfoContentTagName.equals("KeyName")) { KeyDataValue modelKeyNameKDV = mapKeyName(apiKeyInfoContentJAXB); modelKeyNameKDV.setKeyInfo(modelKeyInfo); keyInfoDataValues.add(modelKeyNameKDV); } else if (apiKeyInfoContentTagName.equals("KeyValue")) { KeyDataValue modelKeyValueKDV = mapKeyValue(apiKeyInfoContentJAXB, keyInfoDataValues); modelKeyValueKDV.setKeyInfo(modelKeyInfo); keyInfoDataValues.add(modelKeyValueKDV); } else if (apiKeyInfoContentTagName.equals("MgmtData")) { KeyDataValue modelKeyValueKDV = new KeyDataValue(); modelKeyValueKDV.setKeyDataName(apiKeyInfoContentTagName); modelKeyValueKDV.setKeyDataType("String"); modelKeyValueKDV.setKeyDataValueString((String) apiKeyInfoContentJAXB.getValue()); modelKeyValueKDV.setKeyInfo(modelKeyInfo); keyInfoDataValues.add(modelKeyValueKDV); } else if (apiKeyInfoContentTagName.equals("RetrievalMethod")) { RetrievalMethodType retrievalMethodType = (RetrievalMethodType) apiKeyInfoContentJAXB .getValue(); KeyDataValue retrievalMethodTypeKDV = mapRetrievalMethod(apiKeyInfoContentTagName, modelKeyInfo, retrievalMethodType); keyInfoDataValues.add(retrievalMethodTypeKDV); } else if (apiKeyInfoContentTagName.equals("PGPData")) { PGPDataType pgpDataType = (PGPDataType) apiKeyInfoContentJAXB.getValue(); KeyDataValue pgpDataTypeKDV = mapPGPDataType(apiKeyInfoContentTagName, modelKeyInfo, pgpDataType); keyInfoDataValues.add(pgpDataTypeKDV); } else if (apiKeyInfoContentTagName.equals("SPKIData")) { SPKIDataType spkiDataType = (SPKIDataType) apiKeyInfoContentJAXB.getValue(); KeyDataValue spkiDataTypeKDV = mapSPKIDataType(apiKeyInfoContentTagName, modelKeyInfo, spkiDataType); keyInfoDataValues.add(spkiDataTypeKDV); } else { throw new RuntimeException("Unrecognized tag: " + apiKeyInfoContentTagName + " type: " + apiKeyInfoContentJAXB.getValue().getClass().getCanonicalName()); } } } modelSignatures.add(modelSignature); } return modelSignatures; }
From source file:org.apache.juddi.mapping.MappingApiToModel.java
private static KeyDataValue mapX509DataType(JAXBElement apiKeyInfoContentJAXB, KeyInfo modelKeyInfo) throws RuntimeException { X509DataType apiKeyInfoContent = (X509DataType) apiKeyInfoContentJAXB.getValue(); KeyDataValue modelX509KeyData = new KeyDataValue(); modelX509KeyData.setKeyDataType(X509DataType.class.getSimpleName()); modelX509KeyData.setKeyDataName(apiKeyInfoContentJAXB.getName().getLocalPart()); modelX509KeyData.setKeyInfo(modelKeyInfo); List<Object> x509IssuerSerialOrX509SKIOrX509SubjectNameList = apiKeyInfoContent .getX509IssuerSerialOrX509SKIOrX509SubjectName(); for (Object x509IssuerSerialOrX509SKIOrX509SubjectNameObj : x509IssuerSerialOrX509SKIOrX509SubjectNameList) { JAXBElement x509IssuerSerialOrX509SKIOrX509SubjectNameJAXB = (JAXBElement) x509IssuerSerialOrX509SKIOrX509SubjectNameObj; String tagName = x509IssuerSerialOrX509SKIOrX509SubjectNameJAXB.getName().getLocalPart(); Object x509IssuerSerialOrX509SKIOrX509SubjectName = x509IssuerSerialOrX509SKIOrX509SubjectNameJAXB .getValue();// w ww . j av a 2s . c o m KeyDataValue modelKeyInfoValue = new KeyDataValue(); modelKeyInfoValue.setKeyDataName(tagName); if (x509IssuerSerialOrX509SKIOrX509SubjectName instanceof byte[]) { modelKeyInfoValue.setKeyDataValueBytes((byte[]) x509IssuerSerialOrX509SKIOrX509SubjectName); } else if (x509IssuerSerialOrX509SKIOrX509SubjectName instanceof String) { modelKeyInfoValue.setKeyDataValueString((String) x509IssuerSerialOrX509SKIOrX509SubjectName); } else if (x509IssuerSerialOrX509SKIOrX509SubjectName instanceof X509IssuerSerialType) { modelKeyInfoValue.setKeyDataType(X509IssuerSerialType.class.getSimpleName()); X509IssuerSerialType x509IssuerSerialType = (X509IssuerSerialType) x509IssuerSerialOrX509SKIOrX509SubjectName; modelKeyInfoValue.setKeyDataValueString(x509IssuerSerialType.getX509IssuerName()); modelKeyInfoValue.setKeyDataValueBytes(x509IssuerSerialType.getX509SerialNumber().toByteArray()); } else if (x509IssuerSerialOrX509SKIOrX509SubjectName != null) { throw new RuntimeException("Unrecognized Value for Element: " + tagName + ": " + x509IssuerSerialOrX509SKIOrX509SubjectName.getClass().getCanonicalName()); } modelKeyInfoValue.setKeyDataValue(modelX509KeyData); modelX509KeyData.getKeyDataValueList().add(modelKeyInfoValue); } return modelX509KeyData; }
From source file:org.apache.juddi.mapping.MappingApiToModel.java
private static KeyDataValue mapKeyName(JAXBElement apiKeyInfoContentJAXB) { KeyDataValue modelKeyNameKDV = new KeyDataValue(); modelKeyNameKDV.setKeyDataType(String.class.getSimpleName()); modelKeyNameKDV.setKeyDataName(apiKeyInfoContentJAXB.getName().getLocalPart()); modelKeyNameKDV.setKeyDataValueString((String) apiKeyInfoContentJAXB.getValue()); return modelKeyNameKDV; }
From source file:org.apache.juddi.mapping.MappingApiToModel.java
private static KeyDataValue mapKeyValue(JAXBElement apiKeyInfoContentJAXB, List<KeyDataValue> keyInfoDataValues) { KeyValueType kvt = (KeyValueType) apiKeyInfoContentJAXB.getValue(); KeyDataValue modelKeyValueKDV = new KeyDataValue(); modelKeyValueKDV.setKeyDataType(KeyValueType.class.getSimpleName()); modelKeyValueKDV.setKeyDataName(apiKeyInfoContentJAXB.getName().getLocalPart()); keyInfoDataValues.add(modelKeyValueKDV); List<Object> kvObjList = kvt.getContent(); for (Object kvObj : kvObjList) { if (kvObj instanceof JAXBElement) { JAXBElement kvJAXB = (JAXBElement) kvObj; Object childVal = kvJAXB.getValue(); KeyDataValue childKDV = new KeyDataValue(); childKDV.setKeyDataValue(modelKeyValueKDV); childKDV.setKeyDataName(kvJAXB.getName().getLocalPart()); childKDV.setKeyDataType(childVal.getClass().getSimpleName()); modelKeyValueKDV.getKeyDataValueList().add(childKDV); if (childVal instanceof DSAKeyValueType) { DSAKeyValueType dsaKeyVal = (DSAKeyValueType) childVal; String dsaKeyValueTagName = kvJAXB.getName().getLocalPart(); KeyDataValue dsaKeyValKDV = new KeyDataValue(null, DSAKeyValueType.class.getSimpleName(), dsaKeyValueTagName, null, null, childKDV); childKDV.getKeyDataValueList().add(dsaKeyValKDV); KeyDataValue gValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "G", dsaKeyVal.getG(), null, dsaKeyValKDV); dsaKeyValKDV.getKeyDataValueList().add(gValKDV); KeyDataValue jValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "J", dsaKeyVal.getJ(), null, dsaKeyValKDV); dsaKeyValKDV.getKeyDataValueList().add(jValKDV); KeyDataValue pValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "P", dsaKeyVal.getP(), null, dsaKeyValKDV); dsaKeyValKDV.getKeyDataValueList().add(pValKDV); KeyDataValue pGenCounterValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "PgenCounter", dsaKeyVal.getPgenCounter(), null, dsaKeyValKDV); dsaKeyValKDV.getKeyDataValueList().add(pGenCounterValKDV); KeyDataValue qValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Q", dsaKeyVal.getQ(), null, dsaKeyValKDV); dsaKeyValKDV.getKeyDataValueList().add(qValKDV); KeyDataValue seedValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Seed", dsaKeyVal.getSeed(), null, dsaKeyValKDV); dsaKeyValKDV.getKeyDataValueList().add(seedValKDV); KeyDataValue yValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Y", dsaKeyVal.getY(), null, dsaKeyValKDV); dsaKeyValKDV.getKeyDataValueList().add(yValKDV); } else if (childVal instanceof RSAKeyValueType) { RSAKeyValueType rsaKeyVal = (RSAKeyValueType) childVal; String rsaKeyValueTagName = kvJAXB.getName().getLocalPart(); KeyDataValue rsaKeyValKDV = new KeyDataValue(null, RSAKeyValueType.class.getSimpleName(), rsaKeyValueTagName, null, null, childKDV); childKDV.getKeyDataValueList().add(rsaKeyValKDV); KeyDataValue exponentValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Exponent", rsaKeyVal.getExponent(), null, rsaKeyValKDV); rsaKeyValKDV.getKeyDataValueList().add(exponentValKDV); KeyDataValue modulusValKDV = new KeyDataValue(null, byte[].class.getSimpleName(), "Modulus", rsaKeyVal.getModulus(), null, rsaKeyValKDV); rsaKeyValKDV.getKeyDataValueList().add(modulusValKDV); }// w w w .j av a 2 s .c om } } return modelKeyValueKDV; }
From source file:org.apache.juddi.mapping.MappingApiToModel.java
private static KeyDataValue mapPGPDataType(String apiKeyInfoContentTagName, KeyInfo modelKeyInfo, PGPDataType pgpDataType) {/*from www . ja v a2 s . c o m*/ KeyDataValue pgpDataTypeKDV = new KeyDataValue(); pgpDataTypeKDV.setKeyDataName(apiKeyInfoContentTagName); pgpDataTypeKDV.setKeyDataType(PGPDataType.class.getSimpleName()); pgpDataTypeKDV.setKeyInfo(modelKeyInfo); List<Object> pgpDataValues = pgpDataType.getContent(); for (Object pgpDataValue : pgpDataValues) { if (pgpDataValue instanceof JAXBElement) { JAXBElement pgpDataJAXB = (JAXBElement) pgpDataValue; String tagName = pgpDataJAXB.getName().getLocalPart(); KeyDataValue keyIDKDV = new KeyDataValue(); keyIDKDV.setKeyDataName(tagName); keyIDKDV.setKeyDataValue(pgpDataTypeKDV); if (pgpDataJAXB.getValue() instanceof String) { keyIDKDV.setKeyDataValueString((String) pgpDataJAXB.getValue()); } else { keyIDKDV.setKeyDataValueBytes((byte[]) pgpDataJAXB.getValue()); } pgpDataTypeKDV.getKeyDataValueList().add(keyIDKDV); } } return pgpDataTypeKDV; }
From source file:org.apache.juddi.mapping.MappingApiToModel.java
private static KeyDataValue mapSPKIDataType(String apiKeyInfoContentTagName, KeyInfo modelKeyInfo, SPKIDataType spkiDataType) {//from w w w . j a va 2 s .c o m KeyDataValue spkiDataTypeKDV = new KeyDataValue(); spkiDataTypeKDV.setKeyDataName(apiKeyInfoContentTagName); spkiDataTypeKDV.setKeyDataType(SPKIDataType.class.getSimpleName()); spkiDataTypeKDV.setKeyInfo(modelKeyInfo); List<Object> spkiDataValues = spkiDataType.getSPKISexpAndAny(); for (Object spkiDataValue : spkiDataValues) { if (spkiDataValue instanceof JAXBElement) { JAXBElement spkiDataJAXB = (JAXBElement) spkiDataValue; String tagName = spkiDataJAXB.getName().getLocalPart(); KeyDataValue keyIDKDV = new KeyDataValue(); keyIDKDV.setKeyDataName(tagName); keyIDKDV.setKeyDataValue(spkiDataTypeKDV); if (spkiDataJAXB.getValue() instanceof String) { keyIDKDV.setKeyDataValueString((String) spkiDataJAXB.getValue()); } else { keyIDKDV.setKeyDataValueBytes((byte[]) spkiDataJAXB.getValue()); } spkiDataTypeKDV.getKeyDataValueList().add(keyIDKDV); } else { throw new RuntimeException("Unrecognized type: " + spkiDataValue.getClass().getCanonicalName()); } } return spkiDataTypeKDV; }