The JaasSecurityDomain is an extension of JaasSecurityManager that addes the notion of a KeyStore, and JSSE
KeyManagerFactory and TrustManagerFactory for supporting SSL and other cryptographic use cases.
Attributes:
| Method from org.jboss.security.plugins.JaasSecurityDomain Detail: |
public byte[] decode(byte[] secret) throws Exception {
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(decodePermission);
Cipher cipher = Cipher.getInstance(cipherAlgorithm);
cipher.init(Cipher.DECRYPT_MODE, cipherKey, cipherSpec);
byte[] decode = cipher.doFinal(secret);
return decode;
}
Decrypt the secret using the cipherKey. |
public byte[] decode64(String secret) throws Exception {
byte[] encoding = CryptoUtil.fromb64(secret);
byte[] decode = decode(encoding);
return decode;
}
Decrypt the base64 encoded secret using the cipherKey. |
public byte[] encode(byte[] secret) throws Exception {
SecurityManager sm = System.getSecurityManager();
if (sm != null)
{
System.out.println("Checking: " + encodePermission);
sm.checkPermission(encodePermission);
}
Cipher cipher = Cipher.getInstance(cipherAlgorithm);
cipher.init(Cipher.ENCRYPT_MODE, cipherKey, cipherSpec);
byte[] encoding = cipher.doFinal(secret);
return encoding;
}
Encrypt the secret using the cipherKey. |
public String encode64(byte[] secret) throws Exception {
byte[] encoding = encode(secret);
String b64 = CryptoUtil.tob64(encoding);
return b64;
}
Encrypt the secret using the cipherKey and return a base64 encoding. |
public String getCipherAlgorithm() {
return cipherAlgorithm;
}
|
public KeyManagerFactory getKeyManagerFactory() throws SecurityException {
return keyMgr;
}
|
public KeyStore getKeyStore() throws SecurityException {
return keyStore;
}
|
public String getKeyStoreType() {
return this.keyStoreType;
}
|
public String getKeyStoreURL() {
String url = null;
if (keyStoreURL != null)
url = keyStoreURL.toExternalForm();
return url;
}
|
public ObjectName getManagerServiceName() {
return this.managerServiceName;
}
The JMX object name string of the security manager service. |
public String getName() {
return "JaasSecurityDomain(" + getSecurityDomain() + ")";
}
|
public ISecurityManagement getSecurityManagement() {
return securityManagement;
}
|
public TrustManagerFactory getTrustManagerFactory() throws SecurityException {
return trustMgr;
}
|
public KeyStore getTrustStore() throws SecurityException {
return trustStore;
}
|
public String getTrustStoreType() {
return this.trustStoreType;
}
|
public String getTrustStoreURL() {
String url = null;
if (trustStoreURL != null)
url = trustStoreURL.toExternalForm();
return url;
}
|
public void reloadKeyAndTrustStore() throws Exception {
loadKeyAndTrustStore();
}
Reload the key- and truststore |
public void setCipherAlgorithm(String cipherAlgorithm) {
this.cipherAlgorithm = cipherAlgorithm;
}
|
public void setIterationCount(int iterationCount) {
this.iterationCount = iterationCount;
}
|
public void setKeyStorePass(String password) throws Exception {
this.keyStorePassword = Util.loadPassword(password);
}
|
public void setKeyStoreType(String type) {
this.keyStoreType = type;
}
|
public void setKeyStoreURL(String storeURL) throws IOException {
this.keyStoreURL = this.validateStoreURL(storeURL);
log.debug("Using KeyStore=" + keyStoreURL.toExternalForm());
}
|
public void setManagerServiceName(ObjectName managerServiceName) {
this.managerServiceName = managerServiceName;
}
Set the JMX object name string of the security manager service. |
public void setSalt(String salt) {
this.salt = salt.getBytes();
}
|
public void setSecurityManagement(ISecurityManagement securityManagement) {
this.securityManagement = securityManagement;
}
|
public void setTrustStorePass(String password) throws Exception {
this.trustStorePassword = Util.loadPassword(password);
}
|
public void setTrustStoreType(String type) {
this.trustStoreType = type;
}
|
public void setTrustStoreURL(String storeURL) throws IOException {
this.trustStoreURL = validateStoreURL(storeURL);
}
|
protected void startService() throws Exception {
// Load the secret key
loadPBESecretKey();
// Load the key and/or truststore into memory
loadKeyAndTrustStore();
// Only register with the JaasSecurityManagerService if its defined
if (managerServiceName != null)
{
/*
* Register with the JaasSecurityManagerServiceMBean. This allows this JaasSecurityDomain to function as the
* security manager for security-domain elements that declare java:/jaas/xxx for our security domain name.
*/
MBeanServer server = MBeanServerLocator.locateJBoss();
Object[] params = {getSecurityDomain(), this};
String[] signature = new String[]{"java.lang.String", "org.jboss.security.SecurityDomain"};
server.invoke(managerServiceName, "registerSecurityDomain", params, signature);
}
// Register yourself with the security management
if (securityManagement instanceof JNDIBasedSecurityManagement)
{
JNDIBasedSecurityManagement jbs = (JNDIBasedSecurityManagement) securityManagement;
jbs.registerJaasSecurityDomainInstance(getSecurityDomain(), this);
}
}
|
protected void stopService() {
if (keyStorePassword != null)
{
Arrays.fill(keyStorePassword, '\0");
keyStorePassword = null;
}
cipherKey = null;
// Deregister yourself with the security management
if (securityManagement instanceof JNDIBasedSecurityManagement)
{
JNDIBasedSecurityManagement jbs = (JNDIBasedSecurityManagement) securityManagement;
jbs.deregisterJaasSecurityDomainInstance(getSecurityDomain(), this);
}
}
|