-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e9ab30
commit f4bcfe9
Showing
17 changed files
with
1,121 additions
and
113 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
60 changes: 60 additions & 0 deletions
60
...n/java/org/jboss/resteasy/security/doseta/ClientDigitalSigningHeaderDecoratorFeature.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,60 @@ | ||
package org.jboss.resteasy.security.doseta; | ||
|
||
import org.jboss.resteasy.annotations.security.doseta.Signed; | ||
import org.jboss.resteasy.spi.ResteasyProviderFactory; | ||
|
||
import javax.ws.rs.BindingPriority; | ||
import javax.ws.rs.ConstrainedTo; | ||
import javax.ws.rs.client.ClientRequestContext; | ||
import javax.ws.rs.client.ClientRequestFilter; | ||
import javax.ws.rs.container.DynamicFeature; | ||
import javax.ws.rs.container.ResourceInfo; | ||
import javax.ws.rs.core.Configurable; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
@ConstrainedTo(ConstrainedTo.Type.CLIENT) | ||
public class ClientDigitalSigningHeaderDecoratorFeature implements DynamicFeature | ||
{ | ||
@Override | ||
public void configure(ResourceInfo resourceInfo, Configurable configurable) | ||
{ | ||
Signed signed = resourceInfo.getResourceMethod().getAnnotation(Signed.class); | ||
if (signed == null) | ||
{ | ||
signed = (Signed) resourceInfo.getResourceClass().getAnnotation(Signed.class); | ||
} | ||
if (signed == null) return; | ||
|
||
configurable.register(new DigitalSigningHeaderDecorator(signed)); | ||
} | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
@BindingPriority(BindingPriority.HEADER_DECORATOR) | ||
public static class DigitalSigningHeaderDecorator extends AbstractDigitalSigningHeaderDecorator implements ClientRequestFilter | ||
{ | ||
public DigitalSigningHeaderDecorator(Signed signed) | ||
{ | ||
this.signed = signed; | ||
} | ||
|
||
@Override | ||
public void filter(ClientRequestContext requestContext) throws IOException | ||
{ | ||
KeyRepository repository = (KeyRepository) requestContext.getProperty(KeyRepository.class.getName()); | ||
if (repository == null) | ||
{ | ||
repository = ResteasyProviderFactory.getContextData(KeyRepository.class); | ||
} | ||
DKIMSignature header = createHeader(repository); | ||
requestContext.getHeaders().add(DKIMSignature.DKIM_SIGNATURE, header); | ||
} | ||
|
||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...a/org/jboss/resteasy/security/doseta/ClientDigitalVerificationHeaderDecoratorFeature.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,56 @@ | ||
package org.jboss.resteasy.security.doseta; | ||
|
||
import org.jboss.resteasy.annotations.security.doseta.Verifications; | ||
import org.jboss.resteasy.annotations.security.doseta.Verify; | ||
|
||
import javax.ws.rs.BindingPriority; | ||
import javax.ws.rs.ConstrainedTo; | ||
import javax.ws.rs.client.ClientRequestContext; | ||
import javax.ws.rs.client.ClientResponseContext; | ||
import javax.ws.rs.client.ClientResponseFilter; | ||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerRequestFilter; | ||
import javax.ws.rs.container.DynamicFeature; | ||
import javax.ws.rs.container.ResourceInfo; | ||
import javax.ws.rs.core.Configurable; | ||
import javax.ws.rs.ext.Provider; | ||
import java.io.IOException; | ||
|
||
/** | ||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a> | ||
* @version $Revision: 1 $ | ||
*/ | ||
@Provider | ||
@ConstrainedTo(ConstrainedTo.Type.CLIENT) | ||
public class ClientDigitalVerificationHeaderDecoratorFeature implements DynamicFeature | ||
{ | ||
@Override | ||
public void configure(ResourceInfo resourceInfo, Configurable configurable) | ||
{ | ||
Verify verify = resourceInfo.getResourceMethod().getAnnotation(Verify.class); | ||
Verifications verifications = resourceInfo.getResourceClass().getAnnotation(Verifications.class); | ||
|
||
if (verify != null || verifications != null) | ||
{ | ||
configurable.register(new DigitalVerificationHeaderDecorator(verify, verifications)); | ||
} | ||
|
||
} | ||
|
||
@BindingPriority(BindingPriority.HEADER_DECORATOR) | ||
public static class DigitalVerificationHeaderDecorator extends AbstractDigitalVerificationHeaderDecorator implements ClientResponseFilter | ||
{ | ||
public DigitalVerificationHeaderDecorator(Verify verify, Verifications verifications) | ||
{ | ||
this.verify = verify; | ||
this.verifications = verifications; | ||
} | ||
|
||
@Override | ||
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException | ||
{ | ||
requestContext.setProperty(Verifier.class.getName(), create()); | ||
} | ||
|
||
} | ||
} |
15 changes: 14 additions & 1 deletion
15
.../ClientDigitalSigningHeaderDecorator.java → ...rDecoratorClientExecutionInterceptor.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
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
Oops, something went wrong.