-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for openwhisk web actions; #20
- Loading branch information
Showing
47 changed files
with
2,930 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...tainer/src/main/java/com/jrestless/core/interceptor/ConditionalBase64ReadInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2017 Bjoern Bilger | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.jrestless.core.interceptor; | ||
|
||
import java.io.IOException; | ||
import java.util.Base64; | ||
|
||
import javax.ws.rs.WebApplicationException; | ||
import javax.ws.rs.ext.ReaderInterceptor; | ||
import javax.ws.rs.ext.ReaderInterceptorContext; | ||
|
||
/** | ||
* Wraps the {@link ReaderInterceptorContext context's} input stream with a | ||
* base64 decoder (RFC4648; not URL-safe) if {@link #isBase64(ReaderInterceptorContext)} | ||
* returns true. | ||
* | ||
* @author Bjoern Bilger | ||
* | ||
*/ | ||
public abstract class ConditionalBase64ReadInterceptor implements ReaderInterceptor { | ||
|
||
@Override | ||
public final Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { | ||
if (isBase64(context)) { | ||
context.setInputStream(Base64.getDecoder().wrap(context.getInputStream())); | ||
} | ||
return context.proceed(); | ||
} | ||
|
||
/** | ||
* Returns true if the {@link ReaderInterceptorContext context's} | ||
* input stream should be wrapped by a base64 decoder. | ||
* | ||
* @param context | ||
* the response context | ||
* @return {@code true} in case the context's input stream must be wrapped | ||
* by a base64 encoder; {@code false} otherwise | ||
*/ | ||
protected abstract boolean isBase64(ReaderInterceptorContext context); | ||
} |
52 changes: 52 additions & 0 deletions
52
...ainer/src/main/java/com/jrestless/core/interceptor/ConditionalBase64WriteInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2017 Bjoern Bilger | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.jrestless.core.interceptor; | ||
|
||
import java.io.IOException; | ||
import java.util.Base64; | ||
|
||
import javax.ws.rs.ext.WriterInterceptor; | ||
import javax.ws.rs.ext.WriterInterceptorContext; | ||
|
||
/** | ||
* Wraps the {@link WriterInterceptorContext context's} output stream with a | ||
* base64 encoder (RFC4648; not URL-safe) if {@link #isBase64(WriterInterceptorContext)} | ||
* returns true. | ||
* | ||
* @author Bjoern Bilger | ||
* | ||
*/ | ||
public abstract class ConditionalBase64WriteInterceptor implements WriterInterceptor { | ||
|
||
@Override | ||
public final void aroundWriteTo(WriterInterceptorContext context) throws IOException { | ||
if (isBase64(context)) { | ||
context.setOutputStream(Base64.getEncoder().wrap(context.getOutputStream())); | ||
} | ||
context.proceed(); | ||
} | ||
|
||
/** | ||
* Returns true if the {@link WriterInterceptorContext context's} | ||
* output stream should be wrapped by a base64 encoder. | ||
* | ||
* @param context | ||
* the response context | ||
* @return {@code true} in case the context's output stream must be wrapped | ||
* by a base64 encoder; {@code false} otherwise | ||
*/ | ||
protected abstract boolean isBase64(WriterInterceptorContext context); | ||
} |
Oops, something went wrong.