|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License; |
| 4 | + * you may not use this file except in compliance with the Elastic License. |
| 5 | + */ |
| 6 | +package org.elasticsearch.xpack.core.security.action.oidc; |
| 7 | + |
| 8 | +import org.elasticsearch.action.ActionRequest; |
| 9 | +import org.elasticsearch.action.ActionRequestValidationException; |
| 10 | +import org.elasticsearch.common.io.stream.StreamInput; |
| 11 | +import org.elasticsearch.common.io.stream.StreamOutput; |
| 12 | + |
| 13 | +import java.io.IOException; |
| 14 | + |
| 15 | +/** |
| 16 | + * Represents a request for authentication using OpenID Connect |
| 17 | + */ |
| 18 | +public class OpenIdConnectAuthenticateRequest extends ActionRequest { |
| 19 | + |
| 20 | + /** |
| 21 | + * The URI where the OP redirected the browser after the authentication attempt. This is passed as is from the |
| 22 | + * facilitator entity (i.e. Kibana) |
| 23 | + */ |
| 24 | + private String redirectUri; |
| 25 | + |
| 26 | + /** |
| 27 | + * The state value that we generated for this specific flow and that should be stored at the user's session with |
| 28 | + * the facilitator |
| 29 | + */ |
| 30 | + private String state; |
| 31 | + |
| 32 | + /** |
| 33 | + * The nonce value that we generated for this specific flow and that should be stored at the user's session with |
| 34 | + * the facilitator |
| 35 | + */ |
| 36 | + private String nonce; |
| 37 | + |
| 38 | + public OpenIdConnectAuthenticateRequest() { |
| 39 | + |
| 40 | + } |
| 41 | + |
| 42 | + public OpenIdConnectAuthenticateRequest(StreamInput in) throws IOException { |
| 43 | + super.readFrom(in); |
| 44 | + redirectUri = in.readString(); |
| 45 | + state = in.readString(); |
| 46 | + nonce = in.readOptionalString(); |
| 47 | + } |
| 48 | + |
| 49 | + public String getRedirectUri() { |
| 50 | + return redirectUri; |
| 51 | + } |
| 52 | + |
| 53 | + public void setRedirectUri(String redirectUri) { |
| 54 | + this.redirectUri = redirectUri; |
| 55 | + } |
| 56 | + |
| 57 | + public String getState() { |
| 58 | + return state; |
| 59 | + } |
| 60 | + |
| 61 | + public void setState(String state) { |
| 62 | + this.state = state; |
| 63 | + } |
| 64 | + |
| 65 | + public String getNonce() { |
| 66 | + return nonce; |
| 67 | + } |
| 68 | + |
| 69 | + public void setNonce(String nonce) { |
| 70 | + this.nonce = nonce; |
| 71 | + } |
| 72 | + |
| 73 | + @Override |
| 74 | + public ActionRequestValidationException validate() { |
| 75 | + return null; |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + public void writeTo(StreamOutput out) throws IOException { |
| 80 | + super.writeTo(out); |
| 81 | + out.writeString(redirectUri); |
| 82 | + out.writeString(state); |
| 83 | + out.writeOptionalString(nonce); |
| 84 | + } |
| 85 | + |
| 86 | + @Override |
| 87 | + public void readFrom(StreamInput in) { |
| 88 | + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); |
| 89 | + } |
| 90 | + |
| 91 | + public String toString() { |
| 92 | + return "{redirectUri=" + redirectUri + ", state=" + state + ", nonce=" + nonce + "}"; |
| 93 | + } |
| 94 | +} |
| 95 | + |
0 commit comments