Package org.wso2.xkms2

Examples of org.wso2.xkms2.LocateRequest


        reissueResult.setId(getRamdomId());
        return reissueResult;
    }
   
    public static LocateResult createLocateResult() {
        LocateResult locateResult = new LocateResult();
        locateResult.setId(getRamdomId());
        return locateResult;
    }
View Full Code Here


            if (list.isEmpty()) {
                throw new XKMSException(XKMSException.NO_MATCH, "KeyNotFound");
            }

            LocateResult result = XKMSUtil.createLocateResult();
            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);
            }

            return result;

        } catch (XKMSException ex) {
            LocateResult result = XKMSUtil.createLocateResult();
            buildFault(locate, result, ex);
            return result;
        }
    }
View Full Code Here

   
    private PrivateKeyBuilder() {
    }

    public XKMSElement buildElement(OMElement element) throws XKMSException {
        PrivateKey privateKey = new PrivateKey();
        OMElement encryptedData = element
                .getFirstChildWithName(XKMS2Constants.Q_ELEM_XML_ENC_DATA);
        privateKey.setEncryptedData((Element) element);
        return privateKey;
    }
View Full Code Here

        OMElement privateKeyElem = element
                .getFirstChildWithName(XKMS2Constants.Q_ELEM_PRIVATE_KEY);

        if (privateKeyElem != null) {
            PrivateKey privateKey = (PrivateKey) PrivateKeyBuilder.INSTANCE.buildElement(privateKeyElem);
            recoverResult.setPrivateKey(privateKey);
        }

        return recoverResult;
    }
View Full Code Here

        Authentication authentication = new Authentication();
        return authentication;
    }

    public static PrototypeKeyBinding createPrototypeKeyBinding() {
        PrototypeKeyBinding keyBinding = new PrototypeKeyBinding();
        keyBinding.setId(XKMSUtil.getRamdomId());
        return keyBinding;
    }
View Full Code Here

    }

    private PrototypeKeyBinding prototypeKeyBinding;

    public XKMSElement buildElement(OMElement element) throws XKMSException {
        prototypeKeyBinding = new PrototypeKeyBinding();
        super.buildElement(element, prototypeKeyBinding);

        OMElement validityIntervalEle = element
                .getFirstChildWithName(XKMS2Constants.ELE_VALIDITY_INTERVAL);
View Full Code Here

        try {
            prepare(request, request.getPrototypeKeyBinding());
            validate(request);

            PrototypeKeyBinding pkb = request.getPrototypeKeyBinding();
            String identifer = getSubjectDN(pkb);

            if (identifer == null) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("No SubjectDN is specified");
                }

                throw new XKMSException(XKMSException.FAILURE, "NoSubjectDN");
            }

            PublicKey public1 = pkb.getKeyValue();
            PrivateKey private1 = null;

            // if a public key is not provided we need to generate both the
            // public key and private key
            if (public1 == null) {
                KeyPair keypair = XKMSKeyUtil.generateRSAKeyPair();
                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);
            }

            long serialNum = nextSerialNumber();
            String aliase = createAlias(serialNum);
            BigInteger serialNumber = BigInteger.valueOf(serialNum);

            X509Certificate cert;

            List keyUsage = pkb.getKeyUsage();
            if (keyUsage == null
                    || keyUsage.isEmpty()
                    || (keyUsage.size() == 1 && keyUsage
                            .contains(KeyUsage.EXCHANGE))) {
                cert = XKMSKeyUtil.getX509Certificate(identifer, serialNumber,
View Full Code Here

    private void validate(RegisterRequest registerRequest) throws XKMSException {

        validate((KRSSRequest) registerRequest);

        PrototypeKeyBinding pkb = registerRequest.getPrototypeKeyBinding();
        XMLSignature proofOfPossession = registerRequest.getProofOfPossession();

        Key key = pkb.getKeyValue();

        if (key != null) {
            try {
                proofOfPossession.checkSignatureValue(key);
View Full Code Here

                                                    String serviceURL) {
        try {
            LocateRequest request = createLocateRequest();
            request.setServiceURI(serviceURL);

            QueryKeyBinding queryKeybinding = createQueryKeyBinding();
            queryKeybinding.setKeyName(alias);
            request.setQueryKeyBinding(queryKeybinding);

            request.addRespondWith(RespondWith.X_509_CERT);

            OMElement element = getAsOMElement(request);
View Full Code Here

        try {

            LocateRequest request = createLocateRequest();
            request.setServiceURI(serviceURL);

            QueryKeyBinding queryKeybinding = createQueryKeyBinding();

            queryKeybinding.setCertValue(cert);
            queryKeybinding.addUseKeyWith(UseKeyWith.PKIX, cert.getSubjectDN()
                    .getName());

            request.setQueryKeyBinding(queryKeybinding);

            request.addRespondWith(RespondWith.KEY_NAME);
View Full Code Here

TOP

Related Classes of org.wso2.xkms2.LocateRequest

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.