package com.perforce.workspace.tjuricek.p4oauth.models; /** * Stores the saved p4d token for the user and request URI (which is bound to * a specific IP address). */ public class Token { private String ipAddress; private String redirectUri; private String token; private long created; public Token() { this.created = System.currentTimeMillis(); } public Token(String ipAddress, String requestUri, String token) { this(); this.ipAddress = ipAddress; this.redirectUri = requestUri; this.token = token; } /** * The IP address of the server we should have generated the token for. * @return */ public String getIpAddress() { return ipAddress; } public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; } /** * The redirectUri that will be sent in by the user to get the next token. * @return */ public String getRedirectUri() { return redirectUri; } public void setRedirectUri(String redirectUri) { this.redirectUri = redirectUri; } /** * The perforce token that can be used in place of the password. * @return */ public String getToken() { return token; } public void setToken(String token) { this.token = token; } /** * When this token was created. * @return */ public long getCreated() { return created; } public void setCreated(long created) { this.created = created; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Token token1 = (Token) o; if (created != token1.created) return false; if (ipAddress != null ? !ipAddress.equals(token1.ipAddress) : token1.ipAddress != null) return false; if (redirectUri != null ? !redirectUri.equals(token1.redirectUri) : token1.redirectUri != null) return false; if (token != null ? !token.equals(token1.token) : token1.token != null) return false; return true; } @Override public int hashCode() { int result = ipAddress != null ? ipAddress.hashCode() : 0; result = 31 * result + (redirectUri != null ? redirectUri.hashCode() : 0); result = 31 * result + (token != null ? token.hashCode() : 0); result = 31 * result + (int) (created ^ (created >>> 32)); return result; } @Override public String toString() { return "Token{" + "ipAddress='" + ipAddress + '\'' + ", redirectUri='" + redirectUri + '\'' + ", token='" + token + '\'' + ", created=" + created + '}'; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#2 | 9095 | tjuricek | Added some basic test data and renamed "workspace" to "workshop" in package name | ||
#1 | 9089 | tjuricek |
Moving some code that worked via some manual validation to the workshop. This just implements a basic code authorization grant scheme. Automated tests are forthcoming, awating some gradle plugin work that should sit outside of this project. |