List of usage examples for javax.xml.bind JAXBElement getName
public QName getName()
From source file:org.apache.openaz.xacml.admin.model.PolicyContainer.java
@Override public Collection<?> getChildren(Object itemId) { final Collection<Object> items = new ArrayList<Object>(); if (itemId instanceof PolicySetType) { PolicySetType policySet = (PolicySetType) itemId; if (policySet.getTarget() != null) { items.add(policySet.getTarget()); }//from www . j av a2s.c o m if (policySet.getObligationExpressions() != null) { items.addAll(policySet.getObligationExpressions().getObligationExpression()); } if (policySet.getAdviceExpressions() != null) { items.addAll(policySet.getAdviceExpressions().getAdviceExpression()); } List<JAXBElement<?>> children = policySet.getPolicySetOrPolicyOrPolicySetIdReference(); for (JAXBElement<?> element : children) { if (element.getName().getLocalPart().equals("PolicySet")) { items.add(element.getValue()); } else if (element.getName().getLocalPart().equals("Policy")) { items.add(element.getValue()); } } } else if (itemId instanceof PolicyType) { PolicyType policy = (PolicyType) itemId; if (policy.getTarget() != null) { items.add(policy.getTarget()); } List<Object> objs = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition(); for (Object obj : objs) { if (obj instanceof VariableDefinitionType) { items.add(obj); } else if (obj instanceof RuleType) { items.add(obj); } } if (policy.getObligationExpressions() != null) { items.addAll(policy.getObligationExpressions().getObligationExpression()); } if (policy.getAdviceExpressions() != null) { items.addAll(policy.getAdviceExpressions().getAdviceExpression()); } } else if (itemId instanceof RuleType) { RuleType rule = (RuleType) itemId; if (rule.getTarget() != null) { items.add(rule.getTarget()); } if (rule.getCondition() != null) { items.add(rule.getCondition()); } if (rule.getObligationExpressions() != null) { items.addAll(((RuleType) itemId).getObligationExpressions().getObligationExpression()); } if (rule.getAdviceExpressions() != null) { items.addAll(rule.getAdviceExpressions().getAdviceExpression()); } } else if (itemId instanceof TargetType) { for (AnyOfType anyof : ((TargetType) itemId).getAnyOf()) { items.add(anyof); } } else if (itemId instanceof AnyOfType) { for (AllOfType allof : ((AnyOfType) itemId).getAllOf()) { items.add(allof); } } else if (itemId instanceof AllOfType) { for (MatchType match : ((AllOfType) itemId).getMatch()) { items.add(match); } } if (logger.isTraceEnabled()) { logger.trace("getChildren: " + itemId + "(" + items.size() + ") " + items); } return Collections.unmodifiableCollection(items); }
From source file:org.apache.openaz.xacml.util.XACMLPolicyScanner.java
/** * @param parent/*from w ww . j a va 2 s . c om*/ * @param policySet * @return */ protected CallbackResult scanPolicySet(PolicySetType parent, PolicySetType policySet) { if (logger.isTraceEnabled()) { logger.trace("scanning policy set: " + policySet.getPolicySetId() + " " + policySet.getDescription()); } if (this.callback != null && this.callback.onPreVisitPolicySet(parent, policySet) == CallbackResult.STOP) { return CallbackResult.STOP; } // // Scan its info // if (this.scanTarget(policySet, policySet.getTarget()) == CallbackResult.STOP) { return CallbackResult.STOP; } if (this.scanObligations(policySet, policySet.getObligationExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; } if (this.scanAdvice(policySet, policySet.getAdviceExpressions()) == CallbackResult.STOP) { return CallbackResult.STOP; } // // Iterate the policy sets and/or policies // List<JAXBElement<?>> list = policySet.getPolicySetOrPolicyOrPolicySetIdReference(); for (JAXBElement<?> element : list) { if (element.getName().getLocalPart().equals("PolicySet")) { if (this.scanPolicySet(policySet, (PolicySetType) element.getValue()) == CallbackResult.STOP) { return CallbackResult.STOP; } } else if (element.getName().getLocalPart().equals("Policy")) { if (this.scanPolicy(policySet, (PolicyType) element.getValue()) == CallbackResult.STOP) { return CallbackResult.STOP; } } else if (element.getValue() instanceof IdReferenceType) { //NOPMD /*TODO if (element.getName().getLocalPart().equals("PolicySetIdReference")) { } else if (element.getName().getLocalPart().equals("PolicyIdReference")) { }*/ } else { logger.warn( "generating policy sets found unsupported element: " + element.getName().getNamespaceURI()); } } if (this.callback != null && this.callback.onPostVisitPolicySet(parent, policySet) == CallbackResult.STOP) { return CallbackResult.STOP; } return CallbackResult.CONTINUE; }
From source file:org.apache.xml.security.stax.ext.XMLSecurityUtils.java
@SuppressWarnings("unchecked") public static <T> T getQNameType(List<Object> objects, QName qName) { for (int i = 0; i < objects.size(); i++) { Object o = objects.get(i); if (o instanceof JAXBElement) { JAXBElement<?> jaxbElement = (JAXBElement<?>) o; if (jaxbElement.getName().equals(qName)) { return (T) jaxbElement.getValue(); }//from ww w.j a v a2 s. c om } } return null; }
From source file:org.atricore.idbus.capabilities.sso.main.idp.producers.SingleSignOnProducer.java
protected SamlR2SecurityTokenEmissionContext emitAssertionFromPreviousSession(CamelMediationExchange exchange, SamlR2SecurityTokenEmissionContext securityTokenEmissionCtx, AuthnRequestType authnRequest, IdPSecurityContext secCtx) throws Exception { // TODO : We need to use the STS ..., and get ALL the required tokens again. // TODO : Set in assertion AuthnCtxClass.PREVIOUS_SESSION_AUTHN_CTX ClaimSet claims = new ClaimSetImpl(); UsernameTokenType usernameToken = new UsernameTokenType(); for (Iterator<Principal> iterator = secCtx.getSubject().getPrincipals().iterator(); iterator.hasNext();) { Principal next = iterator.next(); if (next instanceof SimplePrincipal) { SimplePrincipal principal = (SimplePrincipal) next; // Get previously used authn-ctx class AuthnCtxClass authnCtx = null; List<JAXBElement<?>> c = secCtx.getAuthnStatement().getAuthnContext().getContent(); if (c != null && c.size() > 0) { for (JAXBElement e : c) { if (e.getName().getLocalPart().equals("AuthnContextClassRef")) { authnCtx = AuthnCtxClass.asEnum((String) e.getValue()); break; }// www . j a v a 2s . co m } } if (authnCtx == null) { logger.warn("No previous authentication context class, forcing Password"); authnCtx = AuthnCtxClass.PASSWORD_AUTHN_CTX; } AttributedString usernameString = new AttributedString(); usernameString.setValue(principal.getName()); usernameToken.setUsername(usernameString); usernameToken.getOtherAttributes().put(new QName(Constants.PASSWORD_NS), principal.getName()); usernameToken.getOtherAttributes().put(new QName(authnCtx.getValue()), "TRUE"); usernameToken.getOtherAttributes().put(new QName(Constants.PREVIOUS_SESSION_NS), "TRUE"); RequestedAuthnContextType reqAuthn = authnRequest.getRequestedAuthnContext(); if (reqAuthn != null) { // TODO : We should honor the originally requested authentication context! logger.warn("Requested Authentication context class ignored !!!! " + reqAuthn); } //CredentialClaim credentialClaim = new CredentialClaimImpl(AuthnCtxClass.PASSWORD_AUTHN_CTX.getValue(), usernameToken); CredentialClaim credentialClaim = new CredentialClaimImpl(authnCtx.getValue(), usernameToken); claims.addClaim(credentialClaim); } } securityTokenEmissionCtx = emitAssertionFromClaims(exchange, securityTokenEmissionCtx, claims, securityTokenEmissionCtx.getMember()); AssertionType assertion = securityTokenEmissionCtx.getAssertion(); //Subject authnSubject = securityTokenEmissionCtx.getSubject(); logger.debug("New Assertion " + assertion.getID() + " emitted form request " + (authnRequest != null ? authnRequest.getID() : "<NULL>")); return securityTokenEmissionCtx; }
From source file:org.atricore.idbus.capabilities.sso.support.core.signature.JSR105SamlR2SignerImpl.java
protected byte[] getBinCertificate(RoleDescriptorType md) { byte[] x509CertificateBin = null; if (md.getKeyDescriptor() != null && md.getKeyDescriptor().size() > 0) { for (KeyDescriptorType keyMd : md.getKeyDescriptor()) { if (!keyMd.getUse().equals(KeyTypes.SIGNING)) continue; if (keyMd.getKeyInfo() != null) { // Get inside Key Info List contentMd = keyMd.getKeyInfo().getContent(); if (contentMd != null && contentMd.size() > 0) { for (Object o : contentMd) { if (o instanceof JAXBElement) { JAXBElement e = (JAXBElement) o; if (e.getValue() instanceof X509DataType) { X509DataType x509Data = (X509DataType) e.getValue(); for (Object x509Content : x509Data .getX509IssuerSerialOrX509SKIOrX509SubjectName()) { if (x509Content instanceof JAXBElement) { JAXBElement x509Certificate = (JAXBElement) x509Content; if (x509Certificate.getName().getNamespaceURI() .equals("http://www.w3.org/2000/09/xmldsig#") && x509Certificate.getName().getLocalPart() .equals("X509Certificate")) { x509CertificateBin = (byte[]) x509Certificate.getValue(); break; } }// w w w . ja va 2 s. c o m } } } if (x509CertificateBin != null) break; } } } else { logger.debug("Metadata Key Descriptor does not have KeyInfo " + keyMd.toString()); } if (x509CertificateBin != null) break; } } else { logger.debug("Metadata does not have Key Descriptors: " + md.getID()); } if (logger.isTraceEnabled()) { logger.trace("MD Sign Certificate: " + Arrays.toString(x509CertificateBin)); } return x509CertificateBin; }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.common.source.TestCswSourceBase.java
protected CswRecordCollection generateCswCollection(String file) { InputStream stream = getClass().getResourceAsStream(file); GetRecordsResponseType recordsResponse = parseXml(stream); GetRecordsResponseType records = new GetRecordsResponseType(); recordsResponse.copyTo(records);/*from w w w.jav a 2s . c o m*/ List<Metacard> cswRecords = new LinkedList<>(); for (JAXBElement<? extends AbstractRecordType> rec : records.getSearchResults().getAbstractRecord()) { MetacardImpl metacard = new MetacardImpl(); cswRecords.add(metacard); if (rec.getValue() instanceof BriefRecordType) { BriefRecordType record = (BriefRecordType) rec.getValue(); metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0)); if (!CollectionUtils.isEmpty(record.getType().getContent())) { metacard.setContentTypeName(record.getType().getContent().get(0)); } } else if (rec.getValue() instanceof SummaryRecordType) { SummaryRecordType record = (SummaryRecordType) rec.getValue(); metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0)); if (!CollectionUtils.isEmpty(record.getType().getContent())) { metacard.setContentTypeName(record.getType().getContent().get(0)); } } else if (rec.getValue() instanceof RecordType) { RecordType record = (RecordType) rec.getValue(); for (JAXBElement<SimpleLiteral> jb : record.getDCElement()) { if ("identifier".equals(jb.getName().getLocalPart())) { metacard.setId(jb.getValue().getContent().get(0)); } if ("type".equals(jb.getName().getLocalPart()) && !CollectionUtils.isEmpty(jb.getValue().getContent())) { metacard.setContentTypeName(jb.getValue().getContent().get(0)); } } } } CswRecordCollection collection = new CswRecordCollection(); collection.setCswRecords(cswRecords); collection.setNumberOfRecordsMatched(records.getSearchResults().getNumberOfRecordsMatched().intValue()); collection.setNumberOfRecordsReturned(records.getSearchResults().getNumberOfRecordsReturned().intValue()); return collection; }
From source file:org.codice.ddf.spatial.ogc.csw.catalog.source.TestCswSourceBase.java
protected CswRecordCollection generateCswCollection(String file) { InputStream stream = getClass().getResourceAsStream(file); GetRecordsResponseType recordsResponse = parseXml(stream); GetRecordsResponseType records = new GetRecordsResponseType(); recordsResponse.copyTo(records);/*from w ww.jav a 2 s. c o m*/ List<Metacard> cswRecords = new LinkedList<Metacard>(); for (JAXBElement<? extends AbstractRecordType> rec : records.getSearchResults().getAbstractRecord()) { MetacardImpl metacard = new MetacardImpl(); cswRecords.add(metacard); if (rec.getValue() instanceof BriefRecordType) { BriefRecordType record = (BriefRecordType) rec.getValue(); metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0)); if (!CollectionUtils.isEmpty(record.getType().getContent())) { metacard.setContentTypeName(record.getType().getContent().get(0)); } } else if (rec.getValue() instanceof SummaryRecordType) { SummaryRecordType record = (SummaryRecordType) rec.getValue(); metacard.setId(record.getIdentifier().get(0).getValue().getContent().get(0)); if (!CollectionUtils.isEmpty(record.getType().getContent())) { metacard.setContentTypeName(record.getType().getContent().get(0)); } } else if (rec.getValue() instanceof RecordType) { RecordType record = (RecordType) rec.getValue(); for (JAXBElement<SimpleLiteral> jb : record.getDCElement()) { if ("identifier".equals(jb.getName().getLocalPart())) { metacard.setId(jb.getValue().getContent().get(0)); } if ("type".equals(jb.getName().getLocalPart()) && !CollectionUtils.isEmpty(jb.getValue().getContent())) { metacard.setContentTypeName(jb.getValue().getContent().get(0)); } } } } CswRecordCollection collection = new CswRecordCollection(); collection.setCswRecords(cswRecords); collection.setNumberOfRecordsMatched(records.getSearchResults().getNumberOfRecordsMatched().intValue()); collection.setNumberOfRecordsReturned(records.getSearchResults().getNumberOfRecordsReturned().intValue()); return collection; }
From source file:org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.TestWfs10JTStoGML200Converter.java
@Test public void testPolygonTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException { Polygon polygon = (Polygon) getGeometryFromWkt(POLYGON); assertThat(polygon == null, is(Boolean.FALSE)); String polygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(polygon); PolygonType polygonType = (PolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(polygonGML, Wfs10Constants.POLYGON);//from w w w .j a va 2 s .co m assertThat(null != polygonType, is(Boolean.TRUE)); JAXBElement<PolygonType> polygonTypeJAXBElement = (JAXBElement<PolygonType>) Wfs10JTStoGML200Converter .convertGeometryTypeToJAXB(polygonType); assertThat(polygonTypeJAXBElement.getName().getLocalPart().equals(Wfs10Constants.POLYGON.getLocalPart()), is(Boolean.TRUE)); assertThat(polygonTypeJAXBElement.getDeclaredType() == PolygonType.class, is(Boolean.TRUE)); JAXB.marshal(polygonTypeJAXBElement, writer); String xml = writer.toString(); Diff diff = XMLUnit.compareXML(xml, POLYGON_GML); assertTrue(XMLUNIT_SIMILAR, diff.similar()); assertThat(diff.similar(), is(Boolean.TRUE)); assertThat(diff.identical(), is(Boolean.FALSE)); }
From source file:org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.TestWfs10JTStoGML200Converter.java
private String extractPointMemberTypeCoordinates(JAXBElement<? extends GeometryAssociationType> jaxbElement1) throws JAXBException, SAXException, IOException, ParseException, NullPointerException { assertThat(Wfs10Constants.POINT_MEMBER.getLocalPart().equals(jaxbElement1.getName().getLocalPart()), is(Boolean.TRUE));/* w w w. jav a 2 s . c o m*/ PointMemberType pointMemberType1 = (PointMemberType) jaxbElement1.getValue(); JAXBElement<? extends AbstractGeometryType> geometry1 = pointMemberType1.getGeometry(); assertThat(Wfs10Constants.POINT.getLocalPart().equals(geometry1.getName().getLocalPart()), is(Boolean.TRUE)); return ((PointType) geometry1.getValue()).getCoordinates().getValue().replaceAll("\n", "").trim(); }
From source file:org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.TestWfs10JTStoGML200Converter.java
private String extractLineStringMemberCoordinates(JAXBElement element1) throws JAXBException, SAXException, IOException, ParseException, NullPointerException { assertThat(Wfs10Constants.LINESTRING_MEMBER.getLocalPart().equals(element1.getName().getLocalPart()), is(Boolean.TRUE));/*from ww w . j a va2s . c o m*/ LineStringMemberType lsMemberType1 = (LineStringMemberType) element1.getValue(); JAXBElement geometry1 = lsMemberType1.getGeometry(); LineStringType lineStringType = (LineStringType) geometry1.getValue(); return lineStringType.getCoordinates().getValue().replaceAll("\n", "").trim(); }