PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/hwi/src/java/org/apache/hadoop/hive/hwi/HWIAuth.java

#
Java | 105 lines | 57 code | 12 blank | 36 comment | 15 complexity | 1580df32ee62a87be393a67b7c501f52 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.hadoop.hive.hwi;
  19. /**
  20. * Represents an authenticated user. This class is stored in the users session.
  21. * It is also used as a key for the HiveSessionManager
  22. */
  23. public class HWIAuth implements Comparable {
  24. private String user;
  25. private String[] groups;
  26. public HWIAuth() {
  27. }
  28. public String getUser() {
  29. return user;
  30. }
  31. public void setUser(String user) {
  32. this.user = user;
  33. }
  34. public String[] getGroups() {
  35. return groups;
  36. }
  37. public void setGroups(String[] groups) {
  38. this.groups = groups;
  39. }
  40. /**
  41. * HWIAuth is used in SortedSets(s) the compartTo method is required.
  42. *
  43. * @return chained call to String.compareTo based on user property
  44. */
  45. public int compareTo(Object obj) {
  46. if (obj == null) {
  47. return -1;
  48. }
  49. if (!(obj instanceof HWIAuth)) {
  50. return -1;
  51. }
  52. HWIAuth o = (HWIAuth) obj;
  53. return o.getUser().compareTo(user);
  54. }
  55. /**
  56. * HWIAuth is used in Map(s) the hashCode method is required.
  57. *
  58. * @see java.lang.Object#hashCode()
  59. */
  60. @Override
  61. public int hashCode() {
  62. final int prime = 31;
  63. int result = 1;
  64. result = prime * result + ((user == null) ? 0 : user.hashCode());
  65. return result;
  66. }
  67. /**
  68. * HWIAuth is used in Map(s) the equals method is required.
  69. *
  70. * @see java.lang.Object#equals(java.lang.Object)
  71. */
  72. @Override
  73. public boolean equals(Object obj) {
  74. if (this == obj) {
  75. return true;
  76. }
  77. if (obj == null) {
  78. return false;
  79. }
  80. if (!(obj instanceof HWIAuth)) {
  81. return false;
  82. }
  83. HWIAuth other = (HWIAuth) obj;
  84. if (user == null) {
  85. if (other.user != null) {
  86. return false;
  87. }
  88. } else if (!user.equals(other.user)) {
  89. return false;
  90. }
  91. return true;
  92. }
  93. }