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
#!/bin/bash | |
# --------------------------- FUNCTIONS --------------------------------- | |
_line() { | |
printf %80s |tr " " "-"; echo "" | |
} | |
_info() { | |
echo -e 1>&2 "\033[32m"$@"\033[0m" | |
} |
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
### Keybase proof | |
I hereby claim: | |
* I am espenhh on github. | |
* I am espenhh (https://keybase.io/espenhh) on keybase. | |
* I have a public key ASCfqeGuidGjUaMb5hBKERUNWyuZKy6u3Rt5NRF8GHjBYgo | |
To claim this, I am signing this object: |
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
### Keybase proof | |
I hereby claim: | |
* I am espenhh on github. | |
* I am espenhh (https://keybase.io/espenhh) on keybase. | |
* I have a public key ASCfqeGuidGjUaMb5hBKERUNWyuZKy6u3Rt5NRF8GHjBYgo | |
To claim this, I am signing this object: |
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
#/bin/bash | |
COMMAND="mvn run whatever kommandoen din for å kjøre er" | |
RED=$(echo -e '\033[41m\033[37m') | |
YELLOW=$(echo -e '\033[43m\033[37m') | |
NORMAL=$(echo -e '\033[0m') | |
$COMMAND | sed -e "s/.*WARN.*/$YELLOW&$NORMAL/" -e "s/.*ERROR.*/$RED&$NORMAL/" |
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
public class ContentMD5VerifikasjonsFilter implements ContainerRequestFilter { | |
@Override | |
public ContainerRequest filter(final ContainerRequest request) { | |
try { | |
// Henter ut alle bytes fra requesten (payload) | |
byte[] entityBytes = IOUtils.toByteArray(request.getEntityInputStream()); // Apache commons | |
// Sjekker bare Content-MD5 dersom det er en request med payload | |
if (entityBytes.length > 0) { | |
String contentMD5Client = request.getHeaderValue("Content-MD5"); |
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
POST | |
/path/to/resource | |
content-md5: Q2hlY2sgSW50YWdyaXR5IQ== | |
date: Wed, 29 Jun 2011 14:58:11 GMT | |
x-vendor-userid: 59829 | |
param1=34¶m2=lol |
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
String stringToSign = uppercase(verb) + "\n" + | |
lowercase(path) + "\n" + | |
"content-md5: " + md5Header + "\n" + | |
"date: " + datoHeader + "\n" + | |
"x-vendor-userid: " + virksomhetsId + "\n" + | |
lowercase(urlencode(requestparametre)) + "\n"; |
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
@Path("/user") | |
public class UserResource { | |
@PUT | |
@Path("{username: [a-zA-Z][a-zA-Z_0-9]*}") | |
@Consumes("application/json, application/xml") | |
@Produces("application/json, application/xml") | |
public Response updateUser(@PathParam("username") String userName) { | |
//Do your thing here… ;) | |
} |
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
@Component | |
public class SignatureVerifikasjonsFilter implements ContainerRequestFilter { | |
@Override | |
public ContainerRequest filter(final ContainerRequest request) { | |
// Henter ut id'en brukeren utgir seg for å være | |
String userIdHeader = request.getHeaderValue"X-Vendor-Userid"); | |
// Henter ut Bruker-objektet |
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
public class DatoVerifikasjonsFilter implements ContainerRequestFilter { | |
@Override | |
public ContainerRequest filter(final ContainerRequest request) { | |
String dato = request.getHeaderValue(Headers.Date); | |
if (dato != null) { | |
sjekkDato(dato); | |
} else { | |
// Kast feil - datoheader mangler! | |
} |
NewerOlder