Package org.wso2.xkms2.client

Examples of org.wso2.xkms2.client.XKMSClientUtil


        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);
View Full Code Here


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

    public static QueryKeyBinding createQueryKeyBinding() {
        QueryKeyBinding binding = new QueryKeyBinding();
        binding.setId(XKMSUtil.getRamdomId());
        return binding;
    }
View Full Code Here

     * @param locate
     * @return
     */
    public LocateResult handleLocateRequest(LocateRequest locate) {
        try {
            QueryKeyBinding keybinding = locate.getQueryKeyBinding();

            String identifer = getSubjectDN(keybinding);
            String[] aliases = null;

            if (identifer == null) {
                KeyInfo keyInfo = keybinding.getKeyInfo();

                if (keyInfo != null) {
                    try {
                        KeyName keyName = keyInfo.itemKeyName(0);
                        if (keyName != null) {
                            aliases = new String[] { keyName.getKeyName() };
                        }
                    } catch (XMLSecurityException xme) {
                        throw new XKMSException(xme);
                    }
                }

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

            byte[] skiValue = getSKIValue(keybinding);
            if (skiValue != null) {
                String alias = getAliasForX509Cert(skiValue);
                if (alias != null) {
                    aliases = new String[] { alias };
                }
            }

            if (aliases == null || aliases.length == 0) {
                throw new XKMSException("KeyNotFound");
            }

            List keyUsage = keybinding.getKeyUsage();
            boolean digitalSigning = keyUsage.contains(KeyUsage.SIGNATURE);
            boolean dataEncryption = keyUsage.contains(KeyUsage.ENCRYPTION);

            List list = new ArrayList();
            for (int i = 0; i < aliases.length; i++) {
View Full Code Here

    }

    public ValidateResult handleValidateRequest(ValidateRequest validateRequest) {

        try {
            QueryKeyBinding queryKeyBinding = validateRequest
                    .getQueryKeyBinding();
            List respondWith = validateRequest.getRespondWith();

            KeyInfo keyInfo = queryKeyBinding.getKeyInfo();
            X509Certificate cert = null;

            if (keyInfo != null) {
                try {
                    cert = keyInfo.getX509Certificate();
View Full Code Here

    private static final QName D = new QName(XKMS2Constants.XKMS2_NS, "D");

    public static final RSAKeyPairTypeBuilder INSTANCE = new RSAKeyPairTypeBuilder();

    public XKMSElement buildElement(OMElement element) throws XKMSException {
        RSAKeyPair rsaKeyPair = new RSAKeyPair();
        OMElement child;
       
        child = element.getFirstChildWithName(MODULUS);
        rsaKeyPair.setModulus(decodeText(child));
       
        child = element.getFirstChildWithName(EXPONENT);
        rsaKeyPair.setExponent(decodeText(child));
       
        child = element.getFirstChildWithName(P);
        rsaKeyPair.setP(decodeText(child));
       
        child = element.getFirstChildWithName(Q);
        rsaKeyPair.setQ(decodeText(child));
       
        child = element.getFirstChildWithName(DP);
        rsaKeyPair.setDP(decodeText(child));
       
        child = element.getFirstChildWithName(DQ);
        rsaKeyPair.setDQ(decodeText(child));
       
        child =element.getFirstChildWithName(INVERSE_Q);
        rsaKeyPair.setInverseQ(decodeText(child));
       
        child = element.getFirstChildWithName(D);
        rsaKeyPair.setD(decodeText(child));
       
        return rsaKeyPair;
    }
View Full Code Here

            Authentication authentication = new Authentication();
            Key authenKey = XKMSKeyUtil.getAuthenticationKey(passPhrase);
            authentication.setKeyBindingAuthenticationKey(authenKey);
            request.setAuthentication(authentication);

            RecoverKeyBinding keyBinding = createRecoverKeyBinding();
            keyBinding.setKeyName(alias);

            Status status = new Status();
            status.setStatusValue(StatusValue.INDETERMINATE);
            keyBinding.setStatus(status);

            request.setRecoverKeyBinding(keyBinding);

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

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

    public static RecoverKeyBinding createRecoverKeyBinding() {
        RecoverKeyBinding recoverKeyBinding = new RecoverKeyBinding();
        recoverKeyBinding.setId(XKMSUtil.getRamdomId());
        return recoverKeyBinding;

    }
View Full Code Here

    private RecoverKeyBindingBuilder() {
    }

    public XKMSElement buildElement(OMElement element) throws XKMSException {
        RecoverKeyBinding recoverKeyBinding = new RecoverKeyBinding();
        KeyBindingBuilder.INSTANCE.buildElement(element, recoverKeyBinding);
        return recoverKeyBinding;
    }
View Full Code Here

    public RecoverResult handleRecoverRequest(RecoverRequest request) {
        try {
            prepare(request, request.getRecoverKeyBinding());
            // TODO Validate ..
            RecoverKeyBinding recoverKeyBinding = request
                    .getRecoverKeyBinding();
            String[] aliases = null;

            X509Certificate cert = recoverKeyBinding.getCertValue();
            if (cert != null) {
                String issuerDN = cert.getIssuerDN().getName();
                BigInteger serialNumber = cert.getSerialNumber();

                String alias = getAliasForX509Cert(issuerDN, serialNumber);
                if (alias != null) {
                    aliases = new String[] { alias };
                }

            } else {
                String subjectDN = getSubjectDN(recoverKeyBinding);

                if (subjectDN != null) {
                    aliases = getAliasesForDN(subjectDN);
                }
            }

            if (aliases == null) {
                String keyName = recoverKeyBinding.getKeyName();
                if (keyName != null) {
                    aliases = new String[] { keyName };
                }
            }
View Full Code Here

    public static PrivateKey getPrivateKey(String alias, String serverURL,
                                           String passPhrase) {

        try {

            RecoverRequest request = createRecoverRequest();
            request.setServiceURI(serverURL);

            Authentication authentication = new Authentication();
            Key authenKey = XKMSKeyUtil.getAuthenticationKey(passPhrase);
            authentication.setKeyBindingAuthenticationKey(authenKey);
            request.setAuthentication(authentication);

            RecoverKeyBinding keyBinding = createRecoverKeyBinding();
            keyBinding.setKeyName(alias);

            Status status = new Status();
            status.setStatusValue(StatusValue.INDETERMINATE);
            keyBinding.setStatus(status);

            request.setRecoverKeyBinding(keyBinding);

            request.addRespondWith(RespondWith.PRIVATE_KEY);

            OMElement element = getAsOMElement(request);
            OMElement result = sendReceive(element, serverURL);
            result = buildElement(result);
View Full Code Here

TOP

Related Classes of org.wso2.xkms2.client.XKMSClientUtil

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.