Package org.wso2.xkms2

Examples of org.wso2.xkms2.Authentication


                                                    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

        try {

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

            QueryKeyBinding queryKeybinding = createQueryKeyBinding();
            queryKeybinding.addUseKeyWith(UseKeyWith.SKI, Base64
                    .encode(skiValue));
            request.setQueryKeyBinding(queryKeybinding);

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

    public static String[] getAliasesForDN(String subjectDN, String serviceURL) {
        try {
            LocateRequest request = createLocateRequest();
            request.setServiceURI(serviceURL);

            QueryKeyBinding queryKeybinding = createQueryKeyBinding();
            queryKeybinding.addUseKeyWith(UseKeyWith.PKIX, subjectDN);
            request.setQueryKeyBinding(queryKeybinding);

            request.addRespondWith(RespondWith.KEY_NAME);

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

        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

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.