Пример #1
0
 static String rebuildUri(HttpServletRequest request, String redirectUrlPrefix) {
   HttpSession session = ((HttpServletRequest) request).getSession(true);
   StringBuilder url = new StringBuilder();
   if (redirectUrlPrefix.endsWith("/")) {
     redirectUrlPrefix = redirectUrlPrefix.substring(0, redirectUrlPrefix.length() - 1);
   }
   url.append(redirectUrlPrefix);
   String uri = request.getRequestURI().substring(request.getContextPath().length());
   url.append(uri);
   url.append("?");
   if (request.getQueryString() != null) {
     url.append(request.getQueryString());
     url.append("&");
   }
   url.append(ssoKey);
   url.append("=");
   try {
     url.append(
         RmStringHelper.encodeUrl(
             RmCryptoHelper.encryptDesBase64(
                 RmSsoLogin.createInstance(session.getId()).toString())));
   } catch (Exception e) {
     e.printStackTrace();
   }
   return url.toString();
 }
Пример #2
0
  public static void main(String[] args) {
    try {
      String value = "中国";
      //			byte[] tmp = RmProjectHelper.encrypt(value.getBytes(), desKey.getBytes());
      //			System.out.println(new String(tmp));
      //			System.out.println(Base64.encodeBase64String(tmp));
      //			System.out.println(new String());
      //			System.out.println(new
      // String(RmProjectHelper.decrypt(Base64.decodeBase64(Base64.encodeBase64String(tmp)),
      // desKey.getBytes())));

      value = RmCryptoHelper.encryptDesBase64(value);
      System.out.println(value);
      System.out.println(RmCryptoHelper.decryptDesBase64(value));

      value = "我爱北京天安门34";
      value = RmCryptoHelper.encryptBase64(value);
      System.out.println(value);
      System.out.println(RmCryptoHelper.decryptBase64(value));
      System.out.println("5oiR54ix5YyX5Lqs5aSp5a6J6ZeoMzQ");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #3
0
  public static boolean doSsoLogin(
      ServletRequest request, ServletResponse response, FilterChain filterChain) {
    try {
      HttpSession session = ((HttpServletRequest) request).getSession(true);
      // 临时登录超时时间
      session.setMaxInactiveInterval(60 * 3);
      String ssoValue = request.getParameter(ssoKey);
      try {
        ssoValue = RmCryptoHelper.decryptDesBase64(ssoValue);
      } catch (Exception e) {
        e.printStackTrace();
      }
      String[] ssoValueArgs = ssoValue.split(splictKeyRegex);
      String nodeId = ssoValueArgs[0];
      String sessionId = ssoValueArgs[2];
      String callWsUrl =
          RmClusterConfig.getSingleton()
              .getSelfNode()
              .get(RmClusterConfig.NodeKey.webServiceUrl.name());
      String address = callWsUrl + "RmSsoLogin";
      JaxWsProxyFactoryBean jw = new JaxWsProxyFactoryBean();
      jw.setServiceClass(IRmSsoService.class);
      jw.setAddress(address);
      Object obj = jw.create();
      IRmSsoService ssoService = (IRmSsoService) obj;

      RmUserVo userVo = ssoService.copyLogin(sessionId, ssoValue);
      session.setAttribute(IGlobalConstants.RM_USER_VO, userVo);
      session.setAttribute(IGlobalConstants.RM_SSO_TEMP, IGlobalConstants.RM_YES);
      return true;
    } catch (Exception e) {
      log.error("doSsoLogin():" + e.toString() + " cause:" + e.getCause());
      // save error
      request.setAttribute("org.apache.struts.action.EXCEPTION", e);
      return false;
    }
  }