Examples of AuthenticationToken


Examples of org.apache.hadoop.security.authentication.server.AuthenticationToken

   */
  @Override
  public AuthenticationToken authenticate(HttpServletRequest request,
      HttpServletResponse response)
      throws IOException, AuthenticationException {
    AuthenticationToken token;
    String delegationParam =
        request
            .getParameter(TimelineAuthenticationConsts.DELEGATION_PARAM);
    if (delegationParam != null) {
      Token<TimelineDelegationTokenIdentifier> dt =
          new Token<TimelineDelegationTokenIdentifier>();
      dt.decodeFromUrlString(delegationParam);
      TimelineDelegationTokenSecretManagerService secretManager =
          AHSWebApp.getInstance()
              .getTimelineDelegationTokenSecretManagerService();
      UserGroupInformation ugi = secretManager.verifyToken(dt);
      final String shortName = ugi.getShortUserName();
      // creating a ephemeral token
      token = new AuthenticationToken(shortName, ugi.getUserName(), getType());
      token.setExpires(0);
    } else {
      token = super.authenticate(request, response);
    }
    return token;
  }
View Full Code Here

Examples of org.apache.hadoop.security.authentication.server.AuthenticationToken

    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    Assert.assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED,
                        conn.getResponseCode());


    AuthenticationToken token =
      new AuthenticationToken("u", "p",
        HttpFSKerberosAuthenticationHandlerForTesting.TYPE);
    token.setExpires(System.currentTimeMillis() + 100000000);
    Signer signer = new Signer("secret".getBytes());
    String tokenSigned = signer.sign(token.toString());

    url = new URL(TestJettyHelper.getJettyURL(),
                  "/webhdfs/v1/?op=GETHOMEDIRECTORY");
    conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Cookie",
View Full Code Here

Examples of org.apache.shiro.authc.AuthenticationToken

    }

    @Override
    public SecurityContext create(String userName, String credential, boolean isSecure, String authcScheme, String host) {

        AuthenticationToken authToken;
        if (credential == null) {
            authToken = new UsernamePasswordToken(userName, credential, host);
        } else {
            if (credential.equalsIgnoreCase("session")) {
                authToken = new SessionIdToken(userName, host);
View Full Code Here

Examples of org.apache.shiro.authc.AuthenticationToken

    public String resolveHost() {
        String host = getHost();

        if (host == null) {
            //check to see if there is an AuthenticationToken from which to retrieve it:
            AuthenticationToken token = getAuthenticationToken();
            if (token instanceof HostAuthenticationToken) {
                host = ((HostAuthenticationToken) token).getHost();
            }
        }
View Full Code Here

Examples of org.apache.shiro.authc.AuthenticationToken

  private static transient final Logger log = LoggerFactory.getLogger(MySecurityManager.class);

  public static boolean login(String username, String password) {
    boolean isLogin = false;
    try {
      AuthenticationToken token = new UsernamePasswordToken(username, password);
      Subject currentUser = SecurityUtils.getSubject();
      currentUser.login(token);
      isLogin = true;
    } catch (AuthenticationException e) {
      log.error("login fail!,case as ", e);
View Full Code Here

Examples of org.apache.shiro.authc.AuthenticationToken

    public AuthenticationSession authenticate(final AuthenticationRequest request, final String code) {
        RealmSecurityManager securityManager = getSecurityManager();
        if(securityManager == null) {
            return null;
        }
        final AuthenticationToken token = asAuthenticationToken(request);
       
        Subject currentUser = SecurityUtils.getSubject();
        if(currentUser.isAuthenticated()) {
            // TODO: verify the code passed in that this session is still alive?
           
View Full Code Here

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

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

   * @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

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

  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

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

   *
   * @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
Copyright © 2018 www.massapi.com. 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.