Package org.latexlab.docs.server.auth

Examples of org.latexlab.docs.server.auth.AuthenticationToken


   * @param token the Authentication token
   * @return a GData Documents service
* @throws DocumentServiceException
   */
  private DocsService getDocsService() throws DocumentServiceException {
  AuthenticationToken token = this.store.getUserToken();
  if (token == null) {
    throw new DocumentServiceException("Service requires authentication.");
  }
  PrivateKey key = AuthenticationKey.getAuthSubKey();
    DocsService svc = new DocsService(GDATA_CLIENT_APPLICATION_NAME);
    svc.setConnectTimeout(0);
    svc.setReadTimeout(0);
    svc.setAuthSubToken(token.getToken(), key);
    svc.setProtocolVersion(DocsService.Versions.V3);
    return svc;
  }
View Full Code Here


   * @return the signed URLs for retrieving the contents of the specified documents.
   * @throws DocumentServiceException
   */
  @Override
  public DocumentSignedLocation[] getDocumentContentUrls(String[] documentLinks) throws DocumentServiceException {
  AuthenticationToken token = this.store.getUserToken();
  if (token == null) {
    throw new DocumentServiceException("Service requires authentication.");
  }
  try {
    DocumentSignedLocation[] dsls = new DocumentSignedLocation[documentLinks.length];
    for (int i=0; i<documentLinks.length; i++) {
    String documentUrl = documentLinks[i];
      String documentUrlSig;
    documentUrlSig = AuthSubUtil.formAuthorizationHeader(
            token.getToken(), AuthenticationKey.getAuthSubKey(), new URL(documentUrl), "GET");
        DocumentSignedLocation dsl =
          new DocumentSignedLocation(documentUrl, documentUrlSig);
      dsls[i] = dsl;
    }
    return dsls;
View Full Code Here

  public DocumentUser getUser() {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if (user != null){
      String email = user.getEmail();
      AuthenticationToken at = AuthenticationToken.getUserToken(email);
      if (at != null) {
        DocumentUser docUser = new DocumentUser();
        docUser.setToken(at.getPublicToken());
        docUser.setName(user.getNickname());
        docUser.setEmail(user.getEmail());
        docUser.setId(user.getUserId());
        return docUser;
      }
View Full Code Here

   *
   * @throws DocumentServiceException
   */
  @Override
  public String logout() throws DocumentServiceException {
    AuthenticationToken token = store.getUserToken();
    if (token != null) {
      try {
      try {
          AuthSubUtil.revokeToken(token.getToken(), AuthenticationKey.getAuthSubKey());
      } catch (Exception x) {
        x.printStackTrace();
      }
        AuthenticationToken.clearUserToken(token.getEmail());
        UserService userService = UserServiceFactory.getUserService();
        URI url = new URI(this.getThreadLocalRequest().getRequestURL().toString());
        return userService.createLogoutURL("http://" + url.getAuthority() + LOGOUT_RETURN_RELATIVE_PATH);
      } catch (Exception e) {
        e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.latexlab.docs.server.auth.AuthenticationToken

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.