Example usage for javax.xml.namespace QName toString

List of usage examples for javax.xml.namespace QName toString

Introduction

In this page you can find the example usage for javax.xml.namespace QName toString.

Prototype

public String toString() 

Source Link

Document

<p><code>String</code> representation of this <code>QName</code>.</p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.apache.servicemix.jbi.runtime.impl.ComponentContextImpl.java

public void registerExternalEndpoint(ServiceEndpoint externalEndpoint) throws JBIException {
    try {/*w  w  w  .j av a2  s. co m*/
        QName serviceName = externalEndpoint.getServiceName();
        String endpointName = externalEndpoint.getEndpointName();
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Endpoint.NAME, serviceName.toString() + ":" + endpointName);
        props.put(Endpoint.SERVICE_NAME, serviceName.toString());
        props.put(Endpoint.ENDPOINT_NAME, endpointName);
        props.put(Endpoint.UNTARGETABLE, Boolean.TRUE.toString());
        props.put(EXTERNAL_ENDPOINT, Boolean.TRUE.toString());
        props.put(ServiceEndpoint.class.getName(), externalEndpoint);
        QName[] interfaceNames = externalEndpoint.getInterfaces();
        if (interfaceNames != null) {
            StringBuilder sb = new StringBuilder();
            for (QName itf : interfaceNames) {
                if (sb.length() > 0) {
                    sb.append(",");
                }
                sb.append(itf.toString());
            }
            props.put(Endpoint.INTERFACE_NAME, sb.toString());
        }
        Document doc = component.getComponent().getServiceDescription(externalEndpoint);
        if (doc != null) {
            String data = DOMUtil.asXML(doc);
            String url = componentRegistry.getDocumentRepository().register(data.getBytes());
            props.put(Endpoint.WSDL_URL, url);
        }
        EndpointImpl endpoint = new EndpointImpl(props);
        endpoint.setQueue(queue);
        componentRegistry.getNmr().getEndpointRegistry().register(endpoint, props);
    } catch (TransformerException e) {
        throw new JBIException(e);
    }
}

From source file:org.apache.synapse.config.xml.SynapsePathFactory.java

public static SynapsePath getSynapsePath(OMElement elem, QName attribName) throws JaxenException {

    SynapsePath path = null;/*from  w ww. ja  v  a 2s.  c  o m*/
    OMAttribute pathAttrib = elem.getAttribute(attribName);

    if (pathAttrib != null && pathAttrib.getAttributeValue() != null) {

        if (pathAttrib.getAttributeValue().startsWith("json-eval(")) {
            path = new SynapseJsonPath(
                    pathAttrib.getAttributeValue().substring(10, pathAttrib.getAttributeValue().length() - 1));
        } else {
            path = new SynapseXPath(pathAttrib.getAttributeValue());
        }

        OMElementUtils.addNameSpaces(path, elem, log);
        path.addNamespacesForFallbackProcessing(elem);

    } else {
        handleException("Couldn't find the XPath attribute with the QName : " + attribName.toString()
                + " in the element : " + elem.toString());
    }

    return path;
}

From source file:org.apache.synapse.config.xml.SynapseXPathFactory.java

public static SynapseXPath getSynapseXPath(OMElement elem, QName attribName) throws JaxenException {

    SynapseXPath xpath = null;//  w  w  w. j a va  2s.  co  m
    OMAttribute xpathAttrib = elem.getAttribute(attribName);

    if (xpathAttrib != null && xpathAttrib.getAttributeValue() != null) {

        xpath = new SynapseXPath(xpathAttrib.getAttributeValue());
        OMElementUtils.addNameSpaces(xpath, elem, log);
        xpath.addNamespacesForFallbackProcessing(elem);

    } else {
        handleException("Couldn't find the XPath attribute with the QName : " + attribName.toString()
                + " in the element : " + elem.toString());
    }

    return xpath;
}

From source file:org.apache.ws.security.processor.SignatureProcessor.java

/**
 * Verify the WS-Security signature.//from w ww  .j a v  a 2  s .  co  m
 * 
 * The functions at first checks if then <code>KeyInfo</code> that is
 * contained in the signature contains standard X509 data. If yes then
 * get the certificate data via the standard <code>KeyInfo</code> methods.
 * 
 * Otherwise, if the <code>KeyInfo</code> info does not contain X509 data, check
 * if we can find a <code>wsse:SecurityTokenReference</code> element. If yes, the next
 * step is to check how to get the certificate. Two methods are currently supported
 * here:
 * <ul>
 * <li> A URI reference to a binary security token contained in the <code>wsse:Security
 * </code> header.  If the dereferenced token is
 * of the correct type the contained certificate is extracted.
 * </li>
 * <li> Issuer name an serial number of the certificate. In this case the method
 * looks up the certificate in the keystore via the <code>crypto</code> parameter.
 * </li>
 * </ul>
 * 
 * The methods checks is the certificate is valid and calls the
 * {@link org.apache.xml.security.signature.XMLSignature#checkSignatureValue(X509Certificate) 
 * verification} function.
 *
 * @param elem        the XMLSignature DOM Element.
 * @param crypto      the object that implements the access to the keystore and the
 *                    handling of certificates.
 * @param returnCert  verifyXMLSignature stores the certificate in the first
 *                    entry of this array. The caller may then further validate
 *                    the certificate
 * @param returnElements verifyXMLSignature adds the wsu:ID attribute values for
 *               the signed elements to this Set
 * @param cb CallbackHandler instance to extract key passwords
 * @return the subject principal of the validated X509 certificate (the
 *         authenticated subject). The calling function may use this
 *         principal for further authentication or authorization.
 * @throws WSSecurityException
 */
protected Principal verifyXMLSignature(Element elem, Crypto crypto, X509Certificate[] returnCert,
        Set returnElements, List protectedElements, byte[][] signatureValue, CallbackHandler cb,
        WSDocInfo wsDocInfo) throws WSSecurityException {
    if (log.isDebugEnabled()) {
        log.debug("Verify XML Signature");
    }
    long t0 = 0, t1 = 0, t2 = 0;
    if (tlog.isDebugEnabled()) {
        t0 = System.currentTimeMillis();
    }

    XMLSignature sig = null;
    try {
        sig = new XMLSignature(elem, null);
    } catch (XMLSecurityException e2) {
        throw new WSSecurityException(WSSecurityException.FAILED_CHECK, "noXMLSig", null, e2);
    }

    sig.addResourceResolver(EnvelopeIdResolver.getInstance());

    KeyInfo info = sig.getKeyInfo();
    UsernameToken ut = null;
    DerivedKeyToken dkt = null;
    SAMLKeyInfo samlKi = null;
    SAML2KeyInfo saml2Ki = null;
    String customTokenId = null;
    java.security.PublicKey publicKey = null;
    X509Certificate[] certs = null;
    boolean validateCertificateChain = false;
    boolean kerbThumbPrint = false;
    X509Certificate cert = null;

    try {
        cert = info.getX509Certificate();
    } catch (KeyResolverException ignore) {
        if (log.isDebugEnabled()) {
            log.debug(ignore);
        }
    }

    if (info != null && info.containsKeyValue()) {
        try {
            publicKey = info.getPublicKey();
        } catch (Exception ex) {
            throw new WSSecurityException(ex.getMessage(), ex);
        }
    } else if (info != null && cert != null) {
        certs = new X509Certificate[] { cert };
    } else if (info != null) {
        Node node = WSSecurityUtil.getDirectChild(info.getElement(),
                SecurityTokenReference.SECURITY_TOKEN_REFERENCE, WSConstants.WSSE_NS);
        if (node == null) {
            throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "unsupportedKeyInfo");
        }
        SecurityTokenReference secRef = new SecurityTokenReference((Element) node);
        //
        // Here we get some information about the document that is being
        // processed, in particular the crypto implementation, and already
        // detected BST that may be used later during dereferencing.
        //
        if (secRef.containsReference()) {
            org.apache.ws.security.message.token.Reference ref = secRef.getReference();
            Element krbToken = secRef.getTokenElement(elem.getOwnerDocument(), wsDocInfo, cb);

            if (krbToken.getAttribute("ValueType").equals(
                    "http://docs.oasis-open.org/wss/oasis-wss-kerberos-token-profile-1.1#GSS_Kerberosv5_AP_REQ")) {

                KerberosTokenProcessor krbp = new KerberosTokenProcessor(this.returnResults);
                return krbp.verifyXMLSignature(elem, crypto, returnCert, returnElements, protectedElements,
                        signatureValue, cb);
            }

            String uri = ref.getURI();
            if (uri.charAt(0) == '#') {
                uri = uri.substring(1);
            }
            Processor processor = wsDocInfo.getProcessor(uri);
            if (processor == null) {
                Element token = secRef.getTokenElement(elem.getOwnerDocument(), wsDocInfo, cb);
                //
                // at this point check token type: Binary, SAML, EncryptedKey, Custom
                //
                QName el = new QName(token.getNamespaceURI(), token.getLocalName());
                if (el.equals(WSSecurityEngine.binaryToken)) {
                    certs = getCertificatesTokenReference(token, crypto);
                    if (certs != null && certs.length > 1) {
                        validateCertificateChain = true;
                    }
                } else if (el.equals(WSSecurityEngine.SAML_TOKEN)) {
                    samlKi = SAMLUtil.getSAMLKeyInfo(token, crypto, cb);
                    certs = samlKi.getCerts();
                    secretKey = samlKi.getSecret();
                } else if (el.equals(WSSecurityEngine.SAML2_TOKEN)) {
                    saml2Ki = SAML2Util.getSAML2KeyInfo(token, crypto, cb);
                    certs = saml2Ki.getCerts();
                    secretKey = saml2Ki.getSecret();

                } else if (el.equals(WSSecurityEngine.ENCRYPTED_KEY)) {
                    if (crypto == null) {
                        throw new WSSecurityException(WSSecurityException.FAILURE, "noSigCryptoFile");
                    }
                    EncryptedKeyProcessor encryptKeyProcessor = new EncryptedKeyProcessor();
                    encryptKeyProcessor.handleEncryptedKey(token, cb, crypto);
                    secretKey = encryptKeyProcessor.getDecryptedBytes();
                } else {
                    // Try custom token through callback handler
                    // try to find a custom token
                    String id = secRef.getReference().getURI();
                    if (id.charAt(0) == '#') {
                        id = id.substring(1);
                    }
                    WSPasswordCallback pwcb = new WSPasswordCallback(id, WSPasswordCallback.CUSTOM_TOKEN);
                    try {
                        Callback[] callbacks = new Callback[] { pwcb };
                        cb.handle(callbacks);
                    } catch (Exception e) {
                        throw new WSSecurityException(WSSecurityException.FAILURE, "noPassword",
                                new Object[] { id }, e);
                    }

                    secretKey = pwcb.getKey();
                    customTokenId = id;
                    if (secretKey == null) {
                        throw new WSSecurityException(WSSecurityException.INVALID_SECURITY,
                                "unsupportedKeyInfo", new Object[] { el.toString() });
                    }
                }
            } else if (processor instanceof UsernameTokenProcessor) {
                ut = ((UsernameTokenProcessor) processor).getUt();
                if (ut.isDerivedKey()) {
                    secretKey = ut.getDerivedKey();
                } else {
                    secretKey = ut.getSecretKey(secretKeyLength);
                }
            } else if (processor instanceof BinarySecurityTokenProcessor) {
                certs = ((BinarySecurityTokenProcessor) processor).getCertificates();
                if (certs != null && certs.length > 1) {
                    validateCertificateChain = true;
                }
            } else if (processor instanceof EncryptedKeyProcessor) {
                EncryptedKeyProcessor ekProcessor = (EncryptedKeyProcessor) processor;
                secretKey = ekProcessor.getDecryptedBytes();
                customTokenId = ekProcessor.getId();
            } else if (processor instanceof SecurityContextTokenProcessor) {
                SecurityContextTokenProcessor sctProcessor = (SecurityContextTokenProcessor) processor;
                secretKey = sctProcessor.getSecret();
                customTokenId = sctProcessor.getIdentifier();
            } else if (processor instanceof DerivedKeyTokenProcessor) {
                DerivedKeyTokenProcessor dktProcessor = (DerivedKeyTokenProcessor) processor;
                String signatureMethodURI = sig.getSignedInfo().getSignatureMethodURI();
                dkt = dktProcessor.getDerivedKeyToken();
                int keyLength = (dkt.getLength() > 0) ? dkt.getLength()
                        : WSSecurityUtil.getKeyLength(signatureMethodURI);

                secretKey = dktProcessor.getKeyBytes(keyLength);
            } else if (processor instanceof SAMLTokenProcessor) {
                if (crypto == null) {
                    throw new WSSecurityException(WSSecurityException.FAILURE, "noSigCryptoFile");
                }
                SAMLTokenProcessor samlp = (SAMLTokenProcessor) processor;
                samlKi = SAMLUtil.getSAMLKeyInfo(samlp.getSamlTokenElement(), crypto, cb);
                certs = samlKi.getCerts();
                secretKey = samlKi.getSecret();
                publicKey = samlKi.getPublicKey();
            } else if (processor instanceof SAML2TokenProcessor) {
                if (crypto == null)
                    throw new WSSecurityException(0, "noSigCryptoFile");
                SAML2TokenProcessor samlp = (SAML2TokenProcessor) processor;
                saml2Ki = SAML2Util.getSAML2KeyInfo(samlp.getSamlTokenElement(), crypto, cb);
                certs = saml2Ki.getCerts();
                secretKey = saml2Ki.getSecret();
            }
        } else if (secRef.containsX509Data() || secRef.containsX509IssuerSerial()) {
            certs = secRef.getX509IssuerSerial(crypto);
        } else if (secRef.containsKeyIdentifier()) {
            if (secRef.getKeyIdentifierValueType().equals(SecurityTokenReference.ENC_KEY_SHA1_URI)) {
                String id = secRef.getKeyIdentifierValue();
                WSPasswordCallback pwcb = new WSPasswordCallback(id, null,
                        SecurityTokenReference.ENC_KEY_SHA1_URI, WSPasswordCallback.ENCRYPTED_KEY_TOKEN);
                try {
                    Callback[] callbacks = new Callback[] { pwcb };
                    cb.handle(callbacks);
                } catch (Exception e) {
                    throw new WSSecurityException(WSSecurityException.FAILURE, "noPassword",
                            new Object[] { id }, e);
                }
                secretKey = pwcb.getKey();
            } else if (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType())) {
                Element token = secRef.getKeyIdentifierTokenElement(elem.getOwnerDocument(), wsDocInfo, cb);

                samlKi = SAMLUtil.getSAMLKeyInfo(token, crypto, cb);
                certs = samlKi.getCerts();
                secretKey = samlKi.getSecret();
                publicKey = samlKi.getPublicKey();
            } else if (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType())) {
                Element token = secRef.getKeyIdentifierTokenElement(elem.getOwnerDocument(), wsDocInfo, cb);
                saml2Ki = SAML2Util.getSAML2KeyInfo(token, crypto, cb);
                certs = saml2Ki.getCerts();
                secretKey = saml2Ki.getSecret();
            } else {
                certs = secRef.getKeyIdentifier(crypto);
                if (certs == null && secRef.containsKerberosThumbprint()) {
                    secretKey = secRef.getKerberosSession().getSessionKey().getEncoded();
                    kerbThumbPrint = true;
                }
            }
        } else {
            throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "unsupportedKeyInfo",
                    new Object[] { node.toString() });
        }
    } else {
        if (crypto == null) {
            throw new WSSecurityException(WSSecurityException.FAILURE, "noSigCryptoFile");
        }
        if (crypto.getDefaultX509Alias() != null) {
            certs = crypto.getCertificates(crypto.getDefaultX509Alias());
        } else {
            throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "unsupportedKeyInfo");
        }
    }
    if (tlog.isDebugEnabled()) {
        t1 = System.currentTimeMillis();
    }
    if ((certs == null || certs.length == 0 || certs[0] == null) && secretKey == null && publicKey == null
            && !kerbThumbPrint) {
        throw new WSSecurityException(WSSecurityException.FAILED_CHECK);
    }
    if (certs != null) {
        try {
            for (int i = 0; i < certs.length; i++) {
                certs[i].checkValidity();
            }
        } catch (CertificateExpiredException e) {
            throw new WSSecurityException(WSSecurityException.FAILED_CHECK, "invalidCert", null, e);
        } catch (CertificateNotYetValidException e) {
            throw new WSSecurityException(WSSecurityException.FAILED_CHECK, "invalidCert", null, e);
        }
    }
    //
    // Delegate verification of a public key to a Callback Handler
    //
    if (publicKey != null) {
        PublicKeyCallback pwcb = new PublicKeyCallback(publicKey);
        try {
            Callback[] callbacks = new Callback[] { pwcb };
            cb.handle(callbacks);
            if (!pwcb.isVerified()) {
                throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION, null, null, null);
            }
        } catch (Exception e) {
            throw new WSSecurityException(WSSecurityException.FAILED_AUTHENTICATION, null, null, e);
        }
    }
    try {
        boolean signatureOk = false;
        if (certs != null) {
            signatureOk = sig.checkSignatureValue(certs[0]);
        } else if (publicKey != null) {
            signatureOk = sig.checkSignatureValue(publicKey);
        } else {
            signatureOk = sig.checkSignatureValue(sig.createSecretKey(secretKey));
        }
        if (signatureOk) {
            if (tlog.isDebugEnabled()) {
                t2 = System.currentTimeMillis();
                tlog.debug("Verify: total= " + (t2 - t0) + ", prepare-cert= " + (t1 - t0) + ", verify= "
                        + (t2 - t1));
            }
            signatureValue[0] = sig.getSignatureValue();
            //
            // Now dig into the Signature element to get the elements that
            // this Signature covers. Build the QName of these Elements and
            // return them to caller
            //
            SignedInfo si = sig.getSignedInfo();
            int numReferences = si.getLength();
            for (int i = 0; i < numReferences; i++) {
                Reference siRef;
                try {
                    siRef = si.item(i);
                } catch (XMLSecurityException e3) {
                    throw new WSSecurityException(WSSecurityException.FAILED_CHECK, null, null, e3);
                }
                String uri = siRef.getURI();
                if (uri != null && !"".equals(uri)) {

                    Element se = null;
                    try {
                        Transforms transforms = siRef.getTransforms();
                        for (int j = 0; j < transforms.getLength(); j++) {
                            Transform transform = transforms.item(j);
                            // We have some transforming to do before we can 
                            // determine the protected element.
                            if (STRTransform.implementedTransformURI.equals(transform.getURI())) {

                                XMLSignatureInput signatureInput = siRef.getContentsBeforeTransformation();

                                if (signatureInput.isElement()) {
                                    // The signature was already validated,
                                    // meaning that this element was already
                                    // parsed.  We can therefore be pretty
                                    // confident that this constructor will work.
                                    SecurityTokenReference secTokenRef = new SecurityTokenReference(
                                            (Element) signatureInput.getSubNode());

                                    // Use the utility to extract the element (or
                                    // generate a new one in some cases) from the
                                    // message.
                                    se = STRTransformUtil.dereferenceSTR(transform.getDocument(), secTokenRef,
                                            wsDocInfo);
                                } else {
                                    // The internal impl of Reference changed.
                                    // We expect it to return the signature input
                                    // based on a node/element.
                                    throw new WSSecurityException(WSSecurityException.FAILURE);
                                }
                            }
                        }
                    } catch (XMLSecurityException e) {
                        log.warn("Error processing signature coverage elements.", e);
                        throw new WSSecurityException(WSSecurityException.FAILURE);
                    }

                    if (se == null) {
                        se = WSSecurityUtil.getElementByWsuId(elem.getOwnerDocument(), uri);
                    }
                    if (se == null) {
                        se = WSSecurityUtil.getElementByGenId(elem.getOwnerDocument(), uri);
                    }
                    if (se == null) {
                        throw new WSSecurityException(WSSecurityException.FAILED_CHECK);
                    }
                    WSDataRef ref = new WSDataRef(uri);
                    ref.setWsuId(uri);
                    ref.setName(new QName(se.getNamespaceURI(), se.getLocalName()));
                    ref.setProtectedElement(se);
                    ref.setXpath(ReferenceListProcessor.getXPath(se));
                    ref.setAlgorithm(si.getSignatureMethodURI());
                    ref.setDigestAlgorithm(siRef.getMessageDigestAlgorithm().getAlgorithmURI());
                    protectedElements.add(ref);
                    returnElements.add(WSSecurityUtil.getIDFromReference(uri));
                } else {
                    // This is the case where the signed element is identified 
                    // by a transform such as XPath filtering
                    // We add the complete reference element to the return 
                    // elements
                    returnElements.add(siRef);
                }
            }

            // Algorithms used for signature and c14n
            signatureMethod = si.getSignatureMethodURI();
            c14nMethod = si.getCanonicalizationMethodURI();

            if (certs != null) {
                returnCert[0] = certs[0];
                if (validateCertificateChain) {
                    certificates = certs;
                }
                return certs[0].getSubjectX500Principal();
            } else if (publicKey != null) {
                return new PublicKeyPrincipal(publicKey);
            } else if (ut != null) {
                WSUsernameTokenPrincipal principal = new WSUsernameTokenPrincipal(ut.getName(), ut.isHashed());
                principal.setNonce(ut.getNonce());
                principal.setPassword(ut.getPassword());
                principal.setCreatedTime(ut.getCreated());
                return principal;
            } else if (dkt != null) {
                WSDerivedKeyTokenPrincipal principal = new WSDerivedKeyTokenPrincipal(dkt.getID());
                principal.setNonce(dkt.getNonce());
                principal.setLabel(dkt.getLabel());
                principal.setLength(dkt.getLength());
                principal.setOffset(dkt.getOffset());
                String basetokenId = null;
                SecurityTokenReference securityTokenReference = dkt.getSecurityTokenReference();
                if (securityTokenReference.containsReference()) {
                    basetokenId = securityTokenReference.getReference().getURI();
                    if (basetokenId.charAt(0) == '#') {
                        basetokenId = basetokenId.substring(1);
                    }
                } else {
                    // KeyIdentifier
                    basetokenId = securityTokenReference.getKeyIdentifierValue();
                }
                principal.setBasetokenId(basetokenId);
                return principal;
            } else if (samlKi != null) {
                final SAMLAssertion assertion = samlKi.getAssertion();
                CustomTokenPrincipal principal = new CustomTokenPrincipal(assertion.getId());
                principal.setTokenObject(assertion);
                return principal;

            } else if (saml2Ki != null) {
                Assertion assertion = saml2Ki.getAssertion();
                CustomTokenPrincipal principal = new CustomTokenPrincipal(assertion.getID());
                principal.setTokenObject(assertion);
                return principal;
            } else if (secretKey != null) {
                // This is the custom key scenario
                CustomTokenPrincipal principal = new CustomTokenPrincipal(customTokenId);
                return principal;
            } else {
                throw new WSSecurityException("Cannot determine principal");
            }
        } else {
            throw new WSSecurityException(WSSecurityException.FAILED_CHECK);
        }
    } catch (XMLSignatureException e1) {
        throw new WSSecurityException(WSSecurityException.FAILED_CHECK, null, null, e1);
    }
}

From source file:org.apereo.portal.portlet.rendering.PortletEventCoordinatationService.java

protected boolean isGlobalEvent(HttpServletRequest request, IPortletWindowId sourceWindowId, Event event) {
    final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, sourceWindowId);
    final IPortletEntity portletEntity = portletWindow.getPortletEntity();
    final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();
    final IPortletDefinitionId portletDefinitionId = portletDefinition.getPortletDefinitionId();
    final PortletApplicationDefinition parentPortletApplicationDescriptor = this.portletDefinitionRegistry
            .getParentPortletApplicationDescriptor(portletDefinitionId);

    final ContainerRuntimeOption globalEvents = parentPortletApplicationDescriptor
            .getContainerRuntimeOption(GLOBAL_EVENT__CONTAINER_OPTION);
    if (globalEvents != null) {
        final QName qName = event.getQName();
        final String qNameStr = qName.toString();
        for (final String globalEvent : globalEvents.getValues()) {
            if (qNameStr.equals(globalEvent)) {
                return true;
            }//ww w. j  av  a  2 s  .c  o  m
        }
    }

    return false;
}

From source file:org.artificer.repository.hibernate.data.SrampToHibernateEntityRelationshipsVisitor.java

private ArtificerRelationship createRelationship(String relationshipName, RelationshipType relationshipType,
        Map<QName, String> relationshipOtherAttributes) throws Exception {
    ArtificerRelationship artificerRelationship = new ArtificerRelationship();
    artificerRelationship.setName(relationshipName);
    artificerRelationship.setType(relationshipType);
    artificerRelationship.setOwner(artificerArtifact);
    for (QName key : relationshipOtherAttributes.keySet()) {
        String value = relationshipOtherAttributes.get(key);
        artificerRelationship.getOtherAttributes().put(key.toString(), value);
    }/*from  w  w w . j  a v a  2 s  . c  o  m*/
    return artificerRelationship;
}

From source file:org.artificer.repository.hibernate.data.SrampToHibernateEntityRelationshipsVisitor.java

private void createTarget(ArtificerRelationship artificerRelationship, Target target) throws Exception {
    ArtificerTarget artificerTarget = new ArtificerTarget();
    artificerTarget.setTarget(relationshipFactory.createRelationship(target.getValue(), entityManager));

    // Use reflection to get the 'artifact type' enum attribute found on
    // most (all?) targets.  Unfortunately, the method and field are
    // redefined in each subclass of Target.
    // Get ^^^ changed in the spec!
    try {//from   w w w .  j a v a2s. co  m
        Method m = target.getClass().getMethod("getArtifactType");
        Object o = m.invoke(target); // the enum itself
        m = o.getClass().getMethod("name");
        String targetType = (String) m.invoke(o);
        artificerTarget.setTargetType(targetType);
    } catch (Exception e) {
        // eat it
    }

    artificerTarget.setRelationship(artificerRelationship);
    for (QName key : target.getOtherAttributes().keySet()) {
        String value = target.getOtherAttributes().get(key);
        artificerTarget.getOtherAttributes().put(key.toString(), value);
    }
    artificerRelationship.getTargets().add(artificerTarget);
}

From source file:org.artificer.repository.jcr.mapper.ArtifactToJCRNodeVisitor.java

private void setOtherAttributes(Node node, Map<QName, String> otherAttributes) throws Exception {
    // store any 'other' attributes
    String attributeKeyPrefix = JCRConstants.SRAMP_OTHER_ATTRIBUTES + ":";
    for (QName qname : otherAttributes.keySet()) {
        String attributeKey = attributeKeyPrefix + qname.toString();
        String attributeValue = otherAttributes.get(qname);
        if (StringUtils.isEmpty(attributeValue)) {
            // Need to support no-value properties, but JCR will remove it if it's null.  Further, if it's an
            // empty string, the property existence query fails.  Therefore, use a placeholder that will eventually
            // be removed by JCRNodeToArtifactVisitor.
            attributeValue = JCRConstants.NO_VALUE;
        }/*w  ww .  j a  va2  s.c o m*/
        node.setProperty(attributeKey, attributeValue);
    }
}

From source file:org.cloudfoundry.identity.uaa.provider.saml.LoginSamlAuthenticationProvider.java

protected String getStringValue(String key, SamlIdentityProviderDefinition definition, XMLObject xmlObject) {
    String value = null;//from  w  ww.j  a va2  s .  c  om
    if (xmlObject instanceof XSString) {
        value = ((XSString) xmlObject).getValue();
    } else if (xmlObject instanceof XSAny) {
        value = ((XSAny) xmlObject).getTextContent();
    } else if (xmlObject instanceof XSInteger) {
        Integer i = ((XSInteger) xmlObject).getValue();
        value = i != null ? i.toString() : null;
    } else if (xmlObject instanceof XSBoolean) {
        XSBooleanValue b = ((XSBoolean) xmlObject).getValue();
        value = b != null && b.getValue() != null ? b.getValue().toString() : null;
    } else if (xmlObject instanceof XSDateTime) {
        DateTime d = ((XSDateTime) xmlObject).getValue();
        value = d != null ? d.toString() : null;
    } else if (xmlObject instanceof XSQName) {
        QName name = ((XSQName) xmlObject).getValue();
        value = name != null ? name.toString() : null;
    } else if (xmlObject instanceof XSURI) {
        value = ((XSURI) xmlObject).getValue();
    } else if (xmlObject instanceof XSBase64Binary) {
        value = ((XSBase64Binary) xmlObject).getValue();
    }

    if (value != null) {
        logger.debug(String.format("Found SAML user attribute %s of value %s [zone:%s, origin:%s]", key, value,
                definition.getZoneId(), definition.getIdpEntityAlias()));
        return value;
    } else if (xmlObject != null) {
        logger.debug(String.format(
                "SAML user attribute %s at is not of type XSString or other recognizable type, %s [zone:%s, origin:%s]",
                key, xmlObject.getClass().getName(), definition.getZoneId(), definition.getIdpEntityAlias()));
    }
    return null;
}

From source file:org.cloudgraph.config.CloudGraphConfig.java

/**
 * Returns a table configuration for the given qualified SDO 
 * Type name.//from   www .  j a v  a2  s  .  c o  m
 * @param typeName the qualified name of an SDO Type 
 * @return the table configuration
 * @throws CloudGraphConfigurationException if the given name is not found
 */
public TableConfig getTable(QName typeName) {
    TableConfig result = findTable(typeName);
    if (result == null)
        throw new CloudGraphConfigurationException(
                "no HTable configured for " + " graph URI '" + typeName.toString() + "'");
    return result;
}