Package edu.uiuc.ncsa.myproxy.oa4mp.client

Examples of edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPResponse


            additionalParameters = new HashMap();
        }
        try {
            KeyPair keyPair = generateKeyPair();
            PKCS10CertificationRequest certReq = createCertRequest(keyPair);
            OA4MPResponse mpdsResponse = new OA4MPResponse();
            mpdsResponse.setPrivateKey(keyPair.getPrivate());
            additionalParameters.put(ClientEnvironment.CERT_REQUEST_KEY, Base64.encodeBase64String(certReq.getDEREncoded()));

            if (additionalParameters.get(getEnvironment().getConstants().get(CALLBACK_URI_KEY)) == null) {
                additionalParameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), getEnvironment().
                        getCallback().toString());
            }

            DelegationRequest daReq = new DelegationRequest();
            daReq.setParameters(additionalParameters);
            daReq.setClient(getEnvironment().getClient());
            daReq.setBaseUri(getEnvironment().getAuthorizationUri());
            DelegationResponse daResp = (DelegationResponse) getEnvironment().getDelegationService().process(daReq);
            mpdsResponse.setRedirect(daResp.getRedirectUri());
            return mpdsResponse;
        } catch (Throwable e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
View Full Code Here


                    response, "/credential-store/error.jsp");
            return;
        }

        log.info("1.a. Starting transaction");
        OA4MPResponse gtwResp = null;

        Map<String, String> queryParameters = new HashMap<String, String>();
        queryParameters.put("gatewayName", gatewayName);
        queryParameters.put("portalUserName", portalUserName);
        queryParameters.put("email", contactEmail);

        Map<String, String> additionalParameters = new HashMap<String, String>();

        String modifiedCallbackUri = decorateURI(getOA4MPService().getEnvironment().getCallback(), queryParameters);

        info("The modified callback URI - " + modifiedCallbackUri);

        additionalParameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), modifiedCallbackUri);


        // Drumroll please: here is the work for this call.
        try {
            gtwResp = getOA4MPService().requestCert(additionalParameters);
        } catch (Throwable t) {
            JSPUtil.handleException(t, request, response, "/credential-store/error.jsp");
            return;
        }
        log.info("1.b. Got response. Creating page with redirect for " + gtwResp.getRedirect().getHost());
        // Normally, we'd just do a redirect, but we will put up a page and show the redirect to the user.
        // The client response contains the generated private key as well
        // In a real application, the private key would be stored. This, however, exceeds the scope of this
        // sample application -- all we need to do to complete the process is send along the redirect url.

        request.setAttribute(REDIR, REDIR);
        request.setAttribute("redirectUrl", gtwResp.getRedirect().toString());
        request.setAttribute(ACTION_KEY, ACTION_KEY);
        request.setAttribute("action", ACTION_REDIRECT_VALUE);
        log.info("1.b. Showing redirect page.");
        JSPUtil.fwd(request, response, "/credential-store/show-redirect.jsp");
View Full Code Here

            return;
        }
        info("2.a Token and verifier found.");
        X509Certificate cert = null;
        AssetResponse assetResponse = null;
        OA4MPResponse oa4MPResponse = null;

        Map<String, String> parameters = createQueryParameters(gatewayName, portalUserName,
                                                     contactEmail, duration);

        try {
            info("Requesting private key ...");
            oa4MPResponse = getOA4MPService().requestCert(parameters);

            info("2.a. Getting the cert(s) from the service");
            assetResponse = getOA4MPService().getCert(token, verifier);
            cert = assetResponse.getX509Certificates()[0];

            // The work in this call
        } catch (Throwable t) {
            warn("2.a. Exception from the server: " + t.getCause().getMessage());
            error("Exception while trying to get cert. message:" + t.getMessage());
            request.setAttribute("exception", t);
            JSPUtil.fwd(request, response, ERROR_PAGE);
            return;
        }
        info("2.b. Done! Displaying success page.");

        CertificateCredential certificateCredential = new CertificateCredential();

        certificateCredential.setNotBefore(Utility.convertDateToString(cert.getNotBefore()));
        certificateCredential.setNotAfter(Utility.convertDateToString(cert.getNotAfter()));
        certificateCredential.setCertificate(cert);
        certificateCredential.setPrivateKey(oa4MPResponse.getPrivateKey());
        certificateCredential.setCommunityUser(new CommunityUser(gatewayName, assetResponse.getUsername(),
                contactEmail));
        certificateCredential.setPortalUserName(portalUserName);
        certificateCredential.setLifeTime(duration);
View Full Code Here

        }

        try {
            KeyPair keyPair = generateKeyPair();
            PKCS10CertificationRequest certReq = createCertRequest(keyPair);
            OA4MPResponse mpdsResponse = new OA4MPResponse();
            mpdsResponse.setPrivateKey(keyPair.getPrivate());
            additionalParameters.put(ClientEnvironment.CERT_REQUEST_KEY,
                    Base64.encodeBase64String(certReq.getDEREncoded()));

            if (additionalParameters.get(getEnvironment().getConstants().get(CALLBACK_URI_KEY)) == null) {
                additionalParameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), getEnvironment()
                        .getCallback().toString());
            }

            DelegationRequest daReq = new DelegationRequest();
            daReq.setParameters(additionalParameters);
            daReq.setClient(getEnvironment().getClient());
            daReq.setBaseUri(getEnvironment().getAuthorizationUri());
            DelegationResponse daResp = (DelegationResponse) getEnvironment().getDelegationService().process(daReq);
            mpdsResponse.setRedirect(daResp.getRedirectUri());
            return mpdsResponse;
        } catch (Throwable e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
View Full Code Here

                    + " user account."), request, response, "/credential-store/error.jsp");
            return;
        }

        log.info("1.a. Starting transaction");
        OA4MPResponse gtwResp = null;

        Map<String, String> queryParameters = new HashMap<String, String>();
        queryParameters.put("gatewayName", gatewayName);
        queryParameters.put("portalUserName", portalUserName);
        queryParameters.put("email", contactEmail);
        queryParameters.put("associatedToken", associatedToken);

        Map<String, String> additionalParameters = new HashMap<String, String>();

        String modifiedCallbackUri = decorateURI(getOA4MPService().getEnvironment().getCallback(), queryParameters);

        info("The modified callback URI - " + modifiedCallbackUri);

        additionalParameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), modifiedCallbackUri);

        // Drumroll please: here is the work for this call.
        try {
            gtwResp = getOA4MPService().requestCert(additionalParameters);
        } catch (Throwable t) {
            JSPUtil.handleException(t, request, response, "/credential-store/error.jsp");
            return;
        }
        log.info("1.b. Got response. Creating page with redirect for " + gtwResp.getRedirect().getHost());
        // Normally, we'd just do a redirect, but we will put up a page and show the redirect to the user.
        // The client response contains the generated private key as well
        // In a real application, the private key would be stored. This, however, exceeds the scope of this
        // sample application -- all we need to do to complete the process is send along the redirect url.

        request.setAttribute(REDIR, REDIR);
        request.setAttribute("redirectUrl", gtwResp.getRedirect().toString());
        request.setAttribute(ACTION_KEY, ACTION_KEY);
        request.setAttribute("action", ACTION_REDIRECT_VALUE);
        log.info("1.b. Showing redirect page.");
        JSPUtil.fwd(request, response, "/credential-store/show-redirect.jsp");
View Full Code Here

            return;
        }
        info("2.a Token and verifier found.");
        X509Certificate cert = null;
        AssetResponse assetResponse = null;
        OA4MPResponse oa4MPResponse = null;

        Map<String, String> parameters = createQueryParameters(gatewayName, portalUserName, contactEmail, portalTokenId);

        try {
            info("Requesting private key ...");
            oa4MPResponse = getOA4MPService().requestCert(parameters);
            // oa4MPResponse = getOA4MPService().requestCert();

            info("2.a. Getting the cert(s) from the service");
            assetResponse = getOA4MPService().getCert(token, verifier);
            cert = assetResponse.getX509Certificates()[0];

            // The work in this call
        } catch (Throwable t) {
            warn("2.a. Exception from the server: " + t.getCause().getMessage());
            error("Exception while trying to get cert. message:" + t.getMessage());
            request.setAttribute("exception", t);
            JSPUtil.fwd(request, response, ERROR_PAGE);
            return;
        }
        info("2.b. Done! Displaying success page.");

        CertificateCredential certificateCredential = new CertificateCredential();

        certificateCredential.setNotBefore(Utility.convertDateToString(cert.getNotBefore()));
        certificateCredential.setNotAfter(Utility.convertDateToString(cert.getNotAfter()));
        certificateCredential.setCertificate(cert);
        certificateCredential.setPrivateKey(oa4MPResponse.getPrivateKey());
        certificateCredential
                .setCommunityUser(new CommunityUser(gatewayName, assetResponse.getUsername(), contactEmail));
        certificateCredential.setPortalUserName(portalUserName);
        certificateCredential.setLifeTime(duration);
        certificateCredential.setToken(portalTokenId);
View Full Code Here

                    + " user account."), request, response, configurationReader.getErrorUrl());
            return;
        }

        log.info("1.a. Starting transaction");
        OA4MPResponse gtwResp;

        Map<String, String> queryParameters = new HashMap<String, String>();
        queryParameters.put(CredentialStoreConstants.GATEWAY_NAME_QUERY_PARAMETER, gatewayName);
        queryParameters.put(CredentialStoreConstants.PORTAL_USER_QUERY_PARAMETER, portalUserName);
        queryParameters.put(CredentialStoreConstants.PORTAL_USER_EMAIL_QUERY_PARAMETER, contactEmail);
        queryParameters.put(CredentialStoreConstants.PORTAL_TOKEN_ID_ASSIGNED, associatedToken);

        Map<String, String> additionalParameters = new HashMap<String, String>();

        String modifiedCallbackUri = decorateURI(getOA4MPService().getEnvironment().getCallback(), queryParameters);

        info("The modified callback URI - " + modifiedCallbackUri);

        additionalParameters.put(getEnvironment().getConstants().get(CALLBACK_URI_KEY), modifiedCallbackUri);

        try {
            gtwResp = getOA4MPService().requestCert(additionalParameters);

            // Private key in store
            PrivateKeyStore privateKeyStore = PrivateKeyStore.getPrivateKeyStore();
            privateKeyStore.addKey(associatedToken, gtwResp.getPrivateKey());

        } catch (Throwable t) {
            JSPUtil.handleException(t, request, response, configurationReader.getErrorUrl());
            return;
        }
        log.info("1.b. Got response. Creating page with redirect for " + gtwResp.getRedirect().getHost());
        // Normally, we'd just do a redirect, but we will put up a page and show the redirect to the user.
        // The client response contains the generated private key as well
        // In a real application, the private key would be stored. This, however, exceeds the scope of this
        // sample application -- all we need to do to complete the process is send along the redirect url.

        request.setAttribute(REDIR, REDIR);
        request.setAttribute("redirectUrl", gtwResp.getRedirect().toString());
        request.setAttribute(ACTION_KEY, ACTION_KEY);
        request.setAttribute("action", ACTION_REDIRECT_VALUE);
        log.info("1.b. Showing redirect page.");
        JSPUtil.fwd(request, response, configurationReader.getPortalRedirectUrl());
View Full Code Here

TOP

Related Classes of edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPResponse

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.