Package org.wso2.xkms2

Examples of org.wso2.xkms2.Status


    public static boolean validateCertPath(X509Certificate cert,
                                           String serviceURL) {
        try {

            ValidateRequest request = createValidateRequest();
            request.setServiceURI(serviceURL);

            QueryKeyBinding keyBinding = createQueryKeyBinding();
            keyBinding.setCertValue(cert);

            String name = cert.getSubjectDN().getName();
            keyBinding.addUseKeyWith(UseKeyWith.PKIX, name);

            request.setQueryKeyBinding(keyBinding);
            request.addRespondWith(RespondWith.X_509_CERT);

            OMElement element = getElement(request);
            OMElement result = sendReceive(element, serviceURL);
            result = buildElement(result);
View Full Code Here


        recoverRequest.setId(XKMSUtil.getRamdomId());
        return recoverRequest;
    }

    public static ValidateRequest createValidateRequest() {
        ValidateRequest validate = new ValidateRequest();
        validate.setId(XKMSUtil.getRamdomId());
        return validate;
    }
View Full Code Here

            OMElement element = getElement(request);
            OMElement result = sendReceive(element, serviceURL);
            result = buildElement(result);

            ValidateResult validateResult = getValidateResult(result);
            List keybinds = validateResult.getKeyBindingList();
            KeyBinding keybinding = (KeyBinding) keybinds.get(0);

            Status status = keybinding.getStatus();

            return StatusValue.VALID.equals(status.getStatusValue());
View Full Code Here

        locateResult.setId(getRamdomId());
        return locateResult;
    }
   
    public static ValidateResult createValidateResult() {
        ValidateResult validateResult = new ValidateResult();
        validateResult.setId(getRamdomId());
        return validateResult;
    }
View Full Code Here

            if (cert == null) {
                throw new XKMSException(XKMSException.FAILURE, "CertNotPresent");
            }

            if (verifyTrust(cert)) {
                ValidateResult validateResult = XKMSUtil.createValidateResult();
                buildResultType((RequestAbstractType) validateRequest,
                        (ResultType) validateResult);

                String subjectDN = cert.getIssuerDN().getName();
                BigInteger issuerSerial = cert.getSerialNumber();

                String alias = getAliasForX509Cert(subjectDN, issuerSerial);
                X509Certificate[] certs = getCertificates(alias);

                KeyBinding keyBinding = XKMSUtil.createKeyBinding();
                validateResult.addKeyBinding(keyBinding);

                addKeyInfo(respondWith, alias, certs, keyBinding);
                addKeyUsage(certs[0], keyBinding);
                addStatus(true, keyBinding);

                return validateResult;

            } else {

                ValidateResult result = XKMSUtil.createValidateResult();
                buildResultType((RequestAbstractType) validateRequest,
                        (ResultType) result);

                KeyBinding keybinding = XKMSUtil.createKeyBinding();
                X509Certificate[] certs = new X509Certificate[] { cert };

                addKeyInfo(validateRequest.getRespondWith(), null, certs,
                        keybinding);
                addKeyUsage(certs[0], keybinding);
                addStatus(false, keybinding);
                result.addKeyBinding(keybinding);

                return result;
            }

        } catch (XKMSException ex) {
            ValidateResult resultType = XKMSUtil.createValidateResult();
            buildFault(validateRequest, resultType, ex);
            return resultType;
        }
    }
View Full Code Here

        return prototypeKeyBinding;
    }

    private void processValidityInterval(OMElement validityIntervalElem)
            throws XKMSException {
        ValidityInterval validityInterval = new ValidityInterval();

        String strNotBefore = validityIntervalElem
                .getAttributeValue(XKMS2Constants.Q_ATTR_NOT_BEFORE);
        String strNotOnOrAfter = validityIntervalElem
                .getAttributeValue(XKMS2Constants.Q_ATTR_NOT_ON_OR_AFTER);

        DateFormat zulu = new XmlSchemaDateFormat();

        try {
            if (strNotBefore != null) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(zulu.parse(strNotBefore));
                validityInterval.setNotBefore(calendar);
            }

            if (strNotOnOrAfter != null) {
                Calendar calendar = Calendar.getInstance();
                calendar.setTime(zulu.parse(strNotOnOrAfter));
                validityInterval.setNotOnOrAfter(calendar);
            }

        } catch (ParseException xkmse) {
            throw new XKMSException(xkmse);
        }
View Full Code Here

                public1 = keypair.getPublic();
                private1 = keypair.getPrivate();
            }

            // calculating the start and expiery dates.
            ValidityInterval validityInterval = pkb.getValidityInterval();
            Date[] adjustedInterval;
            if (validityInterval != null) {
                adjustedInterval = getAdjustedValidityInterval(validityInterval
                        .getNotBefore(), validityInterval.getOnOrAfter());
            } else {
                adjustedInterval = getAdjustedValidityInterval((Date) null,
                        (Date) null);
            }
View Full Code Here

                calendar.setTime(zulu.parse(strNotOnOrAfter));
                validityInterval.setNotOnOrAfter(calendar);
            }

        } catch (ParseException xkmse) {
            throw new XKMSException(xkmse);
        }

        prototypeKeyBinding.setValidityInterval(validityInterval);
    }
View Full Code Here

            return factory.newDocumentBuilder().parse(bais)
                    .getDocumentElement();

        } catch (XMLStreamException e) {
            log.error(e);
            throw new XKMSException(e);
        } catch (IOException e) {
            log.error(e);
            throw new XKMSException(e);
        } catch (ParserConfigurationException e) {
            log.error(e);
            throw new XKMSException(e);
        } catch (SAXException e) {
            log.error(e);
            throw new XKMSException(e);
        }

    }
View Full Code Here

            buider = new StAXOMBuilder(new ByteArrayInputStream(bos
                    .toByteArray()));
            return buider.getDocumentElement();
        } catch (IOException e) {
            log.error(e);
            throw new XKMSException(e);
        } catch (CanonicalizationException e) {
            log.error(e);
            throw new XKMSException(e);
        } catch (InvalidCanonicalizerException e) {
            log.error(e);
            throw new XKMSException(e);
        } catch (XMLStreamException e) {
            log.error(e);
            throw new XKMSException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.wso2.xkms2.Status

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.