Welcome to the jGuard's wiki » jGuard Documentation » import/export authentication and authorization data

import/export authentication and authorization data

Last modified by RaffaelloPelagalli on 2007/01/03 14:02

import authentication data

we try to import another AuthenticationManager in the current one.

this other AuthenticationManager can be backed by an XML file(in this example) or a database.

AuthenticationManager otherAuthNManager =  new XMLAuthenticationManager();
Map options = new HashMap();
options.put(CoreConstants.APPLICATION_NAME,"myAppName");
options.put(SecurityConstants.AUTHENTICATION_XML_FILE_LOCATION,"/home/user/myfile.xml");
otherAuthNManager.init(options);
//retrieve current AuthenticationManager
AuthenticationManager myAuthNManager = AuthenticationManagerFactory.getAuthenticationManager();
//import in the current AuthenticationManager some data
myAuthNManager.importAuthenticationManager(otherAuthNManager);

export authentication data in XML

several methods exist in net.sf.jguard.ext.authentication.manager.AuthenticationUtils class to export data in XML way.

export your AuthenticationManager as an XMLAuthenticationManager

AuthenticationManager myAuthNManager;
XMLAuthenticationManager myXmlAUthNManager = AuthenticationUtils.exportAsXmlAuthorizationManager(myAuthNManager);

export your AuthenticationManager as an XML string

AuthenticationManager myAuthNManager;
String myXmlData = AuthenticationUtils.exportAsXMLString(myAuthNManager);

export your AuthenticationManager as an XML File

AuthenticationManager myAuthNManager;
String fileLocation="/home/data/myFile.xml";
AuthenticationUtils.exportAsXMLFile(myAuthNManager,fileLocation);

export your AuthorizationManager as an HTML form in a stream

AuthenticationManager myAuthNManager;
OutputStream myOutputStream = yourHttpServletResponse.getOutputStream();
AuthenticationUtils.writeAsHTML(myAuthNManager,myOutputStream);

export your AuthenticationManager as an XML form in a stream

AuthenticationManager myAuthNManager;
OutputStream myOutputStream = yourHttpServletResponse.getOutputStream();
String encodingScheme = yourHttpServletResponse.getEncodingScheme();
AuthenticationUtils.writeAsXML(myAuthNManager,myOutputStream,encodingScheme);

import authorization data

we try to import another AuthorizationManager in the current one.

this other AuthorizationManager can be backed by an XML file(in this example) or a database.

AuthorizationManager otherAuthZManager =  new XMLAuthorizationManager();
Map options = new HashMap();
options.put(CoreConstants.APPLICATION_NAME,"myAppName");
options.put(SecurityConstants.AUTHORIZATION_XML_FILE_LOCATION,"/home/user/myfile.xml");
otherAuthZManager.init(options);
//retrieve current AuthorizationManager 
AuthorizationManager myAuthNManager = AuthorizationManagerFactory.getAuthorizationManager();
//import in the current AuthenticationManager some data
myAuthNManager.importAuthenticationManager(otherAuthNManager);

export authorization data in XML

several methods exist in net.sf.jguard.ext.authorization.manager.AuthorizationUtils class to export data in XML way.

export your AuthorizationManager as an XMLAuthorizationManager

Authorizationmanager myAuthZManager;
XMLAuthorizationManager myXmlAUthZManager = AuthorizationUtils.exportAsXmlAuthorizationManager(myAuthZManager);

export your AuthorizationManager as an XML string

Authorizationmanager myAuthZManager;
String myXmlData = AuthorizationUtils.exportAsXMLString(myAuthZManager);

export your AuthorizationManager as an XML File

Authorizationmanager myAuthZManager;
String fileLocation="/home/data/myFile.xml";
AuthorizationUtils.exportAsXMLFile(myAuthZManager,fileLocation);

export your AuthorizationManager as an HTML form in a stream

Authorizationmanager myAuthZManager;
OutputStream myOutputStream = yourHttpServletResponse.getOutputStream();
AuthorizationUtils.writeAsHTML(myAuthZManager,myOutputStream);

export your AuthorizationManager as an XML form in a stream

Authorizationmanager myAuthZManager;
OutputStream myOutputStream = yourHttpServletResponse.getOutputStream();
String encodingScheme = yourHttpServletResponse.getEncodingScheme();
AuthorizationUtils.writeAsXML(myAuthZManager,myOutputStream,encodingScheme);
Tags:
Created by diabolo512 on 2007/01/02 11:33

jGuard team copyright 2004-2009
3.1.1