Skip to content

Instantly share code, notes, and snippets.

@Pushpalanka
Pushpalanka / svid.cert
Created December 29, 2018 17:09
A sample SVID in SPIFFE
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 10608244402538346926 (0x93380e1447d2f9ae)
Signature Algorithm: ecdsa-with-SHA512
Issuer: C=US, O=SPIRE
Validity
Not Before: May 13 19:33:47 2018 GMT
Not After : May 12 19:33:47 2023 GMT
Subject: C=US, O=SPIRE
@Pushpalanka
Pushpalanka / Signature.java
Created June 24, 2017 05:08
Customize Signing
@Override
public Assertion doSetSignature(Assertion assertion, String signatureAlgorithm, X509Credential cred) throws IdentityException {
try {
//override the credentials with our desired one
cred = getRequiredCredentials();
Signature signature = (Signature) buildXMLObject(Signature.DEFAULT_ELEMENT_NAME);
signature.setSigningCredential(cred);
signature.setSignatureAlgorithm(signatureAlgorithm);
@Pushpalanka
Pushpalanka / CustomClaimHandler.java
Created June 24, 2017 05:00
CustomClaimHandler
public class CustomClaimHandler implements ClaimHandler {
private static Log log = LogFactory.getLog(CustomClaimHandler.class);
private static volatile CustomClaimHandler instance;
private String connectionURL = null;
private String userName = null;
private String password = null;
private String jdbcDriver = null;
private String sql = null;
@Pushpalanka
Pushpalanka / SAMLResponse_attributes.xml
Created June 24, 2017 04:57
SAML Response with attributes
<?xml version="1.0"?>
<saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:xs="http://www.w3.org/2001/XMLSchema" Destination="https://localhost:9444/acs" ID="faibaccbcepemkackalbbjkihlegenhhigcdjbjk" InResponseTo="kbedjkocfjdaaadgmjeipbegnclbelfffbpbophe" IssueInstant="2014-07-17T13:15:05.032Z" Version="2.0">
<saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">localhost
</saml2:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
..........
</ds:Signature>
<saml2p:Status>
<saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</saml2p:Status>
@Pushpalanka
Pushpalanka / Response.xml
Created June 14, 2017 09:08
SAML Response Wrapping XACML Response.
<samlp:Response IssueInstant="2011-10-31T06:49:51.013Z" Version="2.0" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<saml:Issuer SPProvidedID="SPPProvierId" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
https://identity.carbon.wso2.org</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
@Pushpalanka
Pushpalanka / XACMLAuthzDecisionQuery.xml
Created June 14, 2017 09:06
XACMLAuthzDecisionQuery
<xacml-samlp:XACMLAuthzDecisionQueryType InputContextOnly="true" IssueInstant="2011-10-31T06:44:57.766Z" ReturnContext="false" Version="2.0" xmlns:xacml-samlp="urn:oasis:names:tc:xacml:2.0:profile:saml2.0:v2:schema:protocol">
<saml:Issuer SPProvidedID="SPPProvierId" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> https://identity.carbon.wso2.org</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
@Pushpalanka
Pushpalanka / XACMLResponse.xml
Created June 14, 2017 08:57
XACML Response
<Response>
<Result ResourceId="http://localhost:8280/services/echo/echoString">
<Decision>Permit</Decision>
<Status>
<StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/>
</Status>
</Result>
</Response>
@Pushpalanka
Pushpalanka / XACMLRequest.xml
Created June 14, 2017 08:56
Sample XACML Request
<Request xmlns="urn:oasis:names:tc:xacml:2.0:context:schema:os">
<Subject>
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:subject:subject-id"
DataType="http://www.w3.org/2001/XMLSchema#string">
<AttributeValue>admin</AttributeValue>
</Attribute>
</Subject>
<Resource>
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:resource:resource-id"
DataType="http://www.w3.org/2001/XMLSchema#string">
@Pushpalanka
Pushpalanka / SetKeyStore.java
Last active June 14, 2017 08:37
Setting keystore in WSO2 code
//Path to Java Key Store (JKS) which is a portable repository of X.509 certificates
//and private keys for encrypting and signing some thing with the private key
String path = "/home/pushpalanka/Installations/wso2is-3.0.1/resources/security/" + "wso2carbon.jks";
//Store of CA certificates to trust. Required to authenticate remote servers
System.setProperty("javax.net.ssl.trustStore", path);
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
try {
//Create a configuration context. A configuration context contains information
osgi> 13:17:41.503 [Timer-0] ERROR org.wso2.carbon.security.caas.internal.CarbonSecurityComponent - org.wso2.carbon.security.userstore.jdbc.connector.JDBCCredentialStoreConnector.init(Ljava/lang/String;Lorg/wso2/carbon/security/caas/user/core/config/CredentialStoreConnectorConfig;)V
java.lang.AbstractMethodError: org.wso2.carbon.security.userstore.jdbc.connector.JDBCCredentialStoreConnector.init(Ljava/lang/String;Lorg/wso2/carbon/security/caas/user/core/config/CredentialStoreConnectorConfig;)V
at org.wso2.carbon.security.caas.user.core.store.CredentialStoreImpl.init(CredentialStoreImpl.java:74) ~[?:?]
at org.wso2.carbon.security.caas.user.core.common.CarbonRealmServiceImpl.<init>(CarbonRealmServiceImpl.java:56) ~[?:?]
at org.wso2.carbon.security.caas.internal.CarbonSecurityComponent.onAllRequiredCapabilitiesAvailable(CarbonSecurityComponent.java:310) ~[?:?]
at org.wso2.carbon.kernel.internal.startupresolver.StartupComponentManager.lambda$notifySatisfiableComponents$27(StartupComponentManager.java:237) ~[?