本文整理汇总了Java中org.jboss.seam.contexts.Contexts类的典型用法代码示例。如果您正苦于以下问题:Java Contexts类的具体用法?Java Contexts怎么用?Java Contexts使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Contexts类属于org.jboss.seam.contexts包,在下文中一共展示了Contexts类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAuthorizedUser
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
protected boolean getAuthorizedUser() {
try {
GluuCustomPerson authUser = (GluuCustomPerson) Contexts.getSessionContext().get(OxTrustConstants.CURRENT_PERSON);
if (authUser == null) {
return false;
}
GluuAppliance appliance = applianceService.getAppliance();
if (appliance == null) {
return false;
}
if (!(GluuBoolean.TRUE.equals(appliance.getScimEnabled()) || GluuBoolean.ENABLED.equals(appliance.getScimEnabled()))) {
return false;
}
return true;
} catch (Exception ex) {
log.error("Exception: ", ex);
return false;
}
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:24,代码来源:BaseScimWebService.java
示例2: logConnectionProviderStatistic
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
public void logConnectionProviderStatistic(String connectionProvider, String bindConnectionProvider) {
if ((connectionProvider != null) && Contexts.getApplicationContext().isSet(connectionProvider)) {
LDAPConnectionProvider ldapConnectionProvider = (LDAPConnectionProvider) Contexts.getApplicationContext().get(connectionProvider);
if (ldapConnectionProvider.getConnectionPool() == null) {
log.error("{0} is empty", connectionProvider);
} else {
log.info("{0} statistics: {1}", connectionProvider, ldapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
}
}
if ((bindConnectionProvider != null) && Contexts.getApplicationContext().isSet(bindConnectionProvider)) {
LDAPConnectionProvider bindLdapConnectionProvider = (LDAPConnectionProvider) Contexts.getApplicationContext().get(bindConnectionProvider);
if (bindLdapConnectionProvider.getConnectionPool() == null) {
log.error("{0} is empty", bindConnectionProvider);
} else {
log.info("{0} statistics: {1}", bindConnectionProvider, bindLdapConnectionProvider.getConnectionPool().getConnectionPoolStatistics());
}
}
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:22,代码来源:LdapStatusTimer.java
示例3: createConnectionAuthProvider
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
private void createConnectionAuthProvider(String configurationLdapConfigComponentName, String fileName, String configurationComponentName, String connectionProviderComponentName) {
FileConfiguration configuration = new FileConfiguration(fileName);
Contexts.getApplicationContext().set(configurationComponentName, configuration);
//
Properties properties = configuration.getProperties();
if (this.ldapConfig != null) {
Contexts.getApplicationContext().set(configurationLdapConfigComponentName, this.ldapConfig);
properties.setProperty("servers", buildServersString(this.ldapConfig.getServers()));
properties.setProperty("bindDN", this.ldapConfig.getBindDN());
properties.setProperty("bindPassword", this.ldapConfig.getBindPassword());
properties.setProperty("useSSL", Boolean.toString(this.ldapConfig.isUseSSL()));
}
//
LdapConnectionService connectionProvider = new LdapConnectionService(PropertiesDecrypter.decryptProperties(properties, oxTrustConfiguration.getCryptoConfigurationSalt()));
Contexts.getApplicationContext().set(connectionProviderComponentName, connectionProvider);
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:20,代码来源:AppInitializer.java
示例4: destroyApplicationComponents
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
/**
* When application undeploy we need to close LDAP Connections
*
* @throws org.apache.commons.configuration.ConfigurationException
*/
// @Destroy
public void destroyApplicationComponents() throws ConfigurationException {
log.debug("Destroying application components");
LdapEntryManager ldapEntryManager = (LdapEntryManager) Contexts.getApplicationContext().get(LDAP_ENTRY_MANAGER_NAME);
ldapEntryManager.destroy();
LdapEntryManager ldapAuthEntryManager = (LdapEntryManager) Contexts.getApplicationContext().get(LDAP_AUTH_ENTRY_MANAGER_NAME);
if (ldapAuthEntryManager != null) {
ldapAuthEntryManager.destroy();
}
LdapEntryManager ldapCentralEntryManager = (LdapEntryManager) Contexts.getApplicationContext().get(LDAP_CENTRAL_ENTRY_MANAGER_NAME);
if (ldapCentralEntryManager != null) {
ldapCentralEntryManager.destroy();
}
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:22,代码来源:AppInitializer.java
示例5: recreateCentralLdapEntryManager
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
@Observer(OxTrustConfiguration.LDAP_CENTRAL_CONFIGUARION_RELOAD_EVENT_TYPE)
public void recreateCentralLdapEntryManager() {
// Backup current references to objects to allow shutdown properly
LdapEntryManager oldCentralLdapEntryManager = (LdapEntryManager) Component.getInstance(LDAP_CENTRAL_ENTRY_MANAGER_NAME);
// Recreate components
if ((oxTrustConfiguration.getLdapCentralConfiguration() != null) && oxTrustConfiguration.getApplicationConfiguration().isUpdateApplianceStatus()) {
createConnectionProvider(oxTrustConfiguration.getLdapCentralConfiguration(), "centralLdapConfiguration", "centralConnectionProvider");
} else {
Contexts.getApplicationContext().remove("centralConnectionProvider");
}
// Destroy old components
Contexts.getApplicationContext().remove(LDAP_CENTRAL_ENTRY_MANAGER_NAME);
if (oldCentralLdapEntryManager != null) {
oldCentralLdapEntryManager.destroy();
log.debug("Destroyed {0}: {1}", LDAP_CENTRAL_ENTRY_MANAGER_NAME, oldCentralLdapEntryManager);
}
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:22,代码来源:AppInitializer.java
示例6: logout
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
public String logout() {
boolean isShib2Authentication = OxTrustConstants.APPLICATION_AUTHORIZATION_NAME_SHIBBOLETH2.equals(Contexts.getSessionContext().get(
OxTrustConstants.APPLICATION_AUTHORIZATION_TYPE));
if (isShib2Authentication) {
// After this redirect we should invalidate this session
try {
HttpServletResponse userResponse = (HttpServletResponse) facesContext.getExternalContext().getResponse();
HttpServletRequest userRequest = (HttpServletRequest) facesContext.getExternalContext().getRequest();
String redirectUrl = String.format("%s%s", applicationConfiguration.getIdpUrl(), "/idp/logout.jsp");
String url = String.format("%s://%s/Shibboleth.sso/Logout?return=%s", userRequest.getScheme(), userRequest.getServerName(),
redirectUrl);
userResponse.sendRedirect(url);
facesContext.responseComplete();
} catch (IOException ex) {
log.error("Failed to redirect to SSO logout page", ex);
}
}
return isShib2Authentication ? OxTrustConstants.RESULT_LOGOUT_SSO : OxTrustConstants.RESULT_LOGOUT;
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:24,代码来源:SsoLoginAction.java
示例7: postLogin
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
/**
* Set session variables after user login
*
* @throws Exception
*/
private void postLogin(User user) {
log.debug("Configuring application after user '{0}' login", user.getUid());
GluuCustomPerson person = findPersonByDn(user.getDn());
Contexts.getSessionContext().set(OxTrustConstants.CURRENT_PERSON, person);
// Set user roles
GluuUserRole[] userRoles = securityService.getUserRoles(user);
if (ArrayHelper.isNotEmpty(userRoles)) {
log.debug("Get '{0}' user roles", Arrays.toString(userRoles));
} else {
log.debug("Get 0 user roles");
}
for (GluuUserRole userRole : userRoles) {
identity.addRole(userRole.getRoleName());
}
if (log.isDebugEnabled()) {
for (Group sg : identity.getSubject().getPrincipals(java.security.acl.Group.class)) {
if ("Roles".equals(sg.getName())) {
log.debug("Using next user roles: '{0}'", sg.members());
break;
}
}
}
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:31,代码来源:Authenticator.java
示例8: init
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
@Create
public void init() {
System.setProperty("com.workplacesystems.queuj.QueujFactory", "com.workplacesystems.queuj.process.seam.SeamFactory");
RunOnce occurrence = new RunOnce();
RelativeScheduleBuilder rsb = occurrence.newRelativeScheduleBuilder();
rsb.setRunImmediately();
rsb.createSchedule();
QueueBuilder<SeamProcessBuilder> qb = QueueFactory.ROOT_QUEUE.newQueueBuilder(SeamProcessBuilder.class);
qb.setQueueRestriction(new JavaQueueRestriction());
qb.setBatchProcessServerClass(SeamProcessServer.class);
qb.setDefaultOccurrence(occurrence);
qb.setDefaultResilience(new RunOnlyOnce());
Queue<SeamProcessBuilder> seamQueue = qb.newQueue();
Contexts.getApplicationContext().set("DEFAULT_QUEUE", seamQueue);
QueujFactory.getProcessServer((String)null, null);
}
开发者ID:workplacesystems,项目名称:queuj,代码行数:20,代码来源:QueujInitialiser.java
示例9: postLogin
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
public void postLogin(GluuCustomPerson person) throws Exception {
log.debug("Configuring application after user '{0}' login", person.getUid());
Contexts.getSessionContext().set(OxTrustConstants.CURRENT_PERSON, person);
// Set user roles
GluuUserRole[] userRoles = securityService.getUserRoles(person);
for (GluuUserRole userRole : userRoles) {
identity.addRole(userRole.getRoleName());
}
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:11,代码来源:OxChooserWebService.java
示例10: createConnectionProvider
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
private void createConnectionProvider(FileConfiguration configuration, String configurationComponentName, String connectionProviderComponentName) {
Contexts.getApplicationContext().set(configurationComponentName, configuration);
LdapConnectionService connectionProvider = null;
if (configuration != null) {
connectionProvider = new LdapConnectionService(PropertiesDecrypter.decryptProperties(configuration
.getProperties(), oxTrustConfiguration.getCryptoConfigurationSalt()));
}
Contexts.getApplicationContext().set(connectionProviderComponentName, connectionProvider);
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:11,代码来源:AppInitializer.java
示例11: createLdapEntryManager
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
@Factory(value = LDAP_ENTRY_MANAGER_NAME, scope = ScopeType.APPLICATION, autoCreate = true)
public LdapEntryManager createLdapEntryManager() {
LdapConnectionService connectionProvider = (LdapConnectionService) Contexts.getApplicationContext().get("connectionProvider");
LdapEntryManager ldapEntryManager = new LdapEntryManager(new OperationsFacade(connectionProvider));
log.debug("Created site LdapEntryManager: " + ldapEntryManager);
return ldapEntryManager;
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:9,代码来源:AppInitializer.java
示例12: createCentralLdapEntryManager
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
@Factory(value = LDAP_CENTRAL_ENTRY_MANAGER_NAME, scope = ScopeType.APPLICATION, autoCreate = true)
public LdapEntryManager createCentralLdapEntryManager() {
LdapConnectionService centralConnectionProvider = (LdapConnectionService) Contexts.getApplicationContext().get("centralConnectionProvider");
if (centralConnectionProvider == null) {
return null;
}
log.debug("Created central LdapEntryManager: " + centralConnectionProvider);
LdapEntryManager centralLdapEntryManager = new LdapEntryManager(new OperationsFacade(centralConnectionProvider));
log.debug("Created central LdapEntryManager: " + centralLdapEntryManager);
return centralLdapEntryManager;
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:14,代码来源:AppInitializer.java
示例13: createLdapAuthEntryManager
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
@Factory(value = "ldapAuthEntryManager", scope = ScopeType.APPLICATION, autoCreate = true)
public LdapEntryManager createLdapAuthEntryManager() {
LdapConnectionService connectionProvider = (LdapConnectionService) Contexts.getApplicationContext().get("authConnectionProvider");
LdapEntryManager ldapAuthEntryManager = new LdapEntryManager(new OperationsFacade(connectionProvider, null));
// LDAP_ENTRY_MANAGER_NAME.addDeleteSubscriber(new
// LdifArchiver(LDAP_ENTRY_MANAGER_NAME));
log.debug("Created site LdapAuthEntryManager: " + ldapAuthEntryManager);
return ldapAuthEntryManager;
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:11,代码来源:AppInitializer.java
示例14: recreateLdapEntryManager
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
@Observer(OxTrustConfiguration.LDAP_CONFIGUARION_RELOAD_EVENT_TYPE)
public void recreateLdapEntryManager() {
// Backup current references to objects to allow shutdown properly
LdapEntryManager oldLdapEntryManager = (LdapEntryManager) Component.getInstance(LDAP_ENTRY_MANAGER_NAME);
// Recreate components
createConnectionProvider(oxTrustConfiguration.getLdapConfiguration(), "localLdapConfiguration", "connectionProvider");
// Destroy old components
Contexts.getApplicationContext().remove(LDAP_ENTRY_MANAGER_NAME);
oldLdapEntryManager.destroy();
log.debug("Destroyed {0}: {1}", LDAP_ENTRY_MANAGER_NAME, oldLdapEntryManager);
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:15,代码来源:AppInitializer.java
示例15: recreateLdapAuthEntryManagers
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
public void recreateLdapAuthEntryManagers() {
// Backup current references to objects to allow shutdown properly
LdapEntryManager oldLdapAuthEntryManager = (LdapEntryManager) Component.getInstance(LDAP_AUTH_ENTRY_MANAGER_NAME);
// Recreate components
createConnectionAuthProvider("ldapAuthConfig", oxTrustConfiguration.getLdapConfiguration().getFileName(), "localLdapAuthConfiguration", "authConnectionProvider");
// Destroy old components
Contexts.getApplicationContext().remove(LDAP_AUTH_ENTRY_MANAGER_NAME);
oldLdapAuthEntryManager.destroy();
log.debug("Destroyed {0}: {1}", LDAP_CENTRAL_ENTRY_MANAGER_NAME, oldLdapAuthEntryManager);
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:14,代码来源:AppInitializer.java
示例16: createResource
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory)
{
// Push this onto event context so we have it available in ResteasyContextInjectionInterceptor
Contexts.getEventContext().set(ResteasyContextInjectionInterceptor.RE_HTTP_REQUEST_VAR, request);
Contexts.getEventContext().set(ResteasyContextInjectionInterceptor.RE_HTTP_RESPONSE_VAR, response);
log.debug("creating RESTEasy resource instance by looking up Seam component: " + seamComponent.getName());
return Component.getInstance(seamComponent.getName());
}
开发者ID:windup,项目名称:windup-rulesets,代码行数:9,代码来源:SeamResteasyResourceFactory.java
示例17: shibboleth2Authenticate
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
/**
* Authenticate using credentials passed from web request header
*/
public boolean shibboleth2Authenticate() {
log.debug("Checking if user authenticated with shibboleth already");
boolean result = false;
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String authType = request.getAuthType();
String userUid = request.getHeader("REMOTE_USER");
String userUidlower = request.getHeader("remote_user");
Enumeration<?> headerNames = request.getHeaderNames();
while (headerNames.hasMoreElements()) {
String headerName = (String) headerNames.nextElement();
log.trace(headerName + "-->" + request.getHeader(headerName));
}
log.debug("Username is " + userUid);
log.debug("UsernameLower is " + userUidlower);
log.debug("AuthType is " + authType);
Map<String, String[]> headers = FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderValuesMap();
for (String name : headers.keySet()) {
log.trace(name + "==>" + StringUtils.join(headers.get(name)));
}
if (StringHelper.isEmpty(userUid) || StringHelper.isEmpty(authType) || !authType.equals("shibboleth")) {
result = false;
return result;
}
Pattern pattern = Pattern.compile("[email protected]+\\.[a-z]+");
Matcher matcher = pattern.matcher(userUid);
User user = null;
if (matcher.matches()) {
// Find user by uid
user = personService.getPersonByEmail(userUid);
} else {
// Find user by uid
user = personService.getUserByUid(userUid);
}
if (user == null) {
result = false;
return result;
}
log.debug("Person Inum is " + user.getInum());
if (GluuStatus.ACTIVE.getValue().equals(user.getAttribute("gluuStatus"))){
credentials.setUsername(user.getUid());
// credentials.setPassword("");
Principal principal = new SimplePrincipal(user.getUid());
log.debug("Principal is " + principal.toString());
identity.acceptExternallyAuthenticatedPrincipal(principal);
log.info("User '{0}' authenticated with shibboleth already", userUid);
identity.quietLogin();
postLogin(user);
Contexts.getSessionContext().set(OxTrustConstants.APPLICATION_AUTHORIZATION_TYPE,
OxTrustConstants.APPLICATION_AUTHORIZATION_NAME_SHIBBOLETH2);
result = true;
if (Events.exists()) {
facesMessages.clear();
Events.instance().raiseEvent(Identity.EVENT_LOGIN_SUCCESSFUL);
}
}else{
result = false;
}
return result;
}
开发者ID:AgarwalNeha1,项目名称:gluu,代码行数:76,代码来源:Authenticator.java
示例18: clear
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
public static void clear()
{
Contexts.getApplicationContext().remove("transactionStatus");
}
开发者ID:windup,项目名称:windup-rulesets,代码行数:5,代码来源:TransactionStatus.java
示例19: updateInstanceLastModifiedInfo
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
/**
* updates the embedded entity's "Last Modified" date and user
*/
private void updateInstanceLastModifiedInfo() {
User currentUser = (User) Contexts.getSessionContext().get(JpaIdentityStore.AUTHENTICATED_USER);
getInstance().setDateLastModified(new Date());
getInstance().setUserLastModified(currentUser);
}
开发者ID:ecollado92,项目名称:TransitDataFeeder,代码行数:9,代码来源:LocationHome.java
示例20: testChangePassword
import org.jboss.seam.contexts.Contexts; //导入依赖的package包/类
@Test
public void testChangePassword() throws Exception
{
Identity identity = Identity.instance();
Contexts.getSessionContext().set("user", new User("Gavin King", "foobar", "gavin"));
identity.setUsername("gavin");
identity.setPassword("foobar");
identity.login();
User user = (User)Component.getInstance("user");
assertEquals("Gavin King", user.getName());
assertEquals("gavin", user.getUsername());
assertEquals("foobar", user.getPassword());
assertFalse(Manager.instance().isLongRunningConversation());
assertTrue(identity.isLoggedIn());
user.setPassword("xxxyyy");
ChangePassword changePassword = (ChangePassword)Component.getInstance("changePassword");
changePassword.setVerify("xxyyyx");
changePassword.changePassword();
user = (User)Component.getInstance("user");
assertEquals("Gavin King", user.getName());
assertEquals("gavin", user.getUsername());
assertEquals("foobar", user.getPassword());
assertFalse(Manager.instance().isLongRunningConversation());
assertTrue(identity.isLoggedIn());
user = (User)Component.getInstance("user");
user.setPassword("xxxyyy");
changePassword = (ChangePassword)Component.getInstance("changePassword");
changePassword.setVerify("xxxyyy");
changePassword.changePassword();
user = (User)Component.getInstance("user");
assertEquals("Gavin King", user.getName());
assertEquals("gavin", user.getUsername());
assertEquals("xxxyyy", user.getPassword());
assertFalse(Manager.instance().isLongRunningConversation());
assertTrue(identity.isLoggedIn());
user = (User)Component.getInstance("user");
assertEquals("xxxyyy", user.getPassword());
user.setPassword("foobar");
changePassword = (ChangePassword)Component.getInstance("changePassword");
changePassword.setVerify("foobar");
changePassword.changePassword();
user = (User)Component.getInstance("user");
assertEquals("Gavin King", user.getName());
assertEquals("gavin", user.getUsername());
assertEquals("foobar", user.getPassword());
assertFalse(Manager.instance().isLongRunningConversation());
assertTrue(identity.isLoggedIn());
}
开发者ID:seam2,项目名称:seam-examples-migrated-off-seam2,代码行数:57,代码来源:ChangePasswordTest.java
注:本文中的org.jboss.seam.contexts.Contexts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论