Package com.ibm.commons.runtime

Examples of com.ibm.commons.runtime.Context


    oAuthHandler.setForceTrustSSLCertificate(forceTrustSSLCertificate);
  }

  @Override
  public JSReference getAuthenticator(String endpointName, String sbtUrl) {
    Context ctx = Context.get();
    JSReference reference = new JSReference("sbt/authenticator/OAuth");
    StringBuilder b = new StringBuilder();
    RuntimeConstants.get().appendBaseProxyUrl(b, ctx);
    b.append("/");
    b.append(OAClientAuthentication.URL_PATH);
View Full Code Here


        public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {

            CookieStore cookieStore;
            cookieStore = new BasicCookieStore();

            Context ctx = Context.get();
           
            boolean ltpaTokenFound = false;
           
            java.util.Map<java.lang.String, java.lang.Object> cookieMap = ctx.getRequestCookieMap();
            if(cookieMap.containsKey("LtpaToken")) {
                javax.servlet.http.Cookie cookie = (javax.servlet.http.Cookie) cookieMap.get("LtpaToken");
                BasicClientCookie2 cookie1 = new BasicClientCookie2(cookie.getName(), getRawCookieValue(cookie, ctx.getHttpRequest()));
                if(cookie.getDomain()!=null) {
                    cookie1.setDomain(cookie.getDomain());
                }
                else {
                    cookie1.setDomain(_domain);
                }
                if(cookie.getPath()!=null) {
                    cookie1.setPath(cookie.getPath());
                }
                else {
                    cookie1.setPath("/");
                }
                cookieStore.addCookie(cookie1);
                ltpaTokenFound = true;
            }

            if(cookieMap.containsKey("LtpaToken2")) {
                javax.servlet.http.Cookie cookie = (javax.servlet.http.Cookie) cookieMap.get("LtpaToken2");
                BasicClientCookie2 cookie2 = new BasicClientCookie2(cookie.getName(), getRawCookieValue(cookie, ctx.getHttpRequest()));
                if(cookie.getDomain()!=null) {
                    cookie2.setDomain(cookie.getDomain());
                }
                else {
                    cookie2.setDomain(_domain);
View Full Code Here

    /*
     * Remove any cached 'X-Update-Nonce' header.
     */
    private void clearNonceHeader() {
        Context context = Context.getUnchecked();
        if (context != null) {
            context.getSessionMap().remove(X_UPDATE_NONCE);
        }
    }
View Full Code Here

     * Retrieve the current nonce value i.e. if the value exists in the cache then
     * user that value otherwise emit a request to retrieve it.
     */
    private String retrieveNonceHeader() throws ClientServicesException, IOException {
        Object nonce = null;
        Context context = Context.getUnchecked();
        if (context != null) {
            nonce = context.getSessionMap().get(X_UPDATE_NONCE);
        }
        if (nonce != null) {
            // return the cached value
            return nonce.toString();
        } else {
            InputStream response = (InputStream)endpoint.xhrGet("files/basic/api/nonce").getData();
            nonce = StreamUtil.readString(response);
           
            // cache the value
            context.getSessionMap().put(X_UPDATE_NONCE, nonce);
           
            return nonce.toString();
        }
    }
View Full Code Here

        if (logger.isLoggable(Level.FINEST)) {
            logger.entering(sourceClass, "doGet", new Object[] { req, resp });
        }

        try {
            Context context = Context.get();
            SBTEnvironment environment = getDefaultEnvironment(context);
            LibraryRequest request = createLibraryRequest(req, resp);
            request.init(defaultParams);

            AbstractLibrary library = createLibrary(request);
View Full Code Here

      if ((HttpServletRequest)Context.get().getHttpRequest() == null) {
        return;
      }
        if(force || !isAuthenticated()) {
            String authPage = getAuthenticationPage();
           Context context = Context.get();
            if(StringUtil.isNotEmpty(authPage)) {
              // to ignore if the authentication page value contains endpoint parameter, we are now making use of this.getName() to get the endpoint name
              // and no need to explicitly set in authentication page value
              if(authPage.contains("?endpoint=") || authPage.contains("?") ){
                authPage = authPage.substring(0, authPage.indexOf(("?")));
              }
              try{
                if(!UrlUtil.isAbsoluteUrl(authPage)){
                  authPage = UrlUtil.makeUrlAbsolute((HttpServletRequest)context.getHttpRequest(), authPage);
                  }

                String redirectUrl = UrlUtil.getRequestUrl((HttpServletRequest)context.getHttpRequest());// change needed to handle portlethttprequest
               
                   String endPointName = this.getName();
                  String baseUrl = UrlUtil.getBaseUrl(((HttpServletRequest)context.getHttpRequest()));
                  String servletPath = ServiceServlet.getServletPath();
                  String basicProxyUrl = AuthCredsHandler.URL_PATH;
                   
                  //constructing proxy action url
                  String postToProxy = PathUtil.concat(baseUrl, servletPath, '/');
                  postToProxy = PathUtil.concat(postToProxy,basicProxyUrl, '/');
                  postToProxy = PathUtil.concat(postToProxy,endPointName, '/');
                  postToProxy = PathUtil.concat(postToProxy,"JavaApp", '/');
                 
                  // encode URL's
                 postToProxy = URLEncoder.encode(postToProxy,"UTF-8");
               redirectUrl = URLEncoder.encode(redirectUrl,"UTF-8");
                 
                  // passing proxy action url as a parameter to the authentication page
                  authPage = PathUtil.concat(authPage,"proxyPath",'?');
                  authPage = PathUtil.concat(authPage,postToProxy,'=');
                  // passing redirectURL as a parameter to the authentication page
                  authPage = PathUtil.concat(authPage,"redirectURL",'&');
                  authPage = PathUtil.concat(authPage,redirectUrl,'=');
                  context.sendRedirect(authPage);
                      
                   
              } catch (IOException e) {
                throw new ClientServicesException(null,"Authentication page not found. Could not redirect to login page");
              }
View Full Code Here

       
    public boolean readFromStore() throws AuthenticationException {
      try {
          if(!storeAlreadyTried) {
              synchronized (this) {
              Context context = Context.getUnchecked();
              if (context != null) {
                    UserPassword u = null;
                  CredentialStore cs = CredentialStoreFactory.getCredentialStore(getCredentialStore());
                  if(cs!=null) {
                      u = (UserPassword)cs.load(getUrl(),STORE_TYPE,context.getCurrentUserId());
                  }
                    if(u!=null) {
                        this.user = u.getUser();
                        this.password = u.getPassword();
                        return true;
View Full Code Here

      }
    }

    public boolean writeToStore() throws AuthenticationException {
      try {
        Context context = Context.getUnchecked();
        if (context != null) {
          CredentialStore cs = CredentialStoreFactory.getCredentialStore(getCredentialStore());
            if(cs!=null) {
              UserPassword u = new UserPassword(user,password);
                cs.store(getUrl(), STORE_TYPE, context.getCurrentUserId(), u);
                return true;
            }
        }
          return false;
      } catch(CredentialStoreException ex) {
View Full Code Here

      }
    }

    public boolean clearFromStore() throws AuthenticationException {
      try {
        Context context = Context.getUnchecked();
        if (context != null) {
          CredentialStore cs = CredentialStoreFactory.getCredentialStore(getCredentialStore());
            if(cs!=null) {
                cs.remove(getUrl(), STORE_TYPE, context.getCurrentUserId());
                return true;
            }
        }
          return false;
    } catch(CredentialStoreException ex) {
View Full Code Here

        setPassword(null);
        clearFromStore();
    }
   
    public void redirect()throws ClientServicesException{
        Context context = Context.get();

        String nextPage = (String)context.getSessionMap().get(REDIRECT_PAGE_KEY);
        if(StringUtil.isEmpty(nextPage))
          nextPage=((HttpServletRequest)context.getHttpRequest()).getParameter("redirectURL");
    if (StringUtil.isNotEmpty(nextPage)) {
      // TODO
      // context.getExternalContext().getSessionMap().remove(REDIRECT_PAGE_KEY);
      // XSPContext ctx =
      // XSPContext.getXSPContext(FacesContext.getCurrentInstance());
      try {
        context.sendRedirect(nextPage);
      } catch (IOException e) {
        throw new ClientServicesException(e,"Error redirecting to the following URL"+nextPage);
      }
    }
    }
View Full Code Here

TOP

Related Classes of com.ibm.commons.runtime.Context

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.