Package org.wso2.xkms2

Examples of org.wso2.xkms2.Authentication


                List keybindings = locateResult.getUnverifiedKeyBindingList();
                String[] aliases = new String[keybindings.size()];

                for (int i = 0; i < keybindings.size(); i++) {
                    UnverifiedKeyBinding unverifiedKeybinding = (UnverifiedKeyBinding) keybindings
                            .get(i);
                    KeyInfo keyInfo = unverifiedKeybinding.getKeyInfo();
                    aliases[i] = keyInfo.itemKeyName(0).getKeyName();
                }
                return aliases;
            }
View Full Code Here


            buildResultType((RequestAbstractType) locate, (ResultType) result);

            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                String alias = (String) iterator.next();
                X509Certificate[] certs = getCertificates(alias);
                UnverifiedKeyBinding ukb = new UnverifiedKeyBinding();

                addKeyInfo(locate.getRespondWith(), alias, certs, ukb);
                addKeyUsage(certs[0], ukb);
                result.addUnverifiedKeyBinding(ukb);
            }
View Full Code Here

        if (useKeyWiths == null || useKeyWiths.isEmpty()) {
            return null;
        }

        for (Iterator iterator = useKeyWiths.iterator(); iterator.hasNext();) {
            UseKeyWith useKeyWith = (UseKeyWith) iterator.next();

            if (UseKeyWith.PKIX.equals(useKeyWith.getApplication())) {
                return useKeyWith.getIdentifier();
            }
        }

        return null;
    }
View Full Code Here

        if (useKeyWiths == null || useKeyWiths.isEmpty()) {
            return null;
        }

        for (Iterator iterator = useKeyWiths.iterator(); iterator.hasNext();) {
            UseKeyWith useKeyWith = (UseKeyWith) iterator.next();

            if (UseKeyWith.SKI.equals(useKeyWith.getApplication())) {
                return Base64.decode(useKeyWith.getIdentifier());
            }
        }

        return null;
    }
View Full Code Here

    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

TOP

Related Classes of org.wso2.xkms2.Authentication

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.