@Override public void stop(StopContext stopContext) { TransactionManagerLocator.setTransactionManager(null); }
/** * Method to compute masked password based on class attributes. * * @return masked password prefixed with {link @PicketBoxSecurityVault.PASS_MASK_PREFIX}. * @throws Exception */ private String computeMaskedPassword() throws Exception { // Create the PBE secret key SecretKeyFactory factory = SecretKeyFactory.getInstance(VAULT_ENC_ALGORITHM); char[] password = "somearbitrarycrazystringthatdoesnotmatter".toCharArray(); PBEParameterSpec cipherSpec = new PBEParameterSpec(salt.getBytes(CHARSET), iterationCount); PBEKeySpec keySpec = new PBEKeySpec(password); SecretKey cipherKey = factory.generateSecret(keySpec); String maskedPass = PBEUtils.encode64(keystorePassword.getBytes(CHARSET), VAULT_ENC_ALGORITHM, cipherKey, cipherSpec); return PicketBoxSecurityVault.PASS_MASK_PREFIX + maskedPass; }
private void setupPolicyRegistration(final StartContext context) { ServiceTarget target = context.getChildTarget(); final BinderService binderService = new BinderService(POLICY_REGISTRATION); binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory( Values.immediateValue(new JBossPolicyRegistration()))); target.addService(ContextNames.buildServiceName(ContextNames.JAVA_CONTEXT_SERVICE_NAME, POLICY_REGISTRATION), binderService) .addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .install(); }
private RoleGroup getCurrentRoles(Principal principal) { //Check that the caller is authenticated to the current thread Subject subject = SubjectActions.getActiveSubject(); //Deal with the security context SecurityContext sc = SubjectActions.getSecurityContext(); if(sc == null) { sc = new JBossSecurityContext(securityDomain); SubjectActions.setSecurityContext(sc); } return getCurrentRoles(principal,subject,sc); }
/** * @see AuthorizationManager#authorize(Resource) */ public int authorize(Resource resource) throws AuthorizationException { validateResource(resource); Subject subject = SubjectActions.getActiveSubject(); return internalAuthorization(resource,subject, null); }
protected TransactionManager getTransactionManager() throws NamingException { TransactionManagerLocator tml = new TransactionManagerLocator(); return tml.getTM(this.txManagerJndiName); } }
/** * @see AuthorizationManager#authorize(Resource, Subject, RoleGroup) */ public int authorize(Resource resource, Subject subject, RoleGroup role) throws AuthorizationException { this.validateResource(resource); return internalAuthorization(resource, subject, role); }
/** {@inheritDoc} */ @Override public synchronized void start(StartContext context) throws StartException { SecurityLogger.ROOT_LOGGER.debugf("Starting SubjectFactoryService"); final ISecurityManagement injectedSecurityManagement = securityManagementValue.getValue(); int i = subjectFactoryClassName.lastIndexOf(":"); if (i == -1) throw SecurityLogger.ROOT_LOGGER.missingModuleName("subject-factory-class-name attribute"); String moduleSpec = subjectFactoryClassName.substring(0, i); String className = subjectFactoryClassName.substring(i + 1); JBossSecuritySubjectFactory subjectFactory = null; try { Class<?> subjectFactoryClazz = SecurityActions.getModuleClassLoader(moduleSpec).loadClass(className); subjectFactory = (JBossSecuritySubjectFactory) subjectFactoryClazz.newInstance(); } catch (Exception e) { throw SecurityLogger.ROOT_LOGGER.unableToStartException("SubjectFactoryService", e); } subjectFactory.setSecurityManagement(injectedSecurityManagement); this.subjectFactory = subjectFactory; }
ClassLoaderLocatorFactory.set(new ModuleClassLoaderLocator(moduleLoaderValue.getValue())); } catch (Exception e) { throw SecurityLogger.ROOT_LOGGER.unableToStartException("SecurityBootstrapService", e);
/** * @see ISecurityManagement#getAuthenticationManager() */ public AuthenticationManager getAuthenticationManager(String securityDomain) { return new JBossAuthenticationManager(securityDomain, this.handler); }
/** Return the set of domain roles the current active Subject 'Roles' group found in the subject Principals set. @param principal - ignored. The current authenticated Subject determines the active user and assigned user roles. @return The Set<Principal> for the application domain roles that the principal has been assigned. */ public Set<Principal> getUserRoles(Principal principal) { RoleGroup userRoles = getCurrentRoles(principal); return this.getRolesAsSet(userRoles); }
/** * @see ISecurityManagement#getAuthorizationManager(String) */ public AuthorizationManager getAuthorizationManager(String securityDomain) { return new JBossAuthorizationManager(securityDomain); }
clonedSecurityContext = (SecurityContext) ((JBossSecurityContext) securityContext).clone(); } else {
/** * @see SubjectFactory#createSubject() */ public Subject createSubject() { return createSubject(SecurityConstants.DEFAULT_APPLICATION_POLICY); }
private RoleGroup getCurrentRoles(Principal principal) { //Check that the caller is authenticated to the current thread Subject subject = SubjectActions.getActiveSubject(); //Deal with the security context SecurityContext sc = SubjectActions.getSecurityContext(); if(sc == null) { sc = new JBossSecurityContext(securityDomain); SubjectActions.setSecurityContext(sc); } return getCurrentRoles(principal,subject,sc); }
/** * @see AuthorizationManager#authorize(Resource) */ public int authorize(Resource resource) throws AuthorizationException { validateResource(resource); Subject subject = SubjectActions.getActiveSubject(); return internalAuthorization(resource,subject, null); }
protected TransactionManager getTransactionManager() throws NamingException { TransactionManagerLocator tml = new TransactionManagerLocator(); return tml.getTM(this.TX_MGR_JNDI_NAME); }
@Override public void start(StartContext startContext) throws StartException { TransactionManagerLocator.setTransactionManager(transactionManagerInjectedValue.getValue()); }
/** * @see AuthorizationManager#authorize(Resource, Subject, RoleGroup) */ public int authorize(Resource resource, Subject subject, RoleGroup role) throws AuthorizationException { this.validateResource(resource); return internalAuthorization(resource, subject, role); }
protected TransactionManager getTransactionManager() throws NamingException { TransactionManagerLocator tml = new TransactionManagerLocator(); return tml.getTM(this.TX_MGR_JNDI_NAME); } }