-`
-})
-export class AppComponent {
-
- constructor(private _kc:KeycloakService, private http:Http){ }
-
- products : string[] = [];
-
- logout(){
- this._kc.logout();
- }
-
- reloadData() {
- //angular dont have http interceptor yet
-
- this._kc.getToken().then(
- token=>{
- let headers = new Headers({
- 'Accept': 'application/json',
- 'Authorization': 'Bearer ' + token
- });
-
- let options = new RequestOptions({ headers: headers });
-
- this.http.get('/database/products', options)
- .map(res => res.json())
- .subscribe(
- prods => this.products = prods,
- error => console.log(error));
-
- },
- error=>{
- console.log(error);
- }
- );
-
- }
-
- private handleError (error: Response) {
- console.error(error);
- return Observable.throw(error.json().error || 'Server error');
- }
-
-}
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/app/keycloak.service.ts b/examples/demo-template/angular2-product-app/src/main/webapp/app/keycloak.service.ts
new file mode 100644
index 0000000000..33fc28357e
--- /dev/null
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/app/keycloak.service.ts
@@ -0,0 +1,48 @@
+import { Injectable } from '@angular/core';
+
+declare var Keycloak: any;
+
+@Injectable()
+export class KeycloakService {
+ static auth: any = {};
+
+ static init(): Promise {
+ let keycloakAuth: any = new Keycloak('keycloak.json');
+ KeycloakService.auth.loggedIn = false;
+
+ return new Promise((resolve, reject) => {
+ keycloakAuth.init({ onLoad: 'login-required' })
+ .success(() => {
+ KeycloakService.auth.loggedIn = true;
+ KeycloakService.auth.authz = keycloakAuth;
+ KeycloakService.auth.logoutUrl = keycloakAuth.authServerUrl + "/realms/demo/protocol/openid-connect/logout?redirect_uri=/angular2-product/index.html";
+ resolve();
+ })
+ .error(() => {
+ reject();
+ });
+ });
+ }
+
+ logout() {
+ console.log('*** LOGOUT');
+ KeycloakService.auth.loggedIn = false;
+ KeycloakService.auth.authz = null;
+
+ window.location.href = KeycloakService.auth.logoutUrl;
+ }
+
+ getToken(): Promise {
+ return new Promise((resolve, reject) => {
+ if (KeycloakService.auth.authz.token) {
+ KeycloakService.auth.authz.updateToken(5)
+ .success(() => {
+ resolve(KeycloakService.auth.authz.token);
+ })
+ .error(() => {
+ reject('Failed to refresh token');
+ });
+ }
+ });
+ }
+}
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/app/keycloak.ts b/examples/demo-template/angular2-product-app/src/main/webapp/app/keycloak.ts
deleted file mode 100644
index 64242ae932..0000000000
--- a/examples/demo-template/angular2-product-app/src/main/webapp/app/keycloak.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import {Injectable} from 'angular2/core';
-
-
-declare var Keycloak: any;
-
-@Injectable()
-export class KeycloakService {
-
- static auth : any = {};
-
- static init() : Promise{
- let keycloakAuth : any = new Keycloak('keycloak.json');
- KeycloakService.auth.loggedIn = false;
-
- return new Promise((resolve,reject)=>{
- keycloakAuth.init({ onLoad: 'login-required' })
- .success( () => {
- KeycloakService.auth.loggedIn = true;
- KeycloakService.auth.authz = keycloakAuth;
- KeycloakService.auth.logoutUrl = keycloakAuth.authServerUrl + "/realms/demo/tokens/logout?redirect_uri=/angular2-product/index.html";
- resolve(null);
- })
- .error(()=> {
- reject(null);
- });
- });
- }
-
- logout(){
- console.log('*** LOGOUT');
- KeycloakService.auth.loggedIn = false;
- KeycloakService.auth.authz = null;
-
- window.location.href = KeycloakService.auth.logoutUrl;
- }
-
- getToken(): Promise{
- return new Promise((resolve,reject)=>{
- if (KeycloakService.auth.authz.token) {
- KeycloakService.auth.authz.updateToken(5).success(function() {
- resolve(KeycloakService.auth.authz.token);
- })
- .error(function() {
- reject('Failed to refresh token');
- });
- }
- });
- }
-}
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/app/main.ts b/examples/demo-template/angular2-product-app/src/main/webapp/app/main.ts
index 73613b2b92..6bf99bfc91 100644
--- a/examples/demo-template/angular2-product-app/src/main/webapp/app/main.ts
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/app/main.ts
@@ -1,14 +1,11 @@
-import 'rxjs/Rx';
-import {bootstrap} from 'angular2/platform/browser';
-import {HTTP_BINDINGS} from 'angular2/http';
-import {KeycloakService} from './keycloak';
-import {AppComponent} from './app';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+import { AppModule } from './app.module';
-KeycloakService.init().then(
- o=>{
- bootstrap(AppComponent,[HTTP_BINDINGS, KeycloakService]);
- },
- x=>{
- window.location.reload();
- }
-);
\ No newline at end of file
+import {KeycloakService} from './keycloak.service';
+
+KeycloakService.init()
+ .then(() => {
+ const platform = platformBrowserDynamic();
+ platform.bootstrapModule(AppModule);
+ })
+ .catch(() => window.location.reload());
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/index.html b/examples/demo-template/angular2-product-app/src/main/webapp/index.html
index 2da600c335..1edeb56477 100644
--- a/examples/demo-template/angular2-product-app/src/main/webapp/index.html
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/index.html
@@ -2,48 +2,23 @@
Angular 2 QuickStart
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
Loading...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/keycloak.json b/examples/demo-template/angular2-product-app/src/main/webapp/keycloak.json
index ddd1f2ec81..87a2ad64ef 100644
--- a/examples/demo-template/angular2-product-app/src/main/webapp/keycloak.json
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/keycloak.json
@@ -1,6 +1,5 @@
{
"realm": "demo",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "/auth",
"ssl-required": "external",
"resource": "angular2-product",
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/package.json b/examples/demo-template/angular2-product-app/src/main/webapp/package.json
index f66b44c110..5bd783b03e 100644
--- a/examples/demo-template/angular2-product-app/src/main/webapp/package.json
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/package.json
@@ -2,24 +2,36 @@
"name": "angular2-product-app",
"version": "1.0.0",
"scripts": {
+ "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
+ "lite": "lite-server",
+ "postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
- "lite": "lite-server",
- "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
+ "typings": "typings"
},
"license": "ISC",
"dependencies": {
- "angular2": "2.0.0-beta.3",
- "systemjs": "0.19.6",
- "es6-promise": "^3.0.2",
- "es6-shim": "^0.33.3",
- "reflect-metadata": "0.1.2",
- "rxjs": "5.0.0-beta.0",
- "zone.js": "0.5.11"
+ "@angular/common": "2.0.0",
+ "@angular/compiler": "2.0.0",
+ "@angular/core": "2.0.0",
+ "@angular/forms": "2.0.0",
+ "@angular/http": "2.0.0",
+ "@angular/platform-browser": "2.0.0",
+ "@angular/platform-browser-dynamic": "2.0.0",
+ "@angular/router": "3.0.0",
+ "@angular/upgrade": "2.0.0",
+ "angular2-in-memory-web-api": "0.0.20",
+ "bootstrap": "^3.3.6",
+ "core-js": "^2.4.1",
+ "reflect-metadata": "^0.1.3",
+ "rxjs": "5.0.0-beta.12",
+ "systemjs": "0.19.27",
+ "zone.js": "^0.6.21"
},
"devDependencies": {
- "concurrently": "^1.0.0",
- "lite-server": "^2.0.1",
- "typescript": "^1.7.5"
+ "concurrently": "^2.2.0",
+ "lite-server": "^2.2.2",
+ "typescript": "^2.0.2",
+ "typings": "^1.3.2"
}
}
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/systemjs.config.js b/examples/demo-template/angular2-product-app/src/main/webapp/systemjs.config.js
new file mode 100644
index 0000000000..de199e68ce
--- /dev/null
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/systemjs.config.js
@@ -0,0 +1,43 @@
+/**
+ * System configuration for Angular 2 samples
+ * Adjust as necessary for your application needs.
+ */
+(function (global) {
+ System.config({
+ paths: {
+ // paths serve as alias
+ 'npm:': 'node_modules/'
+ },
+ // map tells the System loader where to look for things
+ map: {
+ // our app is within the app folder
+ app: 'app',
+ // angular bundles
+ '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
+ '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
+ '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
+ '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
+ '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
+ '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
+ '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
+ '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
+ // other libraries
+ 'rxjs': 'npm:rxjs',
+ 'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
+ },
+ // packages tells the System loader how to load when no filename and/or no extension
+ packages: {
+ app: {
+ main: './main.js',
+ defaultExtension: 'js'
+ },
+ rxjs: {
+ defaultExtension: 'js'
+ },
+ 'angular2-in-memory-web-api': {
+ main: './index.js',
+ defaultExtension: 'js'
+ }
+ }
+ });
+})(this);
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/tsconfig.json b/examples/demo-template/angular2-product-app/src/main/webapp/tsconfig.json
index 52c77a54a4..e6a6eac11d 100644
--- a/examples/demo-template/angular2-product-app/src/main/webapp/tsconfig.json
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/tsconfig.json
@@ -1,15 +1,12 @@
{
"compilerOptions": {
"target": "es5",
- "module": "system",
+ "module": "commonjs",
"moduleResolution": "node",
- "sourceMap": false,
+ "sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
- },
- "exclude": [
- "node_modules"
- ]
-}
\ No newline at end of file
+ }
+}
diff --git a/examples/demo-template/angular2-product-app/src/main/webapp/typings.json b/examples/demo-template/angular2-product-app/src/main/webapp/typings.json
new file mode 100644
index 0000000000..7da31ca0af
--- /dev/null
+++ b/examples/demo-template/angular2-product-app/src/main/webapp/typings.json
@@ -0,0 +1,7 @@
+{
+ "globalDependencies": {
+ "core-js": "registry:dt/core-js#0.0.0+20160725163759",
+ "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
+ "node": "registry:dt/node#6.0.0+20160909174046"
+ }
+}
diff --git a/examples/demo-template/customer-app-cli/src/main/resources/META-INF/keycloak.json b/examples/demo-template/customer-app-cli/src/main/resources/META-INF/keycloak.json
index 51c8775c99..1c61433813 100644
--- a/examples/demo-template/customer-app-cli/src/main/resources/META-INF/keycloak.json
+++ b/examples/demo-template/customer-app-cli/src/main/resources/META-INF/keycloak.json
@@ -1,6 +1,5 @@
{
"realm" : "demo",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url" : "http://localhost:8080/auth",
"ssl-required" : "external",
"resource" : "customer-portal-cli",
diff --git a/examples/demo-template/customer-app-filter/src/main/webapp/WEB-INF/keycloak.json b/examples/demo-template/customer-app-filter/src/main/webapp/WEB-INF/keycloak.json
index 14e56f543b..3766330ece 100755
--- a/examples/demo-template/customer-app-filter/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/demo-template/customer-app-filter/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "customer-portal-filter",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "/auth",
"ssl-required" : "external",
"expose-token": true,
diff --git a/examples/demo-template/customer-app-js/src/main/webapp/keycloak.json b/examples/demo-template/customer-app-js/src/main/webapp/keycloak.json
index 224c70b76f..4a60ffacd0 100644
--- a/examples/demo-template/customer-app-js/src/main/webapp/keycloak.json
+++ b/examples/demo-template/customer-app-js/src/main/webapp/keycloak.json
@@ -1,6 +1,5 @@
{
"realm" : "demo",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url" : "/auth",
"ssl-required" : "external",
"resource" : "customer-portal-js",
diff --git a/examples/demo-template/customer-app/src/main/webapp/WEB-INF/keycloak.json b/examples/demo-template/customer-app/src/main/webapp/WEB-INF/keycloak.json
index c2241b3e91..20619097b5 100755
--- a/examples/demo-template/customer-app/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/demo-template/customer-app/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "customer-portal",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "/auth",
"ssl-required" : "external",
"expose-token": true,
diff --git a/examples/demo-template/database-service/src/main/webapp/WEB-INF/keycloak.json b/examples/demo-template/database-service/src/main/webapp/WEB-INF/keycloak.json
index cb938548dc..72e4903bc6 100755
--- a/examples/demo-template/database-service/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/demo-template/database-service/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm" : "demo",
"resource" : "database-service",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "/auth",
"bearer-only" : true,
"ssl-required" : "external"
diff --git a/examples/demo-template/offline-access-app/src/main/webapp/WEB-INF/keycloak.json b/examples/demo-template/offline-access-app/src/main/webapp/WEB-INF/keycloak.json
index dff976cf0e..600dcfa8a8 100644
--- a/examples/demo-template/offline-access-app/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/demo-template/offline-access-app/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "offline-access-portal",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "/auth",
"ssl-required" : "external",
"credentials": {
diff --git a/examples/demo-template/pom.xml b/examples/demo-template/pom.xml
index b7fc0274ee..dbc0218250 100755
--- a/examples/demo-template/pom.xml
+++ b/examples/demo-template/pom.xml
@@ -51,6 +51,7 @@
example-earadmin-access-appangular-product-app
+ angular2-product-appdatabase-servicethird-partythird-party-cdi
diff --git a/examples/demo-template/product-app/src/main/webapp/WEB-INF/keycloak.json b/examples/demo-template/product-app/src/main/webapp/WEB-INF/keycloak.json
index 0a86c041c7..109270101f 100755
--- a/examples/demo-template/product-app/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/demo-template/product-app/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm" : "demo",
"resource" : "product-portal",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url" : "/auth",
"ssl-required" : "external",
"credentials" : {
diff --git a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java
index e4d6a4033a..72ffd4959b 100644
--- a/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java
+++ b/examples/demo-template/service-account/src/main/java/org/keycloak/example/ProductServiceAccountServlet.java
@@ -41,6 +41,7 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.keycloak.OAuth2Constants;
import org.keycloak.RSATokenVerifier;
+import org.keycloak.adapters.rotation.AdapterRSATokenVerifier;
import org.keycloak.common.VerificationException;
import org.keycloak.adapters.KeycloakDeployment;
import org.keycloak.adapters.KeycloakDeploymentBuilder;
@@ -163,7 +164,7 @@ public abstract class ProductServiceAccountServlet extends HttpServlet {
private void setTokens(HttpServletRequest req, KeycloakDeployment deployment, AccessTokenResponse tokenResponse) throws IOException, VerificationException {
String token = tokenResponse.getToken();
String refreshToken = tokenResponse.getRefreshToken();
- AccessToken tokenParsed = RSATokenVerifier.verifyToken(token, deployment.getRealmKey(), deployment.getRealmInfoUrl());
+ AccessToken tokenParsed = AdapterRSATokenVerifier.verifyToken(token, deployment);
req.getSession().setAttribute(TOKEN, token);
req.getSession().setAttribute(REFRESH_TOKEN, refreshToken);
req.getSession().setAttribute(TOKEN_PARSED, tokenParsed);
diff --git a/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-secret.json b/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-secret.json
index 7eec22a6c3..1a9322d96a 100644
--- a/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-secret.json
+++ b/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-secret.json
@@ -1,6 +1,5 @@
{
"realm" : "demo",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url" : "http://localhost:8080/auth",
"ssl-required" : "external",
"resource" : "product-sa-client",
diff --git a/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-signed-jwt.json b/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-signed-jwt.json
index 3e90c34a30..3c99da7b42 100644
--- a/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-signed-jwt.json
+++ b/examples/demo-template/service-account/src/main/webapp/WEB-INF/keycloak-client-signed-jwt.json
@@ -1,6 +1,5 @@
{
"realm" : "demo",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url" : "http://localhost:8080/auth",
"ssl-required" : "external",
"resource" : "product-sa-client-jwt-auth",
diff --git a/examples/fuse/camel/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/examples/fuse/camel/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index a4796cc152..56550d681a 100644
--- a/examples/fuse/camel/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/examples/fuse/camel/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -26,7 +26,6 @@
-
diff --git a/examples/fuse/customer-app-fuse/src/main/webapp/WEB-INF/keycloak.json b/examples/fuse/customer-app-fuse/src/main/webapp/WEB-INF/keycloak.json
index b5d6b30d24..c7f61f68e3 100755
--- a/examples/fuse/customer-app-fuse/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/fuse/customer-app-fuse/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "customer-portal",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "http://localhost:8080/auth",
"ssl-required" : "external",
"credentials": {
diff --git a/examples/fuse/cxf-jaxrs/src/main/resources/WEB-INF/keycloak.json b/examples/fuse/cxf-jaxrs/src/main/resources/WEB-INF/keycloak.json
index f5d7e1a989..a8c4b752e1 100644
--- a/examples/fuse/cxf-jaxrs/src/main/resources/WEB-INF/keycloak.json
+++ b/examples/fuse/cxf-jaxrs/src/main/resources/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "builtin-cxf-app",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "http://localhost:8080/auth",
"ssl-required" : "external",
"credentials": {
diff --git a/examples/fuse/cxf-jaxws/src/main/resources/META-INF/spring/beans.xml b/examples/fuse/cxf-jaxws/src/main/resources/META-INF/spring/beans.xml
index 2d15ae017b..8a808c623c 100644
--- a/examples/fuse/cxf-jaxws/src/main/resources/META-INF/spring/beans.xml
+++ b/examples/fuse/cxf-jaxws/src/main/resources/META-INF/spring/beans.xml
@@ -32,7 +32,6 @@
-
diff --git a/examples/fuse/external-config/external-config-keycloak.json b/examples/fuse/external-config/external-config-keycloak.json
index 920e99a677..469da82a17 100644
--- a/examples/fuse/external-config/external-config-keycloak.json
+++ b/examples/fuse/external-config/external-config-keycloak.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "external-config",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "http://localhost:8080/auth",
"ssl-required" : "external",
"credentials": {
diff --git a/examples/fuse/fuse-admin/keycloak-direct-access.json b/examples/fuse/fuse-admin/keycloak-direct-access.json
index 8e5ac0ff24..2441134231 100644
--- a/examples/fuse/fuse-admin/keycloak-direct-access.json
+++ b/examples/fuse/fuse-admin/keycloak-direct-access.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "ssh-jmx-admin-client",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"ssl-required" : "external",
"auth-server-url" : "http://localhost:8080/auth",
"credentials": {
diff --git a/examples/fuse/product-app-fuse/src/main/resources/WEB-INF/keycloak.json b/examples/fuse/product-app-fuse/src/main/resources/WEB-INF/keycloak.json
index 2a52d247f7..e90433ac51 100644
--- a/examples/fuse/product-app-fuse/src/main/resources/WEB-INF/keycloak.json
+++ b/examples/fuse/product-app-fuse/src/main/resources/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm": "demo",
"resource": "product-portal",
- "realm-public-key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "http://localhost:8080/auth",
"ssl-required" : "external",
"credentials": {
diff --git a/examples/js-console/src/main/webapp/keycloak.json b/examples/js-console/src/main/webapp/keycloak.json
index c0c04d5aee..cc4bab3394 100644
--- a/examples/js-console/src/main/webapp/keycloak.json
+++ b/examples/js-console/src/main/webapp/keycloak.json
@@ -1,6 +1,5 @@
{
"realm" : "example",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url" : "/auth",
"ssl-required" : "external",
"resource" : "js-console",
diff --git a/examples/kerberos/src/main/webapp/WEB-INF/keycloak.json b/examples/kerberos/src/main/webapp/WEB-INF/keycloak.json
index db1223c6b2..7e9d91a7da 100644
--- a/examples/kerberos/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/kerberos/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm" : "kerberos-demo",
"resource" : "kerberos-app",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "/auth",
"ssl-required" : "external",
"credentials": {
diff --git a/examples/ldap/src/main/webapp/WEB-INF/keycloak.json b/examples/ldap/src/main/webapp/WEB-INF/keycloak.json
index 84e1129a88..f43107b054 100644
--- a/examples/ldap/src/main/webapp/WEB-INF/keycloak.json
+++ b/examples/ldap/src/main/webapp/WEB-INF/keycloak.json
@@ -1,7 +1,6 @@
{
"realm" : "ldap-demo",
"resource" : "ldap-app",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url": "/auth",
"ssl-required" : "external",
"credentials": {
diff --git a/examples/multi-tenant/src/main/resources/tenant1-keycloak.json b/examples/multi-tenant/src/main/resources/tenant1-keycloak.json
index 57be2774e7..34c17737b3 100644
--- a/examples/multi-tenant/src/main/resources/tenant1-keycloak.json
+++ b/examples/multi-tenant/src/main/resources/tenant1-keycloak.json
@@ -1,7 +1,6 @@
{
"realm" : "tenant1",
"resource" : "multi-tenant",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
"auth-server-url" : "http://localhost:8080/auth",
"ssl-required" : "external",
"credentials" : {
diff --git a/examples/multi-tenant/src/main/resources/tenant2-keycloak.json b/examples/multi-tenant/src/main/resources/tenant2-keycloak.json
index 4f221dc66d..5877082e35 100644
--- a/examples/multi-tenant/src/main/resources/tenant2-keycloak.json
+++ b/examples/multi-tenant/src/main/resources/tenant2-keycloak.json
@@ -1,7 +1,6 @@
{
"realm" : "tenant2",
"resource" : "multi-tenant",
- "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA0oJjgPQJhnVhOo51KauQGfLLreMFu64OJdKXRnfvAQJQTuKNwc5JrR63l/byyW1B6FgclABF818TtLvMCAkn4EuFwQZCZhg3x3+lFGiB/IzC6UAt4Bi0JQrTbdh83/U97GIPegvaDqiqEiQESEkbCZWxM6sh/34hQaAhCaFpMwIDAQAB",
"auth-server-url" : "http://localhost:8080/auth",
"ssl-required" : "external",
"credentials" : {
diff --git a/examples/providers/authenticator/README.md b/examples/providers/authenticator/README.md
index 1edf0ed693..54dc752734 100755
--- a/examples/providers/authenticator/README.md
+++ b/examples/providers/authenticator/README.md
@@ -6,13 +6,12 @@ of Keycloak. To deploy, build this directory then take the jar and copy it to
KEYCLOAK_HOME/bin/jboss-cli.sh --command="module add --name=org.keycloak.examples.secret-question --resources=target/authenticator-required-action-example.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-server-spi,org.keycloak.keycloak-services,org.jboss.resteasy.resteasy-jaxrs,javax.ws.rs.api"
-Then registering the provider by editing keycloak-server.json and adding the module to the providers field:
-
- "providers": [
- ....
- "module:org.keycloak.examples.secret-question"
- ],
+Then registering the provider by editing `standalone/configuration/standalone.xml` and adding the module to the providers element:
+
+ ...
+ module:org.keycloak.examples.secret-question
+
You then have to copy the secret-question.ftl and secret-question-config.ftl files to the themes/base/login directory.
diff --git a/examples/providers/domain-extension/README.md b/examples/providers/domain-extension/README.md
index e1aa2cdb62..51e2b3c56a 100644
--- a/examples/providers/domain-extension/README.md
+++ b/examples/providers/domain-extension/README.md
@@ -6,12 +6,12 @@ To run, deploy as a module by running:
$KEYCLOAK_HOME/bin/jboss-cli.sh --command="module add --name=org.keycloak.examples.domain-extension-example --resources=target/domain-extension-example.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-services,org.keycloak.keycloak-model-jpa,org.keycloak.keycloak-server-spi,javax.ws.rs.api,javax.persistence.api,org.hibernate,org.javassist"
-Then registering the provider by editing keycloak-server.json and adding the module to the providers field:
+Then registering the provider by editing `standalone/configuration/standalone.xml` and adding the module to the providers element:
- "providers": [
- ....
- "module:org.keycloak.examples.domain-extension-example"
- ],
+
+ ...
+ module:org.keycloak.examples.domain-extension-example
+
Then start (or restart) the server.
diff --git a/examples/providers/event-listener-sysout/README.md b/examples/providers/event-listener-sysout/README.md
index 57519f3e2c..8e1a0850ad 100644
--- a/examples/providers/event-listener-sysout/README.md
+++ b/examples/providers/event-listener-sysout/README.md
@@ -5,23 +5,25 @@ To deploy copy target/event-listener-sysout-example.jar to providers directory.
KEYCLOAK_HOME/bin/jboss-cli.sh --command="module add --name=org.keycloak.examples.event-sysout --resources=target/event-listener-sysout-example.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-server-spi"
-Then registering the provider by editing keycloak-server.json and adding the module to the providers field:
+Then registering the provider by editing `standalone/configuration/standalone.xml` and adding the module to the providers element:
- "providers": [
- ....
- "module:org.keycloak.examples.event-sysout"
- ],
+
+ ...
+ module:org.keycloak.examples.event-sysout
+
Then start (or restart) the server. Once started open the admin console, select your realm, then click on Events,
followed by config. Click on Listeners select box, then pick sysout from the dropdown. After this try to logout and
login again to see events printed to System.out.
The example event listener can be configured to exclude certain events, for example to exclude REFRESH_TOKEN and
-CODE_TO_TOKEN events add the following to keycloak-server.json:
+CODE_TO_TOKEN events add the following to `standalone.xml`:
...
- "eventsListener": {
- "sysout": {
- "exclude": [ "REFRESH_TOKEN", "CODE_TO_TOKEN" ]
- }
- }
+
+
+
+
+
+
diff --git a/examples/providers/event-store-mem/README.md b/examples/providers/event-store-mem/README.md
index d533fdad69..682ff42b78 100644
--- a/examples/providers/event-store-mem/README.md
+++ b/examples/providers/event-store-mem/README.md
@@ -5,24 +5,24 @@ To deploy copy target/event-store-mem-example.jar to providers directory. Altern
KEYCLOAK_HOME/bin/jboss-cli.sh --command="module add --name=org.keycloak.examples.event-inmem --resources=target/event-store-mem-example.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-server-spi"
-Then registering the provider by editing keycloak-server.json and adding the module to the providers field:
+Then registering the provider by editing `standalone/configuration/standalone.xml` and adding the module to the providers element:
- "providers": [
- ....
- "module:org.keycloak.examples.event-inmem"
- ],
+
+ ...
+ module:org.keycloak.examples.event-inmem
+
-Then edit standalone/configuration/keycloak-server.json, change:
+Then edit `standalone/configuration/standalone.xml`, change:
- "eventsStore": {
- "provider": "jpa"
- }
+
+ jpa
+
to:
- "eventsStore": {
- "provider": "in-mem"
- }
+
+ in-mem
+
Then start (or restart)the server. Once started open the admin console, select your realm, then click on Events,
followed by config. Set the toggle for Enabled to ON. After this try to logout and login again then open the Events tab
diff --git a/examples/providers/federation-provider/README.md b/examples/providers/federation-provider/README.md
index c8b443079d..c90e791547 100755
--- a/examples/providers/federation-provider/README.md
+++ b/examples/providers/federation-provider/README.md
@@ -6,13 +6,12 @@ key pairs. To deploy, build this directory then take the jar and copy it to pro
KEYCLOAK_HOME/bin/jboss-cli.sh --command="module add --name=org.keycloak.examples.userprops --resources=target/federation-properties-example.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-server-spi"
-Then registering the provider by editing keycloak-server.json and adding the module to the providers field:
-
- "providers": [
- ....
- "module:org.keycloak.examples.userprops"
- ],
+Then registering the provider by editing `standalone/configuration/standalone.xml` and adding the module to the providers element:
+
+ ...
+ module:org.keycloak.examples.userprops
+
You will then have to restart the authentication server.
diff --git a/examples/providers/federation-provider/src/main/java/org/keycloak/examples/federation/properties/BasePropertiesFederationFactory.java b/examples/providers/federation-provider/src/main/java/org/keycloak/examples/federation/properties/BasePropertiesFederationFactory.java
index 2d5abc3f22..e9ec451af5 100755
--- a/examples/providers/federation-provider/src/main/java/org/keycloak/examples/federation/properties/BasePropertiesFederationFactory.java
+++ b/examples/providers/federation-provider/src/main/java/org/keycloak/examples/federation/properties/BasePropertiesFederationFactory.java
@@ -96,7 +96,7 @@ public abstract class BasePropertiesFederationFactory implements UserFederationP
}
/**
- * You can import additional plugin configuration from keycloak-server.json here.
+ * You can import additional plugin configuration from standalone.xml here.
*
* @param config
*/
diff --git a/examples/providers/rest/README.md b/examples/providers/rest/README.md
index 5124f88b1d..5ee9327132 100644
--- a/examples/providers/rest/README.md
+++ b/examples/providers/rest/README.md
@@ -5,12 +5,12 @@ To deploy copy target/hello-rest-example.jar to providers directory. Alternative
$KEYCLOAK_HOME/bin/jboss-cli.sh --command="module add --name=org.keycloak.examples.hello-rest-example --resources=target/hello-rest-example.jar --dependencies=org.keycloak.keycloak-core,org.keycloak.keycloak-server-spi,javax.ws.rs.api"
-Then registering the provider by editing keycloak-server.json and adding the module to the providers field:
+Then registering the provider by editing `standalone/configuration/standalone.xml` and adding the module to the providers element:
- "providers": [
- ....
- "module:org.keycloak.examples.hello-rest-example"
- ],
+
+ ...
+ module:org.keycloak.examples.hello-rest-example
+
Then start (or restart) the server. Once started open http://localhost:8080/realms/master/hello and you should see the message _Hello master_.
You can also invoke the endpoint for other realms by replacing `master` with the realm name in the above url.
\ No newline at end of file
diff --git a/examples/themes/README.md b/examples/themes/README.md
index ea160bc650..5089ca1e7f 100644
--- a/examples/themes/README.md
+++ b/examples/themes/README.md
@@ -17,14 +17,14 @@ Alternatively you can deploy as modules. This can be done by first running:
mvn clean install
$KEYCLOAK_HOME/bin/jboss-cli.sh --command="module add --name=org.keycloak.example.themes --resources=target/keycloak-example-themes.jar"
-Then open $KEYCLOAK_HOME/standalone/configuration/keycloak-server.json and register the theme module by adding:
-
- "theme": {
- "module": {
- "modules": [ "org.keycloak.example.themes" ]
- }
- }
+Then open `standalone/configuration/standalone.xml` and register the theme module by adding:
+
+ ...
+
+ org.keycloak.example.themes
+
+
Address Theme
-------------------
@@ -45,11 +45,11 @@ Change Logo Theme
To enable the theme open the admin console, select your realm, click on `Theme`. In the dropdowns for `Login Theme`, `Account Theme` and `Admin Console Theme` select `logo-example`. Click `Save` and login to the realm to see the new theme in action.
-To change the theme for the welcome pages open `standalone/configuration/keycloak-server.json` find the config for `theme` and add 'welcomeTheme':
+To change the theme for the welcome pages open `standalone/configuration/standalone.xml` find the config for `theme` and add 'welcomeTheme':
- "theme": {
+
...
- "welcomeTheme": "logo-example"
- },
+ logo-example
+
One thing to note is that to change the admin console for the master admin console (`/auth/admin`) you need to change the theme for the master realm. Changing the admin console theme for any other realms will only change the admin console for that specific realm (for example `/auth/admin/myrealm/console`).
diff --git a/federation/ldap/pom.xml b/federation/ldap/pom.xml
index f6a8c4bae1..257c617af0 100755
--- a/federation/ldap/pom.xml
+++ b/federation/ldap/pom.xml
@@ -74,6 +74,11 @@
junittest
+
+ org.jboss.spec.javax.transaction
+ jboss-transaction-api_1.2_spec
+ provided
+
diff --git a/federation/pom.xml b/federation/pom.xml
index 663f857a0b..dc702ccfab 100755
--- a/federation/pom.xml
+++ b/federation/pom.xml
@@ -35,6 +35,7 @@
ldapkerberos
+ sssd
diff --git a/federation/sssd/pom.xml b/federation/sssd/pom.xml
new file mode 100644
index 0000000000..d3e3afbb65
--- /dev/null
+++ b/federation/sssd/pom.xml
@@ -0,0 +1,70 @@
+
+
+
+ keycloak-parent
+ org.keycloak
+ 2.2.0-SNAPSHOT
+ ../../pom.xml
+
+ 4.0.0
+
+ keycloak-sssd-federation
+ Keycloak SSSD Federation
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ ${maven.compiler.target}
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.3
+
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+
+
+ junit
+ junit
+ test
+
+
+ net.java.dev.jna
+ jna
+
+
+ org.keycloak
+ keycloak-core
+ provided
+
+
+ org.keycloak
+ keycloak-server-spi
+ provided
+
+
+ org.jboss.logging
+ jboss-logging
+ provided
+
+
+
+
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/LibraryLoader.java b/federation/sssd/src/main/java/cx/ath/matthew/LibraryLoader.java
new file mode 100644
index 0000000000..4088d46ebb
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/LibraryLoader.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016 Red Hat, Inc. and/or its affiliates
+ * and other contributors as indicated by the @author tags.
+ *
+ * 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 cx.ath.matthew;
+
+/**
+ * @author Bruno Oliveira.
+ */
+public class LibraryLoader {
+
+ private static final String[] PATHS = {"/usr/lib/", "/usr/lib64/", "/usr/local/lib/", "/opt/local/lib/"};
+ private static final String LIBRARY_NAME = "libunix_dbus_java";
+ private static final String VERSION = "0.0.8";
+ private static boolean loadSucceeded;
+
+ public static LibraryLoader load() {
+ for (String path : PATHS) {
+ try {
+ System.load(String.format("%s/%s.so.%s", path, LIBRARY_NAME, VERSION));
+ loadSucceeded = true;
+ break;
+ } catch (UnsatisfiedLinkError e) {
+ loadSucceeded = false;
+ }
+ }
+
+ return new LibraryLoader();
+ }
+
+ public boolean succeed() {
+ return loadSucceeded;
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/debug/Debug.java b/federation/sssd/src/main/java/cx/ath/matthew/debug/Debug.java
new file mode 100644
index 0000000000..30c4d8549d
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/debug/Debug.java
@@ -0,0 +1,671 @@
+/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ . */
+/* This header is separate from features.h so that the compiler can
+ include it implicitly at the start of every compilation. It must
+ not itself include or any other header that includes
+ because the implicit include comes before any feature
+ test macros that may be defined in a source file before it first
+ explicitly includes a system header. GCC knows the name of this
+ header in order to preinclude it. */
+/* glibc's intent is to support the IEC 559 math functionality, real
+ and complex. If the GCC (4.9 and later) predefined macros
+ specifying compiler intent are available, use them to determine
+ whether the overall intent is to support these features; otherwise,
+ presume an older compiler has intent to support these features and
+ define these macros by default. */
+/* wchar_t uses Unicode 7.0.0. Version 7.0 of the Unicode Standard is
+ synchronized with ISO/IEC 10646:2012, plus Amendments 1 (published
+ on April, 2013) and 2 (not yet published as of February, 2015).
+ Additionally, it includes the accelerated publication of U+20BD
+ RUBLE SIGN. Therefore Unicode 7.0.0 is between 10646:2012 and
+ 10646:2014, and so we use the date ISO/IEC 10646:2012 Amd.1 was
+ published. */
+/* We do not support C11 . */
+/*
+ * Java Debug Library
+ *
+ * Copyright (c) Matthew Johnson 2005
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+package cx.ath.matthew.debug;
+
+import cx.ath.matthew.utils.Hexdump;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Add debugging to your program, has support for large projects with multiple
+ * classes and debug levels per class. Supports optional enabling of debug
+ * per-level per-class and debug targets of files, Streams or stderr.
+ * Also supports timing between debug outputs, printing of stack traces for Throwables
+ * and files/line numbers on each message.
+ *
+ * Debug now automatically figures out which class it was called from, so all
+ * methods passing in the calling class are deprecated.
+ *
+ *
+ * The defaults are to print all messages to stderr with class and method name.
+ *
+ *
+ * Should be called like this:
+ *
+ *
+ * if (Debug.debug) Debug.print(Debug.INFO, "Debug Message");
+ *
+ */
+public class Debug {
+ /**
+ * This interface can be used to provide custom printing filters
+ * for certain classes.
+ */
+ public static interface FilterCommand {
+ /**
+ * Called to print debug messages with a custom filter.
+ *
+ * @param output The PrintStream to output to.
+ * @param level The debug level of this message.
+ * @param location The textual location of the message.
+ * @param extra Extra information such as timing details.
+ * @param message The debug message.
+ * @param lines Other lines of a multiple-line debug message.
+ */
+ public void filter(PrintStream output, int level, String location, String extra, String message, String[] lines);
+ }
+
+ /**
+ * Highest priority messages
+ */
+ public static final int CRIT = 1;
+ /**
+ * Error messages
+ */
+ public static final int ERR = 2;
+ /**
+ * Warnings
+ */
+ public static final int WARN = 3;
+ /**
+ * Information
+ */
+ public static final int INFO = 4;
+ /**
+ * Debug messages
+ */
+ public static final int DEBUG = 5;
+ /**
+ * Verbose debug messages
+ */
+ public static final int VERBOSE = 6;
+ /**
+ * Set this to false to disable compilation of Debug statements
+ */
+ public static final boolean debug = false;
+ /**
+ * The current output stream (defaults to System.err)
+ */
+ public static PrintStream debugout = System.err;
+ private static Properties prop = null;
+ private static boolean timing = false;
+ private static boolean ttrace = false;
+ private static boolean lines = false;
+ private static boolean hexdump = false;
+ private static long last = 0;
+ private static int balen = 36;
+ private static int bawidth = 80;
+ private static Class saveclass = null;
+ //TODO: 1.5 private static Map, FilterCommand> filterMap = new HashMap, FilterCommand>();
+ private static Map filterMap = new HashMap();
+
+ /**
+ * Set properties to configure debugging.
+ * Format of properties is class => level, e.g.
+ *
+ * The debug level can be one of CRIT, ERR, WARN, INFO, DEBUG or VERBOSE which
+ * correspond to all messages up to that level. The special words YES, ALL and TRUE
+ * cause all messages to be printed regardless of level. All other terms disable
+ * messages for that class. CRIT and ERR messages are always printed if debugging is enabled
+ * unless explicitly disabled.
+ * The special class name ALL can be used to set the default level for all classes.
+ *
+ * @param prop Properties object to use.
+ */
+ public static void setProperties(Properties prop) {
+ Debug.prop = prop;
+ }
+
+ /**
+ * Read which class to debug on at which level from the given File.
+ * Syntax the same as Java Properties files:
+ *
+ * The debug level can be one of CRIT, ERR, WARN, INFO, DEBUG or VERBOSE which
+ * correspond to all messages up to that level. The special words YES, ALL and TRUE
+ * cause all messages to be printed regardless of level. All other terms disable
+ * messages for that class. CRIT and ERR messages are always printed if debugging is enabled
+ * unless explicitly disabled.
+ * The special class name ALL can be used to set the default level for all classes.
+ *
+ * @param f File to read from.
+ */
+ public static void loadConfig(File f) throws IOException {
+ prop = new Properties();
+ prop.load(new FileInputStream(f));
+ }
+
+ /**
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static boolean debugging(Class c, int loglevel) {
+ if (debug) {
+ if (null == c) return true;
+ return debugging(c.getName(), loglevel);
+ }
+ return false;
+ }
+
+ public static boolean debugging(String s, int loglevel) {
+ if (debug) {
+ try {
+ if (null == s) return true;
+ if (null == prop) return loglevel <= DEBUG;
+ String d = prop.getProperty(s);
+ if (null == d || "".equals(d)) d = prop.getProperty("ALL");
+ if (null == d) return loglevel <= ERR;
+ if ("".equals(d)) return loglevel <= ERR;
+ d = d.toLowerCase();
+ if ("true".equals(d)) return true;
+ if ("yes".equals(d)) return true;
+ if ("all".equals(d)) return true;
+ if ("verbose".equals(d)) return loglevel <= VERBOSE;
+ if ("debug".equals(d)) return loglevel <= DEBUG;
+ if ("info".equals(d)) return loglevel <= INFO;
+ if ("warn".equals(d)) return loglevel <= WARN;
+ if ("err".equals(d)) return loglevel <= ERR;
+ if ("crit".equals(d)) return loglevel <= CRIT;
+ int i = Integer.parseInt(d);
+ return i >= loglevel;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Output to the given Stream
+ */
+ public static void setOutput(PrintStream p) throws IOException {
+ debugout = p;
+ }
+
+ /**
+ * Output to the given file
+ */
+ public static void setOutput(String filename) throws IOException {
+ debugout = new PrintStream(new FileOutputStream(filename, true));
+ }
+
+ /**
+ * Output to the default debug.log
+ */
+ public static void setOutput() throws IOException {
+ setOutput("./debug.log");
+ }
+
+ /**
+ * Log at DEBUG
+ *
+ * @param d The object to log
+ */
+ public static void print(Object d) {
+ if (debug) {
+ if (d instanceof String)
+ print(DEBUG, (String) d);
+ else if (d instanceof Throwable)
+ print(DEBUG, (Throwable) d);
+ else if (d instanceof byte[])
+ print(DEBUG, (byte[]) d);
+ else if (d instanceof Map)
+ printMap(DEBUG, (Map) d);
+ else print(DEBUG, d);
+ }
+ }
+
+ /**
+ * Log at DEBUG
+ *
+ * @param o The object doing the logging
+ * @param d The object to log
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void print(Object o, Object d) {
+ if (debug) {
+ if (o instanceof Class)
+ saveclass = (Class) o;
+ else
+ saveclass = o.getClass();
+ print(d);
+ }
+ }
+
+ /**
+ * Log an Object
+ *
+ * @param o The object doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param d The object to log with d.toString()
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void print(Object o, int loglevel, Object d) {
+ if (debug) {
+ if (o instanceof Class)
+ saveclass = (Class) o;
+ else
+ saveclass = o.getClass();
+ print(loglevel, d);
+ }
+ }
+
+ /**
+ * Log a String
+ *
+ * @param o The object doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param s The log message
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void print(Object o, int loglevel, String s) {
+ if (debug) {
+ if (o instanceof Class)
+ saveclass = (Class) o;
+ else
+ saveclass = o.getClass();
+ print(loglevel, s);
+ }
+ }
+
+ /**
+ * Log a Throwable
+ *
+ * @param o The object doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param t The throwable to log with .toString and .printStackTrace
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void print(Object o, int loglevel, Throwable t) {
+ if (debug) {
+ if (o instanceof Class)
+ saveclass = (Class) o;
+ else
+ saveclass = o.getClass();
+ print(loglevel, t);
+ }
+ }
+
+ /**
+ * Log a Throwable
+ *
+ * @param c The class doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param t The throwable to log with .toString and .printStackTrace
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void print(Class c, int loglevel, Throwable t) {
+ if (debug) {
+ saveclass = c;
+ print(loglevel, t);
+ }
+ }
+
+ /**
+ * Log a Throwable
+ *
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param t The throwable to log with .toString and .printStackTrace
+ * @see #setThrowableTraces to turn on stack traces.
+ */
+ public static void print(int loglevel, Throwable t) {
+ if (debug) {
+ String timestr = "";
+ String[] data = getTraceElements();
+ if (debugging(data[0], loglevel)) {
+ if (timing) {
+ long now = System.currentTimeMillis();
+ timestr = "{" + (now - last) + "} ";
+ last = now;
+ }
+ String[] lines = null;
+ if (ttrace) {
+ StackTraceElement[] ste = t.getStackTrace();
+ lines = new String[ste.length];
+ for (int i = 0; i < ste.length; i++)
+ lines[i] = "\tat " + ste[i].toString();
+ }
+ _print(t.getClass(), loglevel, data[0] + "." + data[1] + "()" + data[2], timestr, t.toString(), lines);
+ }
+ }
+ }
+
+ /**
+ * Log a byte array
+ *
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param b The byte array to print.
+ * @see #setHexDump to enable hex dumping.
+ * @see #setByteArrayCount to change how many bytes are printed.
+ * @see #setByteArrayWidth to change the formatting width of hex.
+ */
+ public static void print(int loglevel, byte[] b) {
+ if (debug) {
+ String timestr = "";
+ String[] data = getTraceElements();
+ if (debugging(data[0], loglevel)) {
+ if (timing) {
+ long now = System.currentTimeMillis();
+ timestr = "{" + (now - last) + "} ";
+ last = now;
+ }
+ String[] lines = null;
+ if (hexdump) {
+ if (balen >= b.length)
+ lines = Hexdump.format(b, bawidth).split("\n");
+ else {
+ byte[] buf = new byte[balen];
+ System.arraycopy(b, 0, buf, 0, balen);
+ lines = Hexdump.format(buf, bawidth).split("\n");
+ }
+ }
+ _print(b.getClass(), loglevel, data[0] + "." + data[1] + "()" + data[2], timestr, b.length + " bytes", lines);
+ }
+ }
+ }
+
+ /**
+ * Log a String
+ *
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param s The string to log with d.toString()
+ */
+ public static void print(int loglevel, String s) {
+ if (debug)
+ print(loglevel, (Object) s);
+ }
+
+ /**
+ * Log an Object
+ *
+ * @param c The class doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param d The object to log with d.toString()
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void print(Class c, int loglevel, Object d) {
+ if (debug) {
+ saveclass = c;
+ print(loglevel, d);
+ }
+ }
+
+ /**
+ * Log a String
+ *
+ * @param c The class doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param s The log message
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void print(Class c, int loglevel, String s) {
+ if (debug) {
+ saveclass = c;
+ print(loglevel, s);
+ }
+ }
+
+ private static String[] getTraceElements() {
+ String[] data = new String[]{"", "", ""};
+ try {
+ Method m = Thread.class.getMethod("getStackTrace", new Class[0]);
+ StackTraceElement[] stes = (StackTraceElement[]) m.invoke(Thread.currentThread(), new Object[0]);
+ for (StackTraceElement ste : stes) {
+ if (Debug.class.getName().equals(ste.getClassName())) continue;
+ if (Thread.class.getName().equals(ste.getClassName())) continue;
+ if (Method.class.getName().equals(ste.getClassName())) continue;
+ if (ste.getClassName().startsWith("sun.reflect")) continue;
+ data[0] = ste.getClassName();
+ data[1] = ste.getMethodName();
+ if (lines)
+ data[2] = " " + ste.getFileName() + ":" + ste.getLineNumber();
+ break;
+ }
+ } catch (NoSuchMethodException NSMe) {
+ if (null != saveclass)
+ data[0] = saveclass.getName();
+ } catch (IllegalAccessException IAe) {
+ } catch (InvocationTargetException ITe) {
+ }
+ return data;
+ }
+
+ /**
+ * Log an Object
+ *
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param o The object to log
+ */
+ public static void print(int loglevel, Object o) {
+ if (debug) {
+ String timestr = "";
+ String[] data = getTraceElements();
+ if (debugging(data[0], loglevel)) {
+ if (timing) {
+ long now = System.currentTimeMillis();
+ timestr = "{" + (now - last) + "} ";
+ last = now;
+ }
+ _print(o.getClass(), loglevel, data[0] + "." + data[1] + "()" + data[2], timestr, o.toString(), null);
+ }
+ }
+ }
+
+ /**
+ * Log a Map
+ *
+ * @param o The object doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param m The Map to print out
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void printMap(Object o, int loglevel, Map m) {
+ if (debug) {
+ if (o instanceof Class)
+ saveclass = (Class) o;
+ else
+ saveclass = o.getClass();
+ printMap(loglevel, m);
+ }
+ }
+
+ /**
+ * Log a Map
+ *
+ * @param c The class doing the logging
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param m The Map to print out
+ * @deprecated In Java 1.5 calling class is automatically identified, no need to pass it in.
+ */
+ //TODO: 1.5 @Deprecated()
+ public static void printMap(Class c, int loglevel, Map m) {
+ if (debug) {
+ saveclass = c;
+ printMap(loglevel, m);
+ }
+ }
+
+ /**
+ * Log a Map at DEBUG log level
+ *
+ * @param m The Map to print out
+ */
+ public static void printMap(Map m) {
+ printMap(DEBUG, m);
+ }
+
+ /**
+ * Log a Map
+ *
+ * @param loglevel The level to log at (DEBUG, WARN, etc)
+ * @param m The Map to print out
+ */
+ public static void printMap(int loglevel, Map m) {
+ if (debug) {
+ String timestr = "";
+ String[] data = getTraceElements();
+ if (debugging(data[0], loglevel)) {
+ if (timing) {
+ long now = System.currentTimeMillis();
+ timestr = "{" + (now - last) + "} ";
+ last = now;
+ }
+ Iterator i = m.keySet().iterator();
+ String[] lines = new String[m.size()];
+ int j = 0;
+ while (i.hasNext()) {
+ Object key = i.next();
+ lines[j++] = "\t\t- " + key + " => " + m.get(key);
+ }
+ _print(m.getClass(), loglevel, data[0] + "." + data[1] + "()" + data[2], timestr, "Map:", lines);
+ }
+ }
+ }
+
+ /**
+ * Enable or disable stack traces in Debuging throwables.
+ */
+ public static void setThrowableTraces(boolean ttrace) {
+ Debug.ttrace = ttrace;
+ }
+
+ /**
+ * Enable or disable timing in Debug messages.
+ */
+ public static void setTiming(boolean timing) {
+ Debug.timing = timing;
+ }
+
+ /**
+ * Enable or disable line numbers.
+ */
+ public static void setLineNos(boolean lines) {
+ Debug.lines = lines;
+ }
+
+ /**
+ * Enable or disable hexdumps.
+ */
+ public static void setHexDump(boolean hexdump) {
+ Debug.hexdump = hexdump;
+ }
+
+ /**
+ * Set the size of hexdumps.
+ * (Default: 36)
+ */
+ public static void setByteArrayCount(int count) {
+ Debug.balen = count;
+ }
+
+ /**
+ * Set the formatted width of hexdumps.
+ * (Default: 80 chars)
+ */
+ public static void setByteArrayWidth(int width) {
+ Debug.bawidth = width;
+ }
+
+ /**
+ * Add a filter command for a specific type.
+ * This command will be called with the output stream
+ * and the text to be sent. It should perform any
+ * changes necessary to the text and then print the
+ * result to the output stream.
+ */
+ public static void addFilterCommand(Class c, FilterCommand f)
+ //TODO 1.5: public static void addFilterCommand(Class extends Object> c, FilterCommand f)
+ {
+ filterMap.put(c, f);
+ }
+
+ private static void _print(Class c, int level, String loc, String extra, String message, String[] lines) {
+ //TODO 1.5: FilterCommand f = filterMap.get(c);
+ FilterCommand f = (FilterCommand) filterMap.get(c);
+ if (null == f) {
+ debugout.println("[" + loc + "] " + extra + message);
+ if (null != lines)
+ for (String s : lines)
+ debugout.println(s);
+ } else
+ f.filter(debugout, level, loc, extra, message, lines);
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/unix/NotConnectedException.java b/federation/sssd/src/main/java/cx/ath/matthew/unix/NotConnectedException.java
new file mode 100644
index 0000000000..836f5d6229
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/unix/NotConnectedException.java
@@ -0,0 +1,35 @@
+/*
+ * Java Unix Sockets Library
+ *
+ * Copyright (c) Matthew Johnson 2004
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+package cx.ath.matthew.unix;
+
+import java.net.SocketException;
+
+public class NotConnectedException extends SocketException {
+ public NotConnectedException() {
+ super("The Socket is Not Connected");
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/unix/USInputStream.java b/federation/sssd/src/main/java/cx/ath/matthew/unix/USInputStream.java
new file mode 100644
index 0000000000..eb143fe6a9
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/unix/USInputStream.java
@@ -0,0 +1,94 @@
+/*
+ * Java Unix Sockets Library
+ *
+ * Copyright (c) Matthew Johnson 2004
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+package cx.ath.matthew.unix;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class USInputStream extends InputStream {
+ public static final int MSG_DONTWAIT = 0x40;
+
+ private native int native_recv(int sock, byte[] b, int off, int len, int flags, int timeout) throws IOException;
+
+ private int sock;
+ boolean closed = false;
+ private byte[] onebuf = new byte[1];
+ private UnixSocket us;
+ private boolean blocking = true;
+ private int flags = 0;
+ private int timeout = 0;
+
+ public USInputStream(int sock, UnixSocket us) {
+ this.sock = sock;
+ this.us = us;
+ }
+
+ public void close() throws IOException {
+ closed = true;
+ us.close();
+ }
+
+ public boolean markSupported() {
+ return false;
+ }
+
+ public int read() throws IOException {
+ int rv = 0;
+ while (0 >= rv) rv = read(onebuf);
+ if (-1 == rv) return -1;
+ return 0 > onebuf[0] ? -onebuf[0] : onebuf[0];
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (closed) throw new NotConnectedException();
+ int count = native_recv(sock, b, off, len, flags, timeout);
+ /* Yes, I really want to do this. Recv returns 0 for 'connection shut down'.
+ * read() returns -1 for 'end of stream.
+ * Recv returns -1 for 'EAGAIN' (all other errors cause an exception to be raised)
+ * whereas read() returns 0 for '0 bytes read', so yes, I really want to swap them here.
+ */
+ if (0 == count) return -1;
+ else if (-1 == count) return 0;
+ else return count;
+ }
+
+ public boolean isClosed() {
+ return closed;
+ }
+
+ public UnixSocket getSocket() {
+ return us;
+ }
+
+ public void setBlocking(boolean enable) {
+ flags = enable ? 0 : MSG_DONTWAIT;
+ }
+
+ public void setSoTimeout(int timeout) {
+ this.timeout = timeout;
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/unix/USOutputStream.java b/federation/sssd/src/main/java/cx/ath/matthew/unix/USOutputStream.java
new file mode 100644
index 0000000000..d8c85a7718
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/unix/USOutputStream.java
@@ -0,0 +1,78 @@
+/*
+ * Java Unix Sockets Library
+ *
+ * Copyright (c) Matthew Johnson 2004
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+package cx.ath.matthew.unix;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class USOutputStream extends OutputStream {
+ private native int native_send(int sock, byte[] b, int off, int len) throws IOException;
+
+ private native int native_send(int sock, byte[][] b) throws IOException;
+
+ private int sock;
+ boolean closed = false;
+ private byte[] onebuf = new byte[1];
+ private UnixSocket us;
+
+ public USOutputStream(int sock, UnixSocket us) {
+ this.sock = sock;
+ this.us = us;
+ }
+
+ public void close() throws IOException {
+ closed = true;
+ us.close();
+ }
+
+ public void flush() {
+ } // no-op, we do not buffer
+
+ public void write(byte[][] b) throws IOException {
+ if (closed) throw new NotConnectedException();
+ native_send(sock, b);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (closed) throw new NotConnectedException();
+ native_send(sock, b, off, len);
+ }
+
+ public void write(int b) throws IOException {
+ onebuf[0] = (byte) (b % 0x7F);
+ if (1 == (b % 0x80)) onebuf[0] = (byte) -onebuf[0];
+ write(onebuf);
+ }
+
+ public boolean isClosed() {
+ return closed;
+ }
+
+ public UnixSocket getSocket() {
+ return us;
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixIOException.java b/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixIOException.java
new file mode 100644
index 0000000000..24fd20cd1f
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixIOException.java
@@ -0,0 +1,43 @@
+/*
+ * Java Unix Sockets Library
+ *
+ * Copyright (c) Matthew Johnson 2004
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+package cx.ath.matthew.unix;
+
+import java.io.IOException;
+
+/**
+ * An IO Exception which occurred during UNIX Socket IO
+ */
+public class UnixIOException extends IOException {
+ private int no;
+ private String message;
+
+ public UnixIOException(int no, String message) {
+ super(message);
+ this.message = message;
+ this.no = no;
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixSocket.java b/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixSocket.java
new file mode 100644
index 0000000000..8851637436
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixSocket.java
@@ -0,0 +1,350 @@
+/*
+ * Java Unix Sockets Library
+ *
+ * Copyright (c) Matthew Johnson 2004
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+package cx.ath.matthew.unix;
+
+import cx.ath.matthew.LibraryLoader;
+import cx.ath.matthew.debug.Debug;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Represents a UnixSocket.
+ */
+public class UnixSocket {
+ static {
+ LibraryLoader.load();
+ }
+
+ private native void native_set_pass_cred(int sock, boolean passcred) throws IOException;
+
+ private native int native_connect(String address, boolean abs) throws IOException;
+
+ private native void native_close(int sock) throws IOException;
+
+ private native int native_getPID(int sock);
+
+ private native int native_getUID(int sock);
+
+ private native int native_getGID(int sock);
+
+ private native void native_send_creds(int sock, byte data) throws IOException;
+
+ private native byte native_recv_creds(int sock, int[] creds) throws IOException;
+
+ private UnixSocketAddress address = null;
+ private USOutputStream os = null;
+ private USInputStream is = null;
+ private boolean closed = false;
+ private boolean connected = false;
+ private boolean passcred = false;
+ private int sock = 0;
+ private boolean blocking = true;
+ private int uid = -1;
+ private int pid = -1;
+ private int gid = -1;
+
+ UnixSocket(int sock, UnixSocketAddress address) {
+ this.sock = sock;
+ this.address = address;
+ this.connected = true;
+ this.os = new USOutputStream(sock, this);
+ this.is = new USInputStream(sock, this);
+ }
+
+ /**
+ * Create an unconnected socket.
+ */
+ public UnixSocket() {
+ }
+
+ /**
+ * Create a socket connected to the given address.
+ *
+ * @param address The Unix Socket address to connect to
+ */
+ public UnixSocket(UnixSocketAddress address) throws IOException {
+ connect(address);
+ }
+
+ /**
+ * Create a socket connected to the given address.
+ *
+ * @param address The Unix Socket address to connect to
+ */
+ public UnixSocket(String address) throws IOException {
+ this(new UnixSocketAddress(address));
+ }
+
+ /**
+ * Connect the socket to this address.
+ *
+ * @param address The Unix Socket address to connect to
+ */
+ public void connect(UnixSocketAddress address) throws IOException {
+ if (connected) close();
+ this.sock = native_connect(address.path, address.abs);
+ this.os = new USOutputStream(this.sock, this);
+ this.is = new USInputStream(this.sock, this);
+ this.address = address;
+ this.connected = true;
+ this.closed = false;
+ this.is.setBlocking(blocking);
+ }
+
+ /**
+ * Connect the socket to this address.
+ *
+ * @param address The Unix Socket address to connect to
+ */
+ public void connect(String address) throws IOException {
+ connect(new UnixSocketAddress(address));
+ }
+
+ public void finalize() {
+ try {
+ close();
+ } catch (IOException IOe) {
+ }
+ }
+
+ /**
+ * Closes the connection.
+ */
+ public synchronized void close() throws IOException {
+ if (Debug.debug) Debug.print(Debug.INFO, "Closing socket");
+ native_close(sock);
+ sock = 0;
+ this.closed = true;
+ this.connected = false;
+ os = null;
+ is = null;
+ }
+
+ /**
+ * Returns an InputStream for reading from the socket.
+ *
+ * @return An InputStream connected to this socket.
+ */
+ public InputStream getInputStream() {
+ return is;
+ }
+
+ /**
+ * Returns an OutputStream for writing to the socket.
+ *
+ * @return An OutputStream connected to this socket.
+ */
+ public OutputStream getOutputStream() {
+ return os;
+ }
+
+ /**
+ * Returns the address this socket is connected to.
+ * Returns null if the socket is unconnected.
+ *
+ * @return The UnixSocketAddress the socket is connected to
+ */
+ public UnixSocketAddress getAddress() {
+ return address;
+ }
+
+ /**
+ * Send a single byte of data with credentials.
+ * (Works on BSDs)
+ *
+ * @param data The byte of data to send.
+ */
+ public void sendCredentialByte(byte data) throws IOException {
+ if (!connected) throw new NotConnectedException();
+ native_send_creds(sock, data);
+ }
+
+ /**
+ * Receive a single byte of data, with credentials.
+ * (Works on BSDs)
+ *
+ * @param data The byte of data to send.
+ * @see getPeerUID
+ * @see getPeerPID
+ * @see getPeerGID
+ */
+ public byte recvCredentialByte() throws IOException {
+ if (!connected) throw new NotConnectedException();
+ int[] creds = new int[]{-1, -1, -1};
+ byte data = native_recv_creds(sock, creds);
+ pid = creds[0];
+ uid = creds[1];
+ gid = creds[2];
+ return data;
+ }
+
+ /**
+ * Get the credential passing status.
+ * (only effective on linux)
+ *
+ * @return The current status of credential passing.
+ * @see setPassCred
+ */
+ public boolean getPassCred() {
+ return passcred;
+ }
+
+ /**
+ * Return the uid of the remote process.
+ * Some data must have been received on the socket to do this.
+ * Either setPassCred must be called on Linux first, or recvCredentialByte
+ * on BSD.
+ *
+ * @return the UID or -1 if it is not available
+ */
+ public int getPeerUID() {
+ if (-1 == uid)
+ uid = native_getUID(sock);
+ return uid;
+ }
+
+ /**
+ * Return the gid of the remote process.
+ * Some data must have been received on the socket to do this.
+ * Either setPassCred must be called on Linux first, or recvCredentialByte
+ * on BSD.
+ *
+ * @return the GID or -1 if it is not available
+ */
+ public int getPeerGID() {
+ if (-1 == gid)
+ gid = native_getGID(sock);
+ return gid;
+ }
+
+ /**
+ * Return the pid of the remote process.
+ * Some data must have been received on the socket to do this.
+ * Either setPassCred must be called on Linux first, or recvCredentialByte
+ * on BSD.
+ *
+ * @return the PID or -1 if it is not available
+ */
+ public int getPeerPID() {
+ if (-1 == pid)
+ pid = native_getPID(sock);
+ return pid;
+ }
+
+ /**
+ * Set the credential passing status.
+ * (Only does anything on linux, for other OS, you need
+ * to use send/recv credentials)
+ *
+ * @param enable Set to true for credentials to be passed.
+ */
+ public void setPassCred(boolean enable) throws IOException {
+ native_set_pass_cred(sock, enable);
+ passcred = enable;
+ }
+
+ /**
+ * Get the blocking mode.
+ *
+ * @return true if reads are blocking.
+ * @see setBlocking
+ */
+ public boolean getBlocking() {
+ return blocking;
+ }
+
+ /**
+ * Set the blocking mode.
+ *
+ * @param enable Set to false for non-blocking reads.
+ */
+ public void setBlocking(boolean enable) {
+ blocking = enable;
+ if (null != is) is.setBlocking(enable);
+ }
+
+ /**
+ * Check the socket status.
+ *
+ * @return true if closed.
+ */
+ public boolean isClosed() {
+ return closed;
+ }
+
+ /**
+ * Check the socket status.
+ *
+ * @return true if connected.
+ */
+ public boolean isConnected() {
+ return connected;
+ }
+
+ /**
+ * Check the socket status.
+ *
+ * @return true if the input stream has been shutdown
+ */
+ public boolean isInputShutdown() {
+ return is.isClosed();
+ }
+
+ /**
+ * Check the socket status.
+ *
+ * @return true if the output stream has been shutdown
+ */
+ public boolean isOutputShutdown() {
+ return os.isClosed();
+ }
+
+ /**
+ * Shuts down the input stream.
+ * Subsequent reads on the associated InputStream will fail.
+ */
+ public void shutdownInput() {
+ is.closed = true;
+ }
+
+ /**
+ * Shuts down the output stream.
+ * Subsequent writes to the associated OutputStream will fail.
+ */
+ public void shutdownOutput() {
+ os.closed = true;
+ }
+
+ /**
+ * Set timeout of read requests.
+ */
+ public void setSoTimeout(int timeout) {
+ is.setSoTimeout(timeout);
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixSocketAddress.java b/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixSocketAddress.java
new file mode 100644
index 0000000000..0baba479bb
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/unix/UnixSocketAddress.java
@@ -0,0 +1,86 @@
+/*
+ * Java Unix Sockets Library
+ *
+ * Copyright (c) Matthew Johnson 2004
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+package cx.ath.matthew.unix;
+
+/**
+ * Represents an address for a Unix Socket
+ */
+public class UnixSocketAddress {
+ String path;
+ boolean abs;
+
+ /**
+ * Create the address.
+ *
+ * @param path The path to the Unix Socket.
+ * @param abs True if this should be an abstract socket.
+ */
+ public UnixSocketAddress(String path, boolean abs) {
+ this.path = path;
+ this.abs = abs;
+ }
+
+ /**
+ * Create the address.
+ *
+ * @param path The path to the Unix Socket.
+ */
+ public UnixSocketAddress(String path) {
+ this.path = path;
+ this.abs = false;
+ }
+
+ /**
+ * Return the path.
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Returns true if this an address for an abstract socket.
+ */
+ public boolean isAbstract() {
+ return abs;
+ }
+
+ /**
+ * Return the Address as a String.
+ */
+ public String toString() {
+ return "unix" + (abs ? ":abstract" : "") + ":path=" + path;
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof UnixSocketAddress)) return false;
+ return ((UnixSocketAddress) o).path.equals(this.path);
+ }
+
+ public int hashCode() {
+ return path.hashCode();
+ }
+}
diff --git a/federation/sssd/src/main/java/cx/ath/matthew/utils/Hexdump.java b/federation/sssd/src/main/java/cx/ath/matthew/utils/Hexdump.java
new file mode 100644
index 0000000000..63f37194db
--- /dev/null
+++ b/federation/sssd/src/main/java/cx/ath/matthew/utils/Hexdump.java
@@ -0,0 +1,147 @@
+/*
+ * Java Hexdump Library
+ *
+ * Copyright (c) Matthew Johnson 2005
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * To Contact the author, please email src@matthew.ath.cx
+ *
+ */
+
+package cx.ath.matthew.utils;
+
+import java.io.PrintStream;
+
+public class Hexdump {
+ public static final char[] hexchars = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+ public static String toHex(byte[] buf) {
+ return toHex(buf, 0, buf.length);
+ }
+
+ public static String toHex(byte[] buf, int ofs, int len) {
+ StringBuffer sb = new StringBuffer();
+ int j = ofs + len;
+ for (int i = ofs; i < j; i++) {
+ if (i < buf.length) {
+ sb.append(hexchars[(buf[i] & 0xF0) >> 4]);
+ sb.append(hexchars[buf[i] & 0x0F]);
+ sb.append(' ');
+ } else {
+ sb.append(' ');
+ sb.append(' ');
+ sb.append(' ');
+ }
+ }
+ return sb.toString();
+ }
+
+ public static String toAscii(byte[] buf) {
+ return toAscii(buf, 0, buf.length);
+ }
+
+ public static String toAscii(byte[] buf, int ofs, int len) {
+ StringBuffer sb = new StringBuffer();
+ int j = ofs + len;
+ for (int i = ofs; i < j; i++) {
+ if (i < buf.length) {
+ if (20 <= buf[i] && 126 >= buf[i])
+ sb.append((char) buf[i]);
+ else
+ sb.append('.');
+ } else
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ public static String format(byte[] buf) {
+ return format(buf, 80);
+ }
+
+ public static String format(byte[] buf, int width) {
+ int bs = (width - 8) / 4;
+ int i = 0;
+ StringBuffer sb = new StringBuffer();
+ do {
+ for (int j = 0; j < 6; j++) {
+ sb.append(hexchars[(i << (j * 4) & 0xF00000) >> 20]);
+ }
+ sb.append('\t');
+ sb.append(toHex(buf, i, bs));
+ sb.append(' ');
+ sb.append(toAscii(buf, i, bs));
+ sb.append('\n');
+ i += bs;
+ } while (i < buf.length);
+ return sb.toString();
+ }
+
+ public static void print(byte[] buf) {
+ print(buf, System.err);
+ }
+
+ public static void print(byte[] buf, int width) {
+ print(buf, width, System.err);
+ }
+
+ public static void print(byte[] buf, int width, PrintStream out) {
+ out.print(format(buf, width));
+ }
+
+ public static void print(byte[] buf, PrintStream out) {
+ out.print(format(buf));
+ }
+
+ /**
+ * Returns a string which can be written to a Java source file as part
+ * of a static initializer for a byte array.
+ * Returns data in the format 0xAB, 0xCD, ....
+ * use like:
+ * javafile.print("byte[] data = {")
+ * javafile.print(Hexdump.toByteArray(data));
+ * javafile.println("};");
+ */
+ public static String toByteArray(byte[] buf) {
+ return toByteArray(buf, 0, buf.length);
+ }
+
+ /**
+ * Returns a string which can be written to a Java source file as part
+ * of a static initializer for a byte array.
+ * Returns data in the format 0xAB, 0xCD, ....
+ * use like:
+ * javafile.print("byte[] data = {")
+ * javafile.print(Hexdump.toByteArray(data));
+ * javafile.println("};");
+ */
+ public static String toByteArray(byte[] buf, int ofs, int len) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = ofs; i < len && i < buf.length; i++) {
+ sb.append('0');
+ sb.append('x');
+ sb.append(hexchars[(buf[i] & 0xF0) >> 4]);
+ sb.append(hexchars[buf[i] & 0x0F]);
+ if ((i + 1) < len && (i + 1) < buf.length)
+ sb.append(',');
+ }
+ return sb.toString();
+ }
+}
diff --git a/federation/sssd/src/main/java/org/freedesktop/DBus.java b/federation/sssd/src/main/java/org/freedesktop/DBus.java
new file mode 100644
index 0000000000..b7a16877ae
--- /dev/null
+++ b/federation/sssd/src/main/java/org/freedesktop/DBus.java
@@ -0,0 +1,534 @@
+/*
+ D-Bus Java Implementation
+ Copyright (c) 2005-2006 Matthew Johnson
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of either the GNU Lesser General Public License Version 2 or the
+ Academic Free Licence Version 2.1.
+
+ Full licence texts are included in the COPYING file with this program.
+*/
+package org.freedesktop;
+
+import org.freedesktop.dbus.DBusInterface;
+import org.freedesktop.dbus.DBusSignal;
+import org.freedesktop.dbus.Position;
+import org.freedesktop.dbus.Struct;
+import org.freedesktop.dbus.Tuple;
+import org.freedesktop.dbus.UInt16;
+import org.freedesktop.dbus.UInt32;
+import org.freedesktop.dbus.UInt64;
+import org.freedesktop.dbus.Variant;
+import org.freedesktop.dbus.exceptions.DBusException;
+import org.freedesktop.dbus.exceptions.DBusExecutionException;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.List;
+import java.util.Map;
+
+public interface DBus extends DBusInterface {
+
+ String BUSNAME = "org.freedesktop.DBus";
+ String OBJECTPATH = "/org/freedesktop/DBus";
+
+ int DBUS_NAME_FLAG_ALLOW_REPLACEMENT = 0x01;
+ int DBUS_NAME_FLAG_REPLACE_EXISTING = 0x02;
+ int DBUS_NAME_FLAG_DO_NOT_QUEUE = 0x04;
+ int DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 1;
+ int DBUS_REQUEST_NAME_REPLY_IN_QUEUE = 2;
+ int DBUS_REQUEST_NAME_REPLY_EXISTS = 3;
+ int DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER = 4;
+ int DBUS_RELEASEME_REPLY_RELEASED = 1;
+ int DBUS_RELEASE_NAME_REPLY_NON_EXISTANT = 2;
+ int DBUS_RELEASE_NAME_REPLY_NOT_OWNER = 3;
+ int DBUS_START_REPLY_SUCCESS = 1;
+ int DBUS_START_REPLY_ALREADY_RUNNING = 2;
+
+ /**
+ * All DBus Applications should respond to the Ping method on this interface
+ */
+ public interface Peer extends DBusInterface {
+ public void Ping();
+ }
+
+ /**
+ * Objects can provide introspection data via this interface and method.
+ * See the Introspection Format.
+ */
+ public interface Introspectable extends DBusInterface {
+ /**
+ * @return The XML introspection data for this object
+ */
+ public String Introspect();
+ }
+
+ /**
+ * A standard properties interface.
+ */
+ public interface Properties extends DBusInterface {
+ /**
+ * Get the value for the given property.
+ *
+ * @param interface_name The interface this property is associated with.
+ * @param property_name The name of the property.
+ * @return The value of the property (may be any valid DBus type).
+ */
+ public A Get(String interface_name, String property_name);
+
+ /**
+ * Set the value for the given property.
+ *
+ * @param interface_name The interface this property is associated with.
+ * @param property_name The name of the property.
+ * @param value The new value of the property (may be any valid DBus type).
+ */
+ public void Set(String interface_name, String property_name, A value);
+
+ /**
+ * Get all properties and values.
+ *
+ * @param interface_name The interface the properties is associated with.
+ * @return The properties mapped to their values.
+ */
+ public Map GetAll(String interface_name);
+ }
+
+ /**
+ * Messages generated locally in the application.
+ */
+ public interface Local extends DBusInterface {
+ public class Disconnected extends DBusSignal {
+ public Disconnected(String path) throws DBusException {
+ super(path);
+ }
+ }
+ }
+
+ /**
+ * Initial message to register ourselves on the Bus.
+ *
+ * @return The unique name of this connection to the Bus.
+ */
+ public String Hello();
+
+ /**
+ * Lists all connected names on the Bus.
+ *
+ * @return An array of all connected names.
+ */
+ public String[] ListNames();
+
+ /**
+ * Determine if a name has an owner.
+ *
+ * @param name The name to query.
+ * @return true if the name has an owner.
+ */
+ public boolean NameHasOwner(String name);
+
+ /**
+ * Get the connection unique name that owns the given name.
+ *
+ * @param name The name to query.
+ * @return The connection which owns the name.
+ */
+ public String GetNameOwner(String name);
+
+ /**
+ * Get the Unix UID that owns a connection name.
+ *
+ * @param connection_name The connection name.
+ * @return The Unix UID that owns it.
+ */
+ public UInt32 GetConnectionUnixUser(String connection_name);
+
+ /**
+ * Start a service. If the given service is not provided
+ * by any application, it will be started according to the .service file
+ * for that service.
+ *
+ * @param name The service name to start.
+ * @param flags Unused.
+ * @return DBUS_START_REPLY constants.
+ */
+ public UInt32 StartServiceByName(String name, UInt32 flags);
+
+ /**
+ * Request a name on the bus.
+ *
+ * @param name The name to request.
+ * @param flags DBUS_NAME flags.
+ * @return DBUS_REQUEST_NAME_REPLY constants.
+ */
+ public UInt32 RequestName(String name, UInt32 flags);
+
+ /**
+ * Release a name on the bus.
+ *
+ * @param name The name to release.
+ * @return DBUS_RELEASE_NAME_REPLY constants.
+ */
+ public UInt32 ReleaseName(String name);
+
+ /**
+ * Add a match rule.
+ * Will cause you to receive messages that aren't directed to you which
+ * match this rule.
+ *
+ * @param matchrule The Match rule as a string. Format Undocumented.
+ */
+ public void AddMatch(String matchrule) throws Error.MatchRuleInvalid;
+
+ /**
+ * Remove a match rule.
+ * Will cause you to stop receiving messages that aren't directed to you which
+ * match this rule.
+ *
+ * @param matchrule The Match rule as a string. Format Undocumented.
+ */
+ public void RemoveMatch(String matchrule) throws Error.MatchRuleInvalid;
+
+ /**
+ * List the connections currently queued for a name.
+ *
+ * @param name The name to query
+ * @return A list of unique connection IDs.
+ */
+ public String[] ListQueuedOwners(String name);
+
+ /**
+ * Returns the proccess ID associated with a connection.
+ *
+ * @param connection_name The name of the connection
+ * @return The PID of the connection.
+ */
+ public UInt32 GetConnectionUnixProcessID(String connection_name);
+
+ /**
+ * Does something undocumented.
+ */
+ public Byte[] GetConnectionSELinuxSecurityContext(String a);
+
+ /**
+ * Does something undocumented.
+ */
+ public void ReloadConfig();
+
+ /**
+ * Signal sent when the owner of a name changes
+ */
+ public class NameOwnerChanged extends DBusSignal {
+ public final String name;
+ public final String old_owner;
+ public final String new_owner;
+
+ public NameOwnerChanged(String path, String name, String old_owner, String new_owner) throws DBusException {
+ super(path, new Object[]{name, old_owner, new_owner});
+ this.name = name;
+ this.old_owner = old_owner;
+ this.new_owner = new_owner;
+ }
+ }
+
+ /**
+ * Signal sent to a connection when it loses a name
+ */
+ public class NameLost extends DBusSignal {
+ public final String name;
+
+ public NameLost(String path, String name) throws DBusException {
+ super(path, name);
+ this.name = name;
+ }
+ }
+
+ /**
+ * Signal sent to a connection when it aquires a name
+ */
+ public class NameAcquired extends DBusSignal {
+ public final String name;
+
+ public NameAcquired(String path, String name) throws DBusException {
+ super(path, name);
+ this.name = name;
+ }
+ }
+
+ /**
+ * Contains standard errors that can be thrown from methods.
+ */
+ public interface Error {
+ /**
+ * Thrown if the method called was unknown on the remote object
+ */
+ @SuppressWarnings("serial")
+ public class UnknownMethod extends DBusExecutionException {
+ public UnknownMethod(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * Thrown if the object was unknown on a remote connection
+ */
+ @SuppressWarnings("serial")
+ public class UnknownObject extends DBusExecutionException {
+ public UnknownObject(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * Thrown if the requested service was not available
+ */
+ @SuppressWarnings("serial")
+ public class ServiceUnknown extends DBusExecutionException {
+ public ServiceUnknown(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * Thrown if the match rule is invalid
+ */
+ @SuppressWarnings("serial")
+ public class MatchRuleInvalid extends DBusExecutionException {
+ public MatchRuleInvalid(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * Thrown if there is no reply to a method call
+ */
+ @SuppressWarnings("serial")
+ public class NoReply extends DBusExecutionException {
+ public NoReply(String message) {
+ super(message);
+ }
+ }
+
+ /**
+ * Thrown if a message is denied due to a security policy
+ */
+ @SuppressWarnings("serial")
+ public class AccessDenied extends DBusExecutionException {
+ public AccessDenied(String message) {
+ super(message);
+ }
+ }
+ }
+
+ /**
+ * Description of the interface or method, returned in the introspection data
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Description {
+ String value();
+ }
+
+ /**
+ * Indicates that a DBus interface or method is deprecated
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Deprecated {
+ }
+
+ /**
+ * Contains method-specific annotations
+ */
+ public interface Method {
+ /**
+ * Methods annotated with this do not send a reply
+ */
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface NoReply {
+ }
+
+ /**
+ * Give an error that the method can return
+ */
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Error {
+ String value();
+ }
+ }
+
+ /**
+ * Contains GLib-specific annotations
+ */
+ public interface GLib {
+ /**
+ * Define a C symbol to map to this method. Used by GLib only
+ */
+ @Target(ElementType.METHOD)
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface CSymbol {
+ String value();
+ }
+ }
+
+ /**
+ * Contains Binding-test interfaces
+ */
+ public interface Binding {
+ public interface SingleTests extends DBusInterface {
+ @Description("Returns the sum of the values in the input list")
+ public UInt32 Sum(byte[] a);
+ }
+
+ public interface TestClient extends DBusInterface {
+ @Description("when the trigger signal is received, this method should be called on the sending process/object.")
+ public void Response(UInt16 a, double b);
+
+ @Description("Causes a callback")
+ public static class Trigger extends DBusSignal {
+ public final UInt16 a;
+ public final double b;
+
+ public Trigger(String path, UInt16 a, double b) throws DBusException {
+ super(path, a, b);
+ this.a = a;
+ this.b = b;
+ }
+ }
+
+ }
+
+ public interface Tests extends DBusInterface {
+ @Description("Returns whatever it is passed")
+ public Variant Identity(Variant input);
+
+ @Description("Returns whatever it is passed")
+ public byte IdentityByte(byte input);
+
+ @Description("Returns whatever it is passed")
+ public boolean IdentityBool(boolean input);
+
+ @Description("Returns whatever it is passed")
+ public short IdentityInt16(short input);
+
+ @Description("Returns whatever it is passed")
+ public UInt16 IdentityUInt16(UInt16 input);
+
+ @Description("Returns whatever it is passed")
+ public int IdentityInt32(int input);
+
+ @Description("Returns whatever it is passed")
+ public UInt32 IdentityUInt32(UInt32 input);
+
+ @Description("Returns whatever it is passed")
+ public long IdentityInt64(long input);
+
+ @Description("Returns whatever it is passed")
+ public UInt64 IdentityUInt64(UInt64 input);
+
+ @Description("Returns whatever it is passed")
+ public double IdentityDouble(double input);
+
+ @Description("Returns whatever it is passed")
+ public String IdentityString(String input);
+
+ @Description("Returns whatever it is passed")
+ public Variant[] IdentityArray(Variant[] input);
+
+ @Description("Returns whatever it is passed")
+ public byte[] IdentityByteArray(byte[] input);
+
+ @Description("Returns whatever it is passed")
+ public boolean[] IdentityBoolArray(boolean[] input);
+
+ @Description("Returns whatever it is passed")
+ public short[] IdentityInt16Array(short[] input);
+
+ @Description("Returns whatever it is passed")
+ public UInt16[] IdentityUInt16Array(UInt16[] input);
+
+ @Description("Returns whatever it is passed")
+ public int[] IdentityInt32Array(int[] input);
+
+ @Description("Returns whatever it is passed")
+ public UInt32[] IdentityUInt32Array(UInt32[] input);
+
+ @Description("Returns whatever it is passed")
+ public long[] IdentityInt64Array(long[] input);
+
+ @Description("Returns whatever it is passed")
+ public UInt64[] IdentityUInt64Array(UInt64[] input);
+
+ @Description("Returns whatever it is passed")
+ public double[] IdentityDoubleArray(double[] input);
+
+ @Description("Returns whatever it is passed")
+ public String[] IdentityStringArray(String[] input);
+
+ @Description("Returns the sum of the values in the input list")
+ public long Sum(int[] a);
+
+ @Description("Given a map of A => B, should return a map of B => a list of all the As which mapped to B")
+ public Map> InvertMapping(Map a);
+
+ @Description("This method returns the contents of a struct as separate values")
+ public Triplet DeStruct(TestStruct a);
+
+ @Description("Given any compound type as a variant, return all the primitive types recursively contained within as an array of variants")
+ public List> Primitize(Variant